2012-03-26 55 views
0

我很新的Ruby/Rails,尤其是水豚和整個過程,所以請忍受我,因爲我已經花了很多時間在這已經和我終於決定提問,因爲我確信這很簡單,我只是還沒有意識到。水豚問題當試圖點擊表單提交按鈕

所以我有一個表格,有幾個複選框,旨在過濾顯示的結果(即,您選擇一個或多個提交和頁面重新加載過濾列表)。在我的特徵文件,我有以下情形(按鈕提交形式所具有的價值=「刷新」):

Scenario: no ratings selected 
    When I uncheck the following ratings: G, PG, PG-13, NC-17, R 
    And I press "Refresh" 
    Then show me the page 
    And I should see none of the movies 

Scenario: all ratings selected 
    When I check the following ratings: G, PG, PG-13, NC-17, R 
    And I press "Refresh" 
    Then show me the page 
    And I should see all of the movies 

當我跑這跟耙功能,它提供了以下的輸出:

And I press "Refresh"          #  features/step_definitions/web_steps.rb:61 
xprop: unable to open display '' 

我使用page.body在方案稍後,我相信這是原因然後我得到了以下錯誤:

Deprecated: please use #source_tags instead. 
Warning: program returned non-zero exit code #1 
WARNING: You don't seem to have any mimeinfo.cache files. 
Try running the update-desktop-database command. If you 
don't have this command you should install the 
desktop-file-utils package. This package is available from 
<link> 
No applications found for mimetype: text/html 
/usr/bin/xdg-open: 563: links2: not found 
/usr/bin/xdg-open: 563: links: not found 
/usr/bin/xdg-open: 563: lynx: not found 
Error occured while reset 800b: errno=5 
xdg-open: no method available for opening '/home/ubuntu/hw3_rottenpotatoes/tmp/capybara /capybara-201203260037535403047955.html' 
Error occured: errno=5 
Warning: program returned non-zero exit code #1 
WARNING: You don't seem to have any mimeinfo.cache files. 
Try running the update-desktop-database command. If you 
don't have this command you should install the 
desktop-file-utils package. This package is available from 
<link> 
No applications found for mimetype: text/html 
/usr/bin/xdg-open: 563: links2: not found 
/usr/bin/xdg-open: 563: links: not found 
/usr/bin/xdg-open: 563: lynx: not found 
Error occured while reset 800b: errno=5 
xdg-open: no method available for opening '/home/ubuntu/hw3_rottenpotatoes/tmp/capybara /capybara-201203260037534847572739.html' 
Error occured: errno=5 
Warning: program returned non-zero exit code #1 
WARNING: You don't seem to have any mimeinfo.cache files. 
Try running the update-desktop-database command. If you 
don't have this command you should install the 
desktop-file-utils package. This package is available from 
<link> 
No applications found for mimetype: text/html 
/usr/bin/xdg-open: 563: links2: not found 
/usr/bin/xdg-open: 563: links: not found 
/usr/bin/xdg-open: 563: lynx: not found 
Error occured while reset 800b: errno=5 
xdg-open: no method available for opening '/home/ubuntu/hw3_rottenpotatoes/tmp/capybara /capybara-20120326003754980186501.html' 

下面是相關的步驟定義

When /I (un)?check the following ratings: (.*)/ do |unc, rating_list| 
    rating_list.split(", ").each do |r| 
    if(unc) 
     uncheck("ratings_#{r}") 
    else 
     check("ratings_#{r}") 
    end 
    end 
    assert true, "Implemented checking function" 
end 


Then /I should (not)?see movies with the following ratings: (.*)/ do |nt, rating_list| 
    flag = true 
    rating_list.split(", ").each do |r| 
    if(nt) 
     if(page.body =~ /<td>#{r}/) 
     flag = false; 
     end 
    else 
     if(page.body !~ /<td>#{r}/) 
     flag = false 
     end 
    end 
    end 
    assert flag, "Seeing (or not) movies of ratings list - implemented" 
end 


Then /I should see all of the movies/ do 
    tot = Movie.all.count 
    assert page.have_selector('tbody tr', :count => tot) 
end 


Then /I should see none of the movies/ do 
    num = page.body.scan(/00:00:00 UTC/m).length 
    assert size == 0, "Showing no movies - implemented" 
end 



When /^(?:|I)press "([^"]*)"$/ do |button| 
    click_button(button) 
end 

Then /^show me the page$/ do 
    save_and_open_page 
end 

我一直在研究的日子裏,當我有時間,有這麼多,我不知道。任何幫助或見解將不勝感激。謝謝!

+0

您可以顯示步驟定義嗎? – Nobita 2012-03-26 04:23:55

+0

當然,我添加了相關的。 – 2012-03-26 13:20:10

+0

我想說這更多的是一個環境/平臺問題。比你的步驟寫的方式。你可以運行其他測試嗎?您是否檢查過錯誤消息中提到的desktop-file-utils軟件包? – 2012-03-26 20:46:30

回答

0

你的問題是你沒有安裝任何瀏覽器來處理html文件。 看來您正在使用無頭服務器(無X),因此您的系統正在嘗試查找合適的瀏覽器(可以從命令行運行的瀏覽器)。

看看Capybara drivers並選擇一個合適的。