簡単なファイルアップロードテストを機能させるのに苦労しています。私はRuby1.9.2でRails3.0.0をCucumberとCapybaraで使用しています。
意見:
<%= 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
テストを実行しようとすると、次のようになります。
(::) failed steps (::) bad content body (EOFError) <internal:prelude>:10:in `synchronize'
助けや洞察に感謝します。ありがとう。