Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Running the test suite with mocha 1.5 fails #10

Open
mbigras opened this issue Apr 27, 2018 · 0 comments
Open

Running the test suite with mocha 1.5 fails #10

mbigras opened this issue Apr 27, 2018 · 0 comments

Comments

@mbigras
Copy link

mbigras commented Apr 27, 2018

Reproduction steps

git clone https://github.com/mbigras/kashmir
cd kashmir/
git co ce9164251f7f27911f64a528e2cdb19c81533bc7
curl https://gist.githubusercontent.com/mbigras/b215f08c7d78226d37fc1c7d8732316d/raw/9fc48d9b3381532c2975a8b73246abfc0af2f6d5/gistfile1.txt > Gemfile.lock
bundle install
bundle exec rake
...
Finished in 0.438303s, 95.8241 runs/s, 136.8916 assertions/s.

  1) Error:
Caching::misc#test_0001_does not cache already cached results:
Mocha::NotInitializedError: Mocha methods cannot be used outside the context of a test
    /Users/mbigras/Box Sync/Projects/github.com/mbigras/kashmir/test/caching_test.rb:176:in `block (3 levels) in <top (required)>'

Seems like the root cause is we're not initializing mocha correctly.
More details at:

lynndylanhurley/devise_token_auth#1137 (comment)

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"

Using mocha/minitest is also mentioned in the README:

https://github.com/freerange/mocha/tree/v1.5.0#minitest-1

MiniTest
# Gemfile in Rails app
gem 'mocha'

# At bottom of test_helper.rb (or at least after `require 'rails/test_help'`)
require 'mocha/minitest'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant