Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Installation Of MiniUnit Causes Test To Fail

#2060

The issue appears to be related to Mocha. It loads MiniTest and when MiniTest is defined a total of 27 failures occur for me in actionpack.

A summary of these errors can be seen here: http://pastie.org/398566

The biggest cluster of failing tests I can see are in AssertSelectTest that expect the Assertion constant, which is being assigned by active support's test case to "MiniTest::Assertion" to be raised. However, they are raising "Test::Unit::AssertionFailedError".

Here is a small code snippet that shows the issue. Below it is a slimmed down version of what ActiveSupport::TestCase is doing when defined?(MiniTest) returns the constant.

@@@ruby require 'rubygems' require 'mocha' require 'test/unit'

class TestFailing < Test::Unit::TestCase

Assertion = MiniTest::Assertion

def test_raise

assert_raise(Assertion) { flunk }

end

end

Loaded suite /Users/kencollins/Desktop/foo

Started

# F

Finished in 0.007994 seconds.

#

1) Failure:

test_raise(TestFailing)

method test_raise in foo.rb at line 10

method send in test_case_adapter.rb at line 69

method run in test_case_adapter.rb at line 69

<MiniTest::Assertion> exception expected but was

Class: <Test::Unit::AssertionFailedError>

Message: <"Flunked.">

---Backtrace---

/Users/kencollins/Desktop/foo.rb:10:in test_raise'

/Users/kencollins/Desktop/foo.rb:10:in test_raise'

/opt/local/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/test_case_adapter.rb:69:in __send__'

/opt/local/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/test_case_adapter.rb:69:in run'

---------------

@@@ruby

So is this a rails or mocha issue.

Reported by Ken Collins · February 24th, 2009 @ 05:29 PM

State: committed
Milestone: 2.x
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Ken Collins
    Ken Collins

    Sorry for the bad formatting. Let me try that again. Note, you have to have the MiniUnit gem installed for this and the rails test cases in the link above to fail.

    
    
    require 'rubygems' 
    # gem 'mocha', '>= 0.9.3'
    require 'mocha'
    require 'test/unit'
    
    class TestFailing < Test::Unit::TestCase
      
      Assertion = MiniTest::Assertion
      
      def test_raise
        assert_raise(Assertion) { flunk }
      end
    
    end
    
    
    # Loaded suite /Users/kencollins/Desktop/test_failing
    # Started
    # F 
    # Finished in 0.007939 seconds.
    # 
    #   1) Failure:
    # test_raise(TestFailing)
    # method test_raise in test_failing.rb at line 11
    # method __send__ in test_case_adapter.rb at line 69
    # method run in test_case_adapter.rb at line 69
    # <MiniTest::Assertion> exception expected but was
    # Class: <Test::Unit::AssertionFailedError>
    # Message: <"Flunked.">
    # ---Backtrace---
    # /Users/kencollins/Desktop/test_failing.rb:11:in `test_raise'
    # /Users/kencollins/Desktop/test_failing.rb:11:in `test_raise'
    # /opt/local/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/test_case_adapter.rb:69:in `__send__'
    # /opt/local/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/test_case_adapter.rb:69:in `run'
    # ---------------
    # 
    # 1 tests, 1 assertions, 1 failures, 0 errors
    

    February 24th, 2009 @ 06:17 PM

  2. James Mead
    James Mead

    Hopefully this commit [1] resolves the Mocha aspects of this problem. Let me know if not.

    Thanks, James.

    [1] http://github.com/floehopper/moc...

    March 4th, 2009 @ 07:17 PM

  3. Ken Collins
    Ken Collins

    Well it does fix it but this commit in Mocha...

    http://github.com/floehopper/moc...

    ... breaks active support since it calls on Mocha::TestCaseAdapter::AssertionCounter. I'll upload a patch for active support to work with the upcoming Mocha code org.

    March 10th, 2009 @ 08:19 PM

  4. Ken Collins
  5. Pratik
    Pratik
    • Assigned user set to Jeremy Kemper

    March 10th, 2009 @ 08:38 PM

  6. Repository
    Repository
    • State changed from new to committed

    (from [4b4e7caffa361a1a3317586d8f498b4ba353adba]) The latest trunk of Mocha > 0.9.5 which addresses issue with MiniUnit compatibility uses namespaced integration classes.

    [#2060 Installation Of MiniUnit Causes Test To Fail state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...

    March 10th, 2009 @ 09:24 PM

  7. August Lilleaas
    August Lilleaas

    Do you need some particular version of mocha to be able to run the tests now? I'm experiencing something very similar (http://pastie.org/417598) on the latest edge. Using mocha 0.9.5, via "gem1.9 install mocha".

    March 16th, 2009 @ 01:14 PM

  8. Ken Collins
    Ken Collins

    This can be marked invalid. It is moot under the release of 1.9.1 and rails 2.3.2.

    May 12th, 2009 @ 02:57 PM