对rails上的uploadify使用黄瓜测试3 [英] Using Cucumber testing for uploadify on rails 3

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

问题描述

我想在ruby on rails上的uploadify的黄瓜测试3.我试图点击上传按钮从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

Cucumber Step like

Cucumber Step like

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

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

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

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