Hi Jamie,
I realise this must be very frustrating, but is there a way you can
narrow this down a bit more for us?
I think it would really help if you could try changing just one thing
at a time e.g. can you run the original version of the project with
Ruby 1.8.7 and Rails 2.3.10, but do just the Mocha upgrade from 0.9.8
to 0.9.10? Could you then also try upgrading just Rails from 2.3.10 to
3, but not upgrading Ruby?
Can you tell us some more details e.g. the exact version of Rails, the
exact version of Ruby, what test frameworks (and what versions) you
are using, and how you are requiring them...?
Ideally can you also try and send us a simple failing test (e.g. in a
fresh Rails project) that would allow us to reproduce the problem
locally...?
I'm afraid I'm away from home at the moment visiting family, so I'm
only going to be in sporadic internet contact.
Regards, James.
----
http://jamesmead.org/
I think it would really help if you could try changing just one thing
at a time e.g. can you run the original version of the project with
Ruby 1.8.7 and Rails 2.3.10, but do just the Mocha upgrade from 0.9.8
to 0.9.10?
Could you then also try upgrading just Rails from 2.3.10 to
3, but not upgrading Ruby?
Can you tell us some more details e.g. the exact version of Rails, the
exact version of Ruby, what test frameworks (and what versions) you
are using, and how you are requiring them...?
Ideally can you also try and send us a simple failing test (e.g. in a
fresh Rails project) that would allow us to reproduce the problem
locally...?
Hi Jamie,
That's all really helpful.
Do any of the Mocha expectations (unsatisfied or satisfied) listed in
the test failure correspond to expectations set up in *other* tests
using e.g. the #stubs or #expects methods? I'm wondering whether some
Mocha state is leaking between tests - perhaps because Mocha's
teardown hook is not being correctly fired.
Also can you run the tests with the following environment set...
MOCHA_OPTIONS=debug
...and supply us with the test output (or at least the first few lines).
This will give us some clues as to whether the Test::Unit
monkey-patching is working as expected.
Thanks, James.
----
http://jamesmead.org/
One other thing - do any of these tests pass when run on their own?
i.e. do they only fail when running the tests with rake? Or do they
fail however you run them?
I've had a go at trying to reproduce [1] the problem you are seeing,
but with no luck so far.
I can successfully run functional tests using Mocha & fixtures with
Ruby 1.9.2-p0, Rails 3.0.3 & Mocha 0.9.10 in a fresh Rails project
generated using Rails 3.0.3. If you're upgrading a project from an
earlier version of Rails, I wonder whether some of the files generated
by the earlier version of Rails haven't been updated to be suitable
for the newer version of Rails.
I required Mocha, by adding this to my Gemfile :-
group :test do
gem 'mocha', '0.9.10', :require => false
end
And adding this to the bottom of my test_helper.rb :-
require 'mocha'
I used Bundler 1.0.7 for these tests. I also used SQLite - are you using MySQL?
I think it would be useful to see the setup code from your test just
to verify that it cannot be the culprit.
Regards, James.
----
[1] https://github.com/floehopper/foo
I'm glad you go this sorted out.
I've added a ticket [1] to try and make Mocha fail fast in this
scenario. I think I tried this once before, but I should have another
go or at least improve debugging and/or documentation.
Regards, James.
----
http://jamesmead.org/
[1] http://floehopper.lighthouseapp.com/projects/22289/tickets/79