Archive for the ‘functionals tests’ Category
Rails functional test : what to test?
What to test in a functiona test?
Then what we need to test ?
- Assert that the page action rendered and returned successful HTTP response code, i.e. 200.
- Assert that the correct template was rendered.
- assert that the correct flash message was rendered
- Assert that action assigns a value to the @user variable.
- Assert that the right @user object was loaded.
class Admin::UserController def test_show get :show, :id => 1 # assert that the http response was 200 assert_response :success # assert that the correct template was rendered assert_template 'admin/userr/show' # assert that the variable @user was assigned assert assigns( :user) # assert that the variable @user was assigned with the correct values assert_equal 'Joel', assigns(:user).first_name assert_equal 'Spolsky', assigns(:user).last_name end end