开发者

Using Cucumber testing for uploadify on rails 3

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 ha开发者_开发百科s 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

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


You would need to write a custom step for uploading a file

When /^I upload a file$/ do
    attach_file(:image, <path-to-file>)
end 

Where image is the name of the html element for getting the file to be uploaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜