flexmock icon indicating copy to clipboard operation
flexmock copied to clipboard

flexmock with minitest throws NoMethodError: undefined method `assertions'

Open ngiger opened this issue 11 years ago • 3 comments

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.

  1. Error: TestMyClass#test_my_class: NoMethodError: undefined method assertions' for #<FlexMock::TestUnitFrameworkAdapter:0x000000013ea4d0> test/pry_test.rb:28:intest_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

ngiger avatar Sep 25 '13 12:09 ngiger

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.

  1. 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:inblock in assert_block' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:1437:in call' /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:in assert_block' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:82:inblock in assert'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/test-unit-2.5.5/lib/test/unit/assertions.rb:1442:in call' /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:in assert' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/test_unit_integration.rb:53:inmake_assertion'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/validators.rb:60:in block in validate_count' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:414:inflexmock_location_filter'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/validators.rb:59:in validate_count' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/validators.rb:78:invalidate'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:141:in block in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:140:ineach'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation.rb:140:in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation_director.rb:65:inblock in flexmock_verify'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation_director.rb:64:in each' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/expectation_director.rb:64:inflexmock_verify'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:86:in block (2 levels) in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:85:ineach'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:85:in block in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:266:inflexmock_wrap'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/core.rb:84:in flexmock_verify' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:40:inblock in flexmock_verify'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:39:in each' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:39:inflexmock_verify'
    /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/mock_container.rb:32:in flexmock_teardown' /home/niklaus/.rvm/gems/ruby-2.0.0-p247/gems/flexmock-1.3.2/lib/flexmock/test_unit_integration.rb:39:inteardown'
    1 runs, 1 assertions, 0 failures, 1 errors, 0 skips

ngiger avatar Sep 25 '13 12:09 ngiger

More information about that one: minitest 5 requires everything that includes MiniTest::Assertions to provide an "assertions" accessor. See seattlerb/minitest#286

doudou avatar Jun 15 '14 12:06 doudou

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.

doudou avatar Jun 29 '15 13:06 doudou