jeudi 25 mai 2017

My Rails Test is Passed on Local but, Failed on Travis CI

This is my Integration Test Code for User's Sign In/Up/Out Activity

require 'test_helper'

class UserFlowTest < ActionDispatch::IntegrationTest
  setup do
    @user = users(:one)
    @password = '1234qwer'
  end

  test "signed in user is redirected to root_path" do
    get user_session_path
    assert_equal 200, status
    sign_in(@user.user_id, @password)
    assert_equal 200, status
    assert_equal "/", path
  end

  test "signed out user is redirected to unauthticated_root_path" do
    sign_in(@user.user_id, @password)
    delete destroy_user_session_path
    follow_redirect!
    assert_equal 200, status
    assert_equal "/", path
  end

  test "signed up user is redirected to root_path" do
    get new_user_registration_path
    assert_equal 200, status
    post user_registration_path('user[user_id]': "ihaveid", 'user[password]': "1234qwer", 'user[password_confirmation]': '1234qwer',
                                'user[name]': "ihavename", 'user[email]': "ihave@email.com", 'user[birthday]': DateTime.now, 'user[phone]': "1")
    follow_redirect!
    assert_equal 200, status
    assert_equal "/", path
  end

  test "return to registration_path when invalid sign up" do
    get new_user_registration_path
    assert_equal 200, status
    post user_registration_path('user[user_id]': "ihaveid", 'user[password]': "1234qwer", 'user[password_confirmation]': '1234qwer',
                                'user[email]': "ihave@email.com", 'user[birthday]': DateTime.now, 'user[phone]': "1")
    assert_equal 200, status
    assert_equal user_registration_path, path
  end
end

It is passed on local with No errors

But, I take some Error in Travis CI while Testing.

............E
Error:
UserFlowTest#test_signed_up_user_is_redirected_to_root_path:
RuntimeError: not a redirect! 422 Unprocessable Entity
    test/integration/user_flow_test.rb:30:in `block in <class:UserFlowTest>'
bin/rails test test/integration/user_flow_test.rb:25
E
Error:
UserFlowTest#test_signed_in_user_is_redirected_to_root_path:
RuntimeError: not a redirect! 422 Unprocessable Entity
    test/test_helper.rb:15:in `sign_in'
    test/integration/user_flow_test.rb:12:in `block in <class:UserFlowTest>'
bin/rails test test/integration/user_flow_test.rb:9
E
Error:
UserFlowTest#test_signed_out_user_is_redirected_to_unauthticated_root_path:
RuntimeError: not a redirect! 422 Unprocessable Entity
    test/test_helper.rb:15:in `sign_in'
    test/integration/user_flow_test.rb:18:in `block in <class:UserFlowTest>'
bin/rails test test/integration/user_flow_test.rb:17
F
Failure:
UserFlowTest#test_return_to_registration_path_when_invalid_sign_up [/home/travis/build/Dal4Segno/KeeperWeb/test/integration/user_flow_test.rb:40]:
Expected: 200
  Actual: 422
bin/rails test test/integration/user_flow_test.rb:35
Finished in 7.691294s, 2.0803 runs/s, 2.0803 assertions/s.
16 runs, 16 assertions, 1 failures, 3 errors, 0 skips
The command "bundle exec rake test" exited with 1.
Done. Your build exited with 1.

I wonder whether the problem is in my Test Codes or set of Configuration.

Aucun commentaire:

Enregistrer un commentaire