Textmate => pass, autotest => failing specs?

Hi all,
I hope I can get a quick pointer about the following problem:

I have a controller spec with 38 examples, all green if run from
within TextMate.

From the shell, however (through either rake or autotest) I get a
handful of pink errors.

For example, I get a few TypeErrors (“can’t convert Note into Array”)
that appear to be raised while my index action is paginating records,
but I am obviously NOT asking help on the specific issue.

Rather, I’d like to know in general how to address such a discrepancy
between environments in the outcome of my tests.

Thanks heaps!
Giuseppe

HI Giuseppe,

I had a similar situation, only reversed. All ran with autotest, but
failed in Textmate. I found the problem was in how I was including
some helper modules and correcting that solved the problem.

Hi Matt,

I had a similar situation, only reversed. All ran with autotest, but
failed in Textmate. I found the problem was in how I was including
some helper modules and correcting that solved the problem.

right, I’ve heard about that before, and I thought that my problem may
be similar in nature, but I am currently at a loss.

Thanks,
Giuseppe

Giuseppe B. wrote:

Thanks,
Giuseppe

Giuseppe,
autotest will run your tests in different order. It does this to catch
any dependencies your tests may have on each other in order to reveal
brittle tests.

For more info see:
http://blog.zenspider.com/archives/2008/01/zentest_390_now_with_more_evil.html

-Ben

catch any dependencies your tests may have on each other
in order to reveal brittle tests.

Following Ben’s hint, I took out examples from the controller spec until
I isolated the culprit.

Briefly, I am switching from RSpec’s built in mocking framework to Mocha
and fixture_scenarios when necessary. I had forgotten to modify one of
the examples, which still had this construct:

object.should_receive(:method).and_return(:a_mock)

instead of Mocha’s:

object.expects(:method).returns(:a_mock)

So I have empirically learned that enabling

config.mock_with :mocha

in /spec/spec_helper.rb and then mixing Mocha with RSpec’s own
mocking/stubbing messes things up in a nasty way, in the sense that
failures occur all over the place with error messages that did not help
me finding the bug.
And again, these errors were not raised by TextMate’s environment.
Tricky.

Thanks for the feedback!
Giuseppe

That’ll learn ya to use Mocha over rSpec :wink:

On Tue, Apr 15, 2008 at 2:27 PM, Giuseppe B. [email protected]
wrote:

object.should_receive(:method).and_return(:a_mock)
mocking/stubbing messes things up in a nasty way, in the sense that


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Bryan R.
http://www.bryanray.net

“Programming today is a race between software engineers striving to
build
bigger and better idiot-proof programs, and the Universe trying to
produce
bigger and better idiots. So far, the Universe is winning.”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs