Comments (9)
@alexdunae Thanks for reporting this - I've opened #646 to see if we can provide a more useful error message in this scenario.
from mocha.
I hope you don't mind but I tidied up the formatting in the issue description.
Upgraded from 1.0 to 2.0
Can you confirm this means you've upgraded mocha from v1.0 to v2.0?
Mocha v1.0 was released in 2014, i.e. 9 years ago! Do you really mean you have upgraded from v1.0 -> v2.0? If so, can you try upgrading to the latest v1.x release first, i.e. v1.16.1. Also I'd recommend upgrading to the latest v2.x release, i.e. v2.0.2, not v2.0.0.
NoMethodError: undefined method `pop' for nil:NilClass
What command generated this ☝️ stack trace?
The stack trace suggests mocha's setup is not getting called correctly. Do you have any other test-related gems installed? Can you post your Gemfile
?
What version of Ruby are you using?
from mocha.
Also can you try running the tests with the MOCHA_OPTIONS
env var set to "debug" and post the output?
from mocha.
from mocha.
Are there any test setup
methods or blocks in test_helper.rb
or its associated files?
from mocha.
i saw a post talking about
require 'mocha/setup'
but dont see that in this code... Is that needed?
from mocha.
OK.. got it working... So basically fixtures being loaded beforehand had some bad data.
Caused the error test_helper to error out. Which caused the mocha/minitest to not load.. which caused the stack trace error above.
There was so much output i never saw the very first error of the fixture data.
from mocha.
I'm glad you got to the bottom of it! And thanks for letting me know and closing the issue. 😄
from mocha.
I also ran into this same error...
NoMethodError: undefined method `pop' for nil:NilClass
@instances.pop
^^^^
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/mocha-2.2.0/lib/mocha/mockery.rb:54:in `ensure in teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/mocha-2.2.0/lib/mocha/mockery.rb:54:in `teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/mocha-2.2.0/lib/mocha/hooks.rb:39:in `mocha_teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/mocha-2.2.0/lib/mocha/integration/minitest/adapter.rb:47:in `after_teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.3.2/lib/active_support/testing/time_helpers.rb:71:in `after_teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.1.3.2/lib/action_cable/test_helper.rb:17:in `after_teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activerecord-7.1.3.2/lib/active_record/test_fixtures.rb:15:in `after_teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.1.3.2/lib/active_support/testing/setup_and_teardown.rb:51:in `after_teardown'
/home/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/activejob-7.1.3.2/lib/active_job/test_helper.rb:54:in `after_teardown'
And the note from @riniculous about fixtures helped get me on my way.
I had been saving cassettes in test/fixtures/vcr_cassettes
but that was causing them to be loaded as regular Rails fixtures.
Moving the cassettes directory out of test/fixtures
solved the problem.
from mocha.
Related Issues (20)
- Stub by id
- Mocha::StateMachine states method stomps on states fixture HOT 8
- Stubs on instances of DelegateClass do not behave as expected HOT 9
- Add docs about issues & workarounds for using Mocha with BasicObject & the various Delegator classes
- YARD docs for Mock#method_missing is broken HOT 1
- Update Ruby Hash syntax in docs
- Drop support for Ruby v2.0
- Drop support for Ruby v2.1
- Document some of the history of Mocha
- Improve failure message
- sometimes method fails to be mocked HOT 8
- Sign releases
- Stubbed methods not cleaned up post spec completion HOT 1
- Consider using GitHub-flavoured markdown notes, warnings, etc in README
- Mocha and Rails 7.0+ and controller tests HOT 3
- Run CI build with `--enable-frozen-string-literal` Ruby command line option
- Fix Circle CI builds for Ruby v2.0 or discontinue support
- undefined method `sequences' HOT 5
- Better error message if `Mockery.teardown` is called when `Mockery.setup` has not been called successfully
- Parameter matching fails on keyword arguments HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mocha.