我是Ruby / Rails的新手,尤其是Capybara和整个过程,所以请耐心等待,因为我已经花了很多时间在这上面,我终于决定问,因为我确定它是一些简单的东西,我只是还没有意识到。
所以我有一个表单,其中有几个复选框,用于过滤显示的结果(即,您选择一个或多个并提交并重新加载页面,并过滤列表)。在我的功能文件中,我有以下场景(提交表单的按钮有一个值=“刷新”):
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
当我使用rake功能运行时,它会提供以下输出:
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 :(得分:0)
您的问题是您没有安装任何浏览器来处理html文件。 您似乎正在使用无头服务器(没有X),因此您的系统正在尝试找到一个合适的浏览器(可以从命令行运行)。
查看Capybara drivers并选择合适的一个。