-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking tests / travis builds - Mocha gem was updated. #1137
Comments
I think the problem is actually that you are not initializing Mocha correctly. For quite a long time now, Rails has been using Minitest not Test::Unit, and so you should be requiring "mocha/minitest" on this line, not "mocha/test_unit" as per the instructions in the Mocha README. These instruction have been unchanged since Mocha v1.0.0. However, making that change then starts verifying your Mocha expectations and you end up with a different test failure:
This hasn't been failing until now, because Mocha wasn't being initialized correctly and thus no expectations were being verified. I'll leave you to work out why this expectation is not being satisfied. I hope this helps. |
Thanks for looking into this @floehopper! I'll try updating the setup for Mocha. UPDATE: However, it appears that this new failure should in fact happen! The test in question sets an expectation that any instance of the User model should receive the |
- Update file to require correct Mocha lib for MiniTest (instead of Test::Unit). Using the wrong lib previously, meant that Mocha was never verifying the stubbed method, and the test passed (erroneously). - Update test to expect the correct method call for sign_in. Resolves lynndylanhurley#1137.
This issue seems to have appeared right around the same time I merged #1134 into
master
. It looks like it's happening on other builds as well though.A recent update to the Mocha gem (release 1.5.0) prevents the use of Mocha outside of test/examples.
This seems to break all of the Travis CI builds, since they try to bundle the latest release.
The simplest solution is probably to specify
~> 1.4.0
in theGemfile
.That said, it seems like the only place Mocha is used in this project is in
/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb
. Perhaps the better long term approach is to refactor that test to either: (A) not stub method calls in thebefore
blocks, (B) stub the methods with Minitest instead (thereby removing the dependency on Mocha), or (C) replace the stubbed responses with real data and not stub any methods at all (thereby removing the dependency on Mocha).I should probably add, the test in question inherits from
ActionDispatch::IntegrationTest
, so it is probably a bad idea to be stubbing method calls here.The text was updated successfully, but these errors were encountered: