[Ruby] conflict between rails and flexmock?

Pete Higgins pete at melodeo.com
Fri Jun 6 15:14:24 PDT 2008


I've noticed that using flexmock in my rails tests with Test::Unit causes
the teardown method in the testcase to not run. This is with rails 2.0.2 and
flexmock 0.8.2. Has anyone run into this before?

Here's a bare-bones example:

require File.join( File.dirname(__FILE__), '..', 'test_helper' )
require 'test/unit'
require 'flexmock/test_unit'

class TestTest < Test::Unit::TestCase
  def setup
    $stderr.puts "inside setup"
  end

  def teardown
    $stderr.puts "inside teardown"
  end

  def test_nothing
    $stderr.puts "inside test"
    assert true
  end
end

Running this gives me:

Loaded suite test/unit/test_test
Started
inside setup
inside test
.
Finished in 0.086216 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

Commenting either the first or third lines of the test case gives me the
expected output:

Loaded suite test/unit/test_test
Started
inside setup
inside test
inside teardown
.
Finished in 0.001005 seconds.

1 tests, 1 assertions, 0 failures, 0 errors

pete



More information about the Ruby mailing list