在 Rails 3 上使用 Cucumber 测试进行上传 [英] Using Cucumber testing for uploadify on rails 3

查看:14
本文介绍了在 Rails 3 上使用 Cucumber 测试进行上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在 rails 3 上的 ruby​​ 上对上传进行黄瓜测试.我曾尝试单击 capybara 的上传按钮,但它既不是按钮也不是链接.此外,它隐藏了text_field,所以我不能写当我用text.txt"填写上传"时".如果有人解决了这个问题,请在这里提供帮助.

I want cucumber test for uploadify on ruby on rails 3. I had tried to click on the upload button from capybara but as it is neither button nor link. Furthermore, it is hiding the text_field so I cannot write "When I fill in "upload" with "text.txt"". If any one has solved this problem, please help is needed here.

推荐答案

编写上传文件的自定义步骤

Write custom step for uploading a file

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

黄瓜步像

当我将文件/images/back.gif"附加到data_input"时

When I attach the file "/images/back.gif" to "data_input"

这篇关于在 Rails 3 上使用 Cucumber 测试进行上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆