Skip to content
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

flexmock with minitest throws NoMethodError: undefined method `assertions' #16

Open
ngiger opened this issue Sep 25, 2013 · 3 comments
Open

Comments

@ngiger
Copy link

ngiger commented Sep 25, 2013

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
Copy link
Author

ngiger commented Sep 25, 2013

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

@doudou
Copy link

doudou commented Jun 15, 2014

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

thulio added a commit to thulio/flexmock that referenced this issue Jul 30, 2014
thulio added a commit to thulio/flexmock that referenced this issue Jul 30, 2014
thulio added a commit to thulio/flexmock that referenced this issue Jul 30, 2014
thulio added a commit to thulio/flexmock that referenced this issue Jul 30, 2014
@doudou
Copy link

doudou commented Jun 29, 2015

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 added a commit to doudou/flexmock that referenced this issue Jun 29, 2015
It is compatible with pre-5 minitest (as shipped with ruby until
at least 2.1) and 5.0+

Note that flexmock's own testsuite currently requires plain ruby,
so you can't run the main testsuite if the 5.0+ minitest gem is active

Fixes jimweirich#15 and
jimweirich#16.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants