problem with FlexMock::TestCase#flexstub in 0.4.0

J

John Wilger

Jim,

I'm really glad to see the stubbing capabilities added to FlexMock.
However, I'm having a problem with the flexstub method.

I have several domain classes (ActiveRecord) in my application, and I
am working on functionality that will import data into the application
from a de-normalized tab-separated file we get from our customer on an
ongoing basis. Each line in the file represents a Product, so the code
calls Product.import( data_hash_from_line ) for each line in the file.
Product.import then calls the import method on several related
classes, giving each one the responsibility for knowing how to handle
its portion of the data.

For the unit tests, I'm using FlexMock to stub out the calls to import
in the other classes. If I run a single test case using `ruby
test/unit/my_test_file.rb`, everything works as expected. However,
when I try to run the whole test suite using `rake` (this is a Rails
app, BTW), I start to see a lot of errors like this:

16) Error:
test_should_return_status_if_it_exists(StatusTest::Import):
NoMethodError: undefined method `import' for #<FlexMock:0x236a0e0>
/usr/local/lib/ruby/gems/1.8/gems/flexmock-0.4.0/lib/flexmock.rb:113:in
`method_missing'
/usr/local/lib/ruby/gems/1.8/gems/flexmock-0.4.0/lib/flexmock.rb:228:in
`mock_wrap'
/usr/local/lib/ruby/gems/1.8/gems/flexmock-0.4.0/lib/flexmock.rb:108:in
`method_missing'
(eval):3:in `import'
(eval):5:in `import'
/Users/jwilger/projects/application/test/test_helper.rb:70:in `import'
./test/unit/status_test.rb:55:in `test_should_return_status_if_it_exists'

It looks like the FlexMock::TestCase#flexmock_teardown method is
removing the stub for Status.import, but it isn't restoring the
original method.

--
Regards,
John Wilger
http://johnwilger.com

-----------
Alice came to a fork in the road. "Which road do I take?" she asked.
"Where do you want to go?" responded the Cheshire cat.
"I don't know," Alice answered.
"Then," said the cat, "it doesn't matter."
- Lewis Carrol, Alice in Wonderland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top