avit / rspec-rails-caching

RSpec helpers for testing page and action caching in Rails
MIT License
12 stars 7 forks source link

uninitialized constant RSpec::Rails::ControllerExampleGroup #1

Closed kueda closed 11 years ago

kueda commented 11 years ago

Just gave this a try but hit this error message (just the top of the trace):

/Users/kueda/.rvm/gems/ruby-1.9.3-p286/gems/rspec-rails-caching-0.2.1/lib/rspec-rails-caching.rb:18:in `block in <module:RSpecRailsCaching>': uninitialized constant RSpec::Rails::ControllerExampleGroup (NameError)
    from /Users/kueda/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.12.2/lib/rspec/core.rb:108:in `configure'
    from /Users/kueda/.rvm/gems/ruby-1.9.3-p286/gems/rspec-rails-caching-0.2.1/lib/rspec-rails-caching.rb:8:in `<module:RSpecRailsCaching>'
    from /Users/kueda/.rvm/gems/ruby-1.9.3-p286/gems/rspec-rails-caching-0.2.1/lib/rspec-rails-caching.rb:6:in `<top (required)>'
    from /Users/kueda/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'

This happens when my spec_helper.rb gets loaded, before any of my tests actually get run. Any way to ensure RSpec::Rails::ControllerExampleGroup is loaded before this line gets run?

avit commented 11 years ago

Thanks for the report... I'm not sure but I'll try it myself on a clean project. Can you give some details for how you've set it up (gem versions, spec_helper file)?

For what it's worth, I have require: false in my Gemfile and load this in my spec_helper after rspec/rails. We could probably work around that.

kueda commented 11 years ago

rspec-core (2.12.2) rspec-rails (2.12.1)

Spec helper: https://github.com/inaturalist/inaturalist/blob/master/spec/spec_helper.rb

Hope that helps. Can you link to one of your spec helper files that's set up as you described?

avit commented 11 years ago

@kueda I just added "require rspec/rails" to my gem, since it sounds like it's getting loaded from your Gemfile before rspec/rails gets loaded in your spec_helper... Released as 0.2.2.

Do let me know if this doesn't fix it.

kueda commented 11 years ago

Cool, the gem is loading now, thanks. FYI, expire_fragment doesn't seem to be defined / aliased and expire raises NoMethodError: Abstract method 'cache_or_expire' to be defined in matcher but I guess those are separate issues.

avit commented 11 years ago

@kueda, open a new ticket for those and I'll have a look.