Reputation: 4532
I've been analizing the code but i can't find an answer.
i get an error running the next spec:
describe 'with valid information' do
before {
fill_in 'Name', with: 'Example User'
fill_in 'Email', with: '[email protected]'
fill_in 'Password', with: 'foobar'
fill_in 'Confirmation', with: 'foobar'
}
it 'should create a user' do
expect {click_button submit}.to change(User, :count).by(1)
end
describe "after saving the user" do
before {click_button submit}
let(:user) {User.find_by_email('[email protected]')}
it {should have_selector('title', text:user.name)}
it {should have_selector('div.alert.alert-success', text: "Welcome")}
end
end
the error is with the "after saving the user" part, and checking the selector div.alert.alert-success:
Failure/Error: it {should have_selector('div.alert.alert-success', text: "Welcome")}
expected css "div.alert.alert-success" with text "Welcome" to return something
My users_controller sends the flash hash with key success:
flash[:succes] = "Welcome"
redirect_to @user
and even the success sign-up sends a tag div with class="alert alert-success" in the page:
<div class="alert alert-succes">
Welcome
</div>
Is there a way to know what is rendering the click_button submit in the test so i can see what is going on? Some way to see the resulting HTML resulting from it in the console
Note It's worth it to say that if i change the test to only should have_selector('div.alert', text: "Welcome" (without the alert-success class), it passes
Thanks in advance
Upvotes: 0
Views: 88