我有:
When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
with_scope(selector) do
click_link(link)
end
end
我打电话给:
Background:
Given I am an existing admin user
When I follow "CLIENTS"
我的 HTML 是这样的:
<a class="active" href="/companies"><h2>CLIENTS</h2></a>
我不断收到这个错误:
.F-.F--U-----U
(::) failed steps (::)
no link with title, id or text 'CLIENTS' found (Capybara::ElementNotFound)
(eval):2:in `click_link'
./features/step_definitions/web_steps.rb:54:in `block (2 levels) in <top (required)>'
./features/step_definitions/web_steps.rb:14:in `with_scope'
./features/step_definitions/web_steps.rb:53:in `/^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/'
features/client_add.feature:8:in `When I follow "CLIENTS"'
我尝试了一些事情:
When I follow "<h2>CLIENTS</h2>"
甚至尝试了save_and_open_page
哪个应该打开浏览器并仍然得到相同的结果:
Given /^I am an existing admin user$/ do
role_user = FactoryGirl.create(:role_user)
admin_user = role_user.user
sign_in(admin_user)
save_and_open_page
end
有没有办法打印 HTML 或找出我的测试失败的原因?