[rspec-users] [Rails] Stubbed static methods are bleeding over into other specs and making them fail

David Chelimsky dchelimsky at gmail.com
Sat Jul 24 02:36:28 EDT 2010

On Fri, Jul 23, 2010 at 7:29 PM, Patrick Gannon <patgannon at gmail.com> wrote:
>> I just got a chance to try this, and ran into more problems.  Prior to
>> trying this, we were running RSpec2 beta 13.  When I changed our Gemfile to
>> depend on 'edge' RSpec et al (as you suggested above), I get a very strange
>> error when I run rake (after doing a 'bundle install').  The same error
>> occurs after I tell it specifically to use beta 16 (rather than 'edge').  It
>> seems to somehow not be able to find the bundler gem when it runs the main
>> bundler script from within rake:
>> C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:779:in
>> `report_activate_error': Could not find RubyGem bundler (>= 0)
>> (Gem::LoadError)
>>         from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:214:in
>> `activate'
>>         from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
>>         from C:/Ruby187/bin/bundle:18
>> rake aborted!
>> bundle exec  C:/Ruby187/bin/ruby.exe  -Ilib -Ispec
>> "./spec/controllers/discrepancies_controller_spec.rb" (...spec names
>> omitted..) failed
>> When I downgrade back to beta 13, everything works again.  I can't seem to
>> figure out why it wouldn't be able to find the bundler gem (since obviously
>> bundler is installed), so I cannot say whether or not your fix for the
>> stubbing issue solved my problem.  The stack trace (resulting from running
>> rake with "--trace") and my current list of installed gems (via "bundle
>> list") is here: http://gist.github.com/470278 (sorry for the line breaks)
>> bundler-1.0.0.beta.4 should fix this. Please give it a shot.
> Ok, I upgraded to bundler 1.0 beta 9 and configured Gemfile to use edge
> RSpec et al (as recommended above).  After doing a 'bundle install', our
> tests failed (without trying to re-enable any of the mocking functionality
> originally mentioned).  It appears that now RSpec is trying to reference
> ActiveRecord, even though we're not using ActiveRecord.  (We specifically
> require each of the railties other than ActiveRecord in application.rb,
> rather than requiring rails/all.)  The error that rake produces is: Don't
> know how to build task 'db:test:prepare'.  I then went ahead and defined an
> empty rake task called db:test:prepare, and then got another error relating
> to ActiveRecord: uninitialized constant
> RSpec::Rails::FixtureSupport::ActiveRecord (NameError).  Stack trace is
> here: https://gist.github.com/acbaf0a384b301013140 (sorry for the formatting
> - copied/pasted from a DOS window).  I then tried to use RSpec 2.0 beta.16
> (rather than edge) and it skipped straight to the aforementioned error (even
> when db:test:prepare wasn't defined, it didn't complain about that).
> Thanks,
> Pat

OK - I believe I've fixed the ActiveRecord problem. Please try "bundle
install" again (make sure you get rspec-rails >=


More information about the rspec-users mailing list