ruby-on-rails - 使用 Cucumber 测试在 rails 3 上上传

标签 ruby-on-rails testing cucumber uploadify

我想要在 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/

相关文章:

Android MVP - 应该避免在演示者中使用 R.string 引用吗?

html - 如何使用 cucumber-html-reporter 在 html 报告中添加内联 css

ruby-on-rails - git - 无法推送到远程,错误 'fatal: Not a git repository'

css - 如何使用@media 查询在 rails 中添加照片作为 div 的背景?

ruby-on-rails - 将大模板 Assets 链接到 rails erb 文件的正确方法是什么?

ruby-on-rails - ActiveModel 序列化程序 : How do I serialize a resource collection?

testing - UI 测试应该在构建服务器上运行还是在部署后运行?

android - Robotium 侧滚动不适合我

java - IntelliJ 对 Cucumber 4.7 的支持

ruby - 你如何将 cucumber 场景标记为待处理