用户登录后,我无法让 Cucumber / Capybara 在页面上找到“成功”闪存消息。如果我在浏览器中手动操作,我可以看到该消息,所以我想我在我的步骤中做错了什么。
user_login.feature
Feature: User login
Scenario: A user successfully logs in from the homepage
Given A user is on the homepage
When the user clicks "Login"
And they fill out the form
Then they should see a success message
步骤定义
Given /^A user is on the homepage$/ do
@user = Factory.create(:user)
visit root_path
end
When /^the user clicks "(.*?)"$/ do |arg1|
click_link arg1
end
When /^they fill out the form$/ do
fill_in "email", with: @user.email
fill_in "password", with: "blahblah1"
click_button "Sign in"
end
Then /^they should see a success message$/ do
page.should have_selector ".alert", text: "Logged in!"
end
输出
expected css ".alert" with text "Logged in!" to return something (RSpec::Expectations::ExpectationNotMetError)