Rails3,Cucumber,Capybara,File upload =>坏内容体(EOFError)? [英] Rails3, Cucumber, Capybara, File upload => bad content body (EOFError)?
问题描述
我很难获得简单的文件上传测试工作。我在Rugs 3.0.0上使用ruby 1.9.2与Cucumber和Capybara。
查看:
<%= form_tag/ upload / create,:multipart => true do%>
< label for =file>要上传的文件:< / label>
<%= file_field_tagfile%>
<%= submit_tag上传%>
<%end%>
Cucumber步骤:
当/ ^我上传基本文件$ / do
访问path_to(upload)
path = File.join(:: Rails.root,somefile)
attach_file(file,path)
click_button(Upload)
end
$ b b
在我的控制器中,我已经注释掉除了以下内容:
def create
file = params [ :file]
end
Gemfile片段:
group:development,:test do
#使用规格测试
gemZenTest,> = 4.3.3
gemautotest
gemrspec-rails,> = 2.0.0.beta.19,:git => git://github.com/rspec/rspec-rails.git
gemrspec,:git => git://github.com/rspec/rspec.git
gemrspec-core,:git => git://github.com/rspec/rspec-core.git
gemrspec-expectations,:git => git://github.com/rspec/rspec-expectations.git
gemrspec-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'#所以你可以做然后显示页面
gem'escape_utils'#需要修复Cucumber - http: //crimpycode.brennonbortz.com/?p=42
end
运行测试,我收到:
(::)失败的步骤$ b bad content body(EOFError)
< internal:prelude>:10:in'同步'
我很感激任何帮助或见解。谢谢。
这证明是rack-test的问题,它可能不会是一个问题,更多的人采用Rails3和Ruby 1.9.x。
将rack-test升级到当前主分支修复了问题。
我不知道rack-test何时会将这些更改包括在gem中。
另请参见:
groups.google.com/group/cukes/browse_thread/thread/5028306893c2c54a
I'm having a hard time getting a simple file upload test working. I'm using Rails 3.0.0 on ruby 1.9.2 with Cucumber and Capybara.
View:
<%= form_tag "/upload/create", :multipart => true do %>
<label for="file">File to Upload:</label>
<%= file_field_tag "file" %>
<%= submit_tag "Upload" %>
<% end %>
Cucumber Step:
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
In my controller, i have commented out everything except for:
def create
file = params[:file]
end
Gemfile snippet:
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
When I try to run the test, I receive:
(::) failed steps (::) bad content body (EOFError) <internal:prelude>:10:in `synchronize'
I appreciate any help or insight. Thanks.
This turned out to be an issue with rack-test and it probably won't be a problem for most until more people adopt Rails3 and Ruby 1.9.x.
Upgrading rack-test to the current master branch fixed the problem. I'm not sure when rack-test will include these changes in the gem.
See also: groups.google.com/group/cukes/browse_thread/thread/5028306893c2c54a
这篇关于Rails3,Cucumber,Capybara,File upload =>坏内容体(EOFError)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!