This project is archived and is in readonly mode.

#2060 ✓ committed
Ken Collins

Installation Of MiniUnit Causes Test To Fail

Reported by Ken Collins | February 24th, 2009 @ 05:29 PM | in 2.x

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.

Comments and changes to this ticket

  • Ken Collins

    Ken Collins February 24th, 2009 @ 06:17 PM

    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
    
  • James Mead

    James Mead March 4th, 2009 @ 07:17 PM

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

    Thanks, James.

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

  • Ken Collins

    Ken Collins March 10th, 2009 @ 08:19 PM

    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.

  • Ken Collins
  • Pratik

    Pratik March 10th, 2009 @ 08:38 PM

    • Assigned user set to “Jeremy Kemper”
  • Repository

    Repository March 10th, 2009 @ 09:24 PM

    • 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 state:committed]

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

  • August Lilleaas

    August Lilleaas March 16th, 2009 @ 01:14 PM

    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".

  • Ken Collins

    Ken Collins May 12th, 2009 @ 02:57 PM

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

Attachments

Referenced by

Pages