file-upload - Rails3、Cucumber、Capybara、文件上传 => 内容正文错误(EOFError)?

标签 file-upload ruby-on-rails-3 cucumber capybara

我很难进行简单的文件上传测试。我在 ruby​​ 1.9.2 上使用 Rails 3.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 %>

cucumber 步骤:

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

在我的 Controller 中,我已注释掉除以下内容之外的所有内容:

def create
  file = params[:file]
end

gem 文件片段:

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'

我感谢任何帮助或见解。谢谢。

最佳答案

事实证明这是机架测试的一个问题,在更多人采用 Rails3 和 Ruby 1.9.x 之前,对于大多数人来说这可能不会成为问题。

将机架测试升级到 current master branch解决了问题。 我不确定机架测试何时会在 gem 中包含这些更改。

另请参阅: groups.google.com/group/cukes/browse_thread/thread/5028306893c2c54a

关于file-upload - Rails3、Cucumber、Capybara、文件上传 => 内容正文错误(EOFError)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3710959/

相关文章:

post - "Translating"POST 文件上传 HTML 到 curl 命令行

java - cucumber .runtime.CucumberException : Arity mismatch: Step Definition

python - 如何在不使用 html 表单的情况下将文件发布到 django

ruby - Rails 3 模型记录器

Ruby 条件 If Else 赋值

ruby-on-rails - Rails 3.2 rake 编译问题

ruby - cucumber 和应该达的主要区别是什么?

cucumber Js : is it possible to define more than one "World"

java - 如何接收文件并将其发送到不同的服务器

javascript - 取消输入类型 ="file"上的事件隐藏