Note that there are some explanatory texts on larger screens.

plurals
  1. POTests pass using "autotest" but not "rake test" using Authlogic
    primarykey
    data
    text
    <p>My tests fail when doing "rake test:functionals" but they pass consistently using autotest.</p> <p>The failing tests in question seems to be related to Authlogic not logging in the user properly when using rake.</p> <p>For facilitating signing in a user in tests, I have a test helper method as follows:</p> <pre><code>class ActionController::TestCase def signin(user, role = nil) activate_authlogic UserSession.create(user) user.has_role!(role) if role end end </code></pre> <p>The above method is used to signin a user</p> <p>My stack is shoulda/authlogic/acl9/factory_girl/mocha</p> <p>The reason why I suspect Authlogic being the issue is the failing tests look like this:</p> <pre><code> 54) Failure: test: A logged in user PUT :update with valid data should redirect to user profile. (UsersControllerTest) [/var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/action_controller/macros.rb:202:in `__bind_1251895098_871629' /var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call' /var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: A logged in user PUT :update with valid data should redirect to user profile. ']: Expected response to be a redirect to &lt;http://test.host/users/92&gt; but was a redirect to &lt;http://test.host/signin&gt;. 55) Failure: test: A logged in user PUT :update with valid data should set the flash to /updated successfully/i. (UsersControllerTest) [/var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/assertions.rb:55:in `assert_accepts' /var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/action_controller/macros.rb:41:in `__bind_1251895098_935749' /var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `call' /var/lib/gems/1.8/gems/thoughtbot-shoulda-2.10.2/lib/shoulda/context.rb:351:in `test: A logged in user PUT :update with valid data should set the flash to /updated successfully/i. ']: Expected the flash to be set to /updated successfully/i, but was {:error=&gt;"You must be signed in to access this page"} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload