gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 06:14:31 26 4
gpt4 key购买 nike

我很难进行简单的文件上传测试。我在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com