Topic: flexmock gotcha - multiple class mocks per test suite

Hi,

I have a test suite that mocks a class method in multiple test methods using flexmock.  Unfortunately, class methods appear to have a mock-once-per-environment-load limitation.  Meaning, when I run a test in isolation it works, but when I run it as part of a suite of tests one of the tests with the mocked class method will fail.  Which test fails depends on alphabetical order within the tests file.

So at its base I have three tests, all mocking the same class method with different return values.  This happens to be a helper unit test.  I've stripped things down for readability.

def test_not_locked_should_be_false
  flexmock(Project, :accessible? => false)
  assert locked
end

def test_not_locked_should_be_true
  flexmock(Project, :accessible? => true)
  assert ! locked
  end


So in this case, when running all tests in the file, the second test executes last and fails.  Project.accessible? returns false due to the mock that was created in the first test, which executed prior.

Is there a way to reset mocking or force a mock of a mock?  Nothing stands out to me in the doc.

TIA