ast*_*ohn 8 file-upload cucumber capybara ruby-on-rails-3
我很难让简单的文件上传测试工作.我在使用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 %>
Run Code Online (Sandbox Code Playgroud)
黄瓜步骤:
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
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,除了:
def create
file = params[:file]
end
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
当我尝试运行测试时,我收到:
Run Code Online (Sandbox Code Playgroud)(::) failed steps (::) bad content body (EOFError) <internal:prelude>:10:in `synchronize'
我感谢任何帮助或见解.谢谢.
事实证明,这是机架测试的一个问题,并且在更多人采用 Rails3 和 Ruby 1.9.x 之前,对于大多数人来说这可能不会成为问题。
将rack-test升级到当前的master分支解决了这个问题。我不确定机架测试何时会在 gem 中包含这些更改。
另请参阅: groups.google.com/group/cukes/browse_thread/thread/5028306893c2c54a
| 归档时间: |
|
| 查看次数: |
8027 次 |
| 最近记录: |