文件上传 – Rails3,Cucumber,Capybara,文件上传=>内容正文(E
发布时间:2020-12-16 19:09:45 所属栏目:百科 来源:网络整理
导读:我很难让简单的文件上传测试工作.我在使用Cucumber和Capybara的 ruby 1.9.2上使用Rails 3.0.0. 视图: %= form_tag "/upload/create",:multipart = true do % label for="file"File to Upload:/label %= file_field_tag "file" % %= submit_tag "Upload" %%
我很难让简单的文件上传测试工作.我在使用Cucumber和Capybara的
ruby 1.9.2上使用Rails 3.0.0.
视图: <%= form_tag "/upload/create",:multipart => true do %> <label for="file">File to Upload:</label> <%= file_field_tag "file" %> <%= submit_tag "Upload" %> <% end %> 黄瓜步骤: When /^I upload the basic file$/ do visit path_to("upload") path = File.join(::Rails.root,"somefile") attach_file("file",path) click_button("Upload") end 在我的控制器中,除了: def create file = params[:file] end Gemfile片段: group :development,:test do # testing with specs gem "ZenTest",">= 4.3.3" gem "autotest" gem "rspec-rails",">= 2.0.0.beta.19",:git => "git://github.com/rspec/rspec-rails.git" gem "rspec",:git => "git://github.com/rspec/rspec.git" gem "rspec-core",:git => "git://github.com/rspec/rspec-core.git" gem "rspec-expectations",:git => "git://github.com/rspec/rspec-expectations.git" gem "rspec-mocks",:git => "git://github.com/rspec/rspec-mocks.git" # cucumber stuff gem 'capybara' gem 'database_cleaner' gem 'cucumber-rails' gem 'cucumber' gem 'spork' gem 'launchy' # So you can do Then show me the page gem 'escape_utils' # needed to fix Cucumber - http://crimpycode.brennonbortz.com/?p=42 end 当我尝试运行测试时,我收到:
我感谢任何帮助或见解.谢谢. 解决方法
事实证明这是机架测试的一个问题,在更多人采用Rails3和Ruby 1.9.x之前,它可能不会成为大多数问题.
将机架测试升级到current master branch修复了问题. 也可以看看: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |