Rails Integration Tests
Blog ยป Rails Integration Tests
Posted on 24 Jun 2009 14:46
Integration tests used to be a pain. Now you can really write the scenarios as they should be and have your integration tests: Shoulda + Factory_Girl + Webrat for Rails Integration Tests:
Matt Lins has a beautiful example there:
class AdminLoginTest < ActionController::IntegrationTest context 'An employee' do setup do @employee = Factory(:employee) end should 'be able to login with a valid username and password' do visit '/admin' assert https? assert_equal '/admin/sessions/new', path fills_in 'Email', :with => @employee.user.email fills_in 'Password', :with => @employee.user.password clicks_button 'Log In' assert_equal @employee.user.id, session[:user_id] end should 'be denied access with an invalid username or password' do visit '/admin' assert https? assert_equal '/admin/sessions/new', path fills_in 'Email', :with => @employee.user.email fills_in 'Password', :with => 'wrongpassord' clicks_button 'Log In' assert_nil session[:user_id] end end end
If you like this page, please spread the word:
You can contact me if you have questions or corrections.


