flexmock
flexmock copied to clipboard
flexmock with minitest throws NoMethodError: undefined method `assertions'
Running
gem 'minitest' require 'minitest/autorun' require 'flexmock' class TestMergeCommand <Minitest::Test include FlexMock::TestCase def test_execute app = flexmock('app') app.should_receive(:dummy).once @model = Array.new assert_nil(@model.index(app)) end end
gives
Run options: --seed 27174
Running:
E Finished in 0.001054s, 949.1800 runs/s, 949.1800 assertions/s.
- Error: TestMyClass#test_my_class: NoMethodError: undefined method
assertions' for #<FlexMock::TestUnitFrameworkAdapter:0x000000013ea4d0> test/pry_test.rb:28:in
test_my_class' 1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
Tested with
- Ruby 1.9.3p448
- flexmock 1.3.2
- minitest-5.0.8
Under Ruby 2.0.0 it works:
Run options: --seed 53091
Running:
E
Finished in 0.108801s, 9.1911 runs/s, 9.1911 assertions/s.
- Error:
TestMyClass#test_my_class:
Test::Unit::AssertionFailedError: in mock 'classToBeMocked': Method 'will_never_be_called(*args)' called incorrect number of times
1 matching call expected
0 matching calls found
The following messages have been received:
returns_false() matched by should_receive(:returns_false).once
.
is not true. test/pry_test.rb:28:in test_my_class' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:51:in
block in assert_block' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:1437:incall' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:1437:in
_wrap_assertion' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:49:inassert_block' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:82:in
block in assert'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:1442:incall' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:1442:in
_wrap_assertion'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:64:inassert' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/test_unit_integration.rb:53:in
make_assertion'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/validators.rb:60:inblock in validate_count' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:414:in
flexmock_location_filter'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/validators.rb:59:invalidate_count' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/validators.rb:78:in
validate'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:141:inblock in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:140:in
each'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:140:inflexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation_director.rb:65:in
block in flexmock_verify'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation_director.rb:64:ineach' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation_director.rb:64:in
flexmock_verify'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:86:inblock (2 levels) in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:85:in
each'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:85:inblock in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:266:in
flexmock_wrap'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:84:inflexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:40:in
block in flexmock_verify'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:39:ineach' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:39:in
flexmock_verify'
/home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:32:inflexmock_teardown' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/test_unit_integration.rb:39:in
teardown'
1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
More information about that one: minitest 5 requires everything that includes MiniTest::Assertions to provide an "assertions" accessor. See seattlerb/minitest#286
A word: I'm trying to take over the maintenance of flexmock. It's unfortunately bit-rotting since Jim's passing, and that's really a pity - both for his memory as a great contributor to Ruby's community and as a really nice piece of software.
I've fixed that particular issue, as well as added minitest-specific support and some other things there: https://github.com/doudou/flexmock. I'm going to try and get the rights to push new gems versions, but I really don't know if it's going to happen.