我想要在 ruby on rails 3 上对 uploadify 进行 cucumber 测试。我曾尝试单击 capybara 的上传按钮,但因为它既不是按钮也不是链接。此外,它隐藏了 text_field,所以我不能写“当我用“text.txt”填写“上传”时”。如果有人解决了这个问题,请在此处提供帮助。
最佳答案
编写上传文件的自定义步骤
When /^(?:|I)attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
type = path.split(".")[1]
case type
when "jpg"
type = "image/jpg"
when "png"
type = "image/png"
when "gif"
type = "image/gif"
end
attach_file(field, path, type)
end
When /^I attach the "(.*)" file at "(.*)" to "(.*)"$/ do |type, path, field|
attach_file(field,path,type)
end
cucumber 步像
当我将文件“/images/back.gif”附加到“data_input”时
关于ruby-on-rails - 使用 Cucumber 测试在 rails 3 上上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4508460/