Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 has solved this problem, please help is needed here.

like image 300
Deepak Lamichhane Avatar asked Nov 05 '22 05:11

Deepak Lamichhane


1 Answers

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"

like image 193
Dipak Panchal Avatar answered Nov 09 '22 04:11

Dipak Panchal