2010-12-22 22 views
5

我想要rails3上的ruby上的uploadify的黃瓜測試3.我曾嘗試點擊從水豚上傳按鈕,但因爲它既不是按鈕也不鏈接。此外,它隱藏了text_field,所以我不能寫「當我用」text.txt「填寫」上傳「時。如果有人解決了這個問題,請在這裏提供幫助。使用黃瓜測試rails3上的uploadify 3

回答

1

上傳

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」

1

你會需要編寫上傳文件

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

如果圖像被上傳得到該文件的HTML元素的名稱自定義步驟。

+0

好..我會試試這個......如果它適合我​​。 – 2010-12-23 10:09:41