Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails3, Cucumber, Capybara, File upload => bad content body (EOFError)?

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.

like image 379
astjohn Avatar asked Sep 14 '10 16:09

astjohn


1 Answers

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

like image 189
astjohn Avatar answered Sep 22 '22 22:09

astjohn