rails-4-1-rspec-3-0
rails-4-1-rspec-3-0 copied to clipboard
Ch 8. Feature spec works without find method
users_spec uses find method:
expect{
click_link 'Users'
click_link 'New User'
fill_in 'Email', with: '[email protected]'
find('#password').fill_in 'Password', with: 'secret123'
find('#password_confirmation').fill_in 'Password confirmation',
with: 'secret123'
click_button 'Create User'
}.to change(User, :count).by(1)
However it works without it:
expect{
click_link 'Users'
click_link 'New User'
fill_in 'Email', with: '[email protected]'
fill_in 'Password', with: 'secret123'
fill_in 'Password confirmation', with: 'secret123'
click_button 'Create User'
}.to change(User, :count).by(1)
Please consider another example for the usage of find. (Sorry, I have no idea now.)