Я довольно плохо знаком с Ruby / Rails и особенно с Capybara и всем процессом, поэтому, пожалуйста, потерпите меня, поскольку я уже потратил много времени на это, и я наконец решил спросить, потому что я уверен, что эточто-то простое, о чем я пока еще ничего не знаю.
Итак, у меня есть форма с несколькими флажками, предназначенными для фильтрации отображаемых результатов (т. е. вы выбираете один или несколько и отправляете, а затем на страницу w).перезагрузки с отфильтрованным списком).В моем файле функций у меня есть следующие сценарии (кнопка для отправки формы имеет значение = "Обновить"):
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
Я занимался исследованиями в те дни, когда у меня есть время, а я так много не знаю.Любая помощь или идеи будут с благодарностью.Спасибо!