Rake spec failure in beta.13

I just upgraded to beta.13 and I’m running into an issue where when I
run ‘rake spec’, I get an ‘uninitialized constant Comment’ error.
Comment is the first model (alphabetically) in my project. If I
switch back to beta.12, it works. If I use ‘spec .’ and not ‘rake
spec’, it also works.

Environment: Rails master, Mongoid master.

On Jun 24, 2010, at 1:23 PM, geetarista wrote:

I just upgraded to beta.13 and I’m running into an issue where when I
run ‘rake spec’, I get an ‘uninitialized constant Comment’ error.
Comment is the first model (alphabetically) in my project. If I
switch back to beta.12, it works. If I use ‘spec .’ and not ‘rake
spec’, it also works.

Environment: Rails master, Mongoid master.

Did you run ‘bundle update’?

I did both ‘bundle install’ and ‘bundle update’.

On Jun 24, 2010, at 2:24 PM, geetarista wrote:

Did you run ‘bundle update’?
I did both ‘bundle install’ and ‘bundle update’.

Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with
rails-3.0.0.beta4.

HTH,
David

On Thu, Jun 24, 2010 at 10:12 PM, geetarista [email protected]
wrote:

switch back to beta.12, it works. If I use ‘spec .’ and not ‘rake
spec’, it also works.

Environment: Rails master, Mongoid master.

Did you run ‘bundle update’?
I did both ‘bundle install’ and ‘bundle update’.

Did you upgrade rails as well? rspec-rails-2.0.0.beta.13 only works with rails-3.0.0.beta4.

I’m using Rails master.

I’m at a loss. Please run “rake spec --trace” and post the full
backtrace.

I’m using Rails master.

Here’s the backtrace and the spec file: http://gist.github.com/452355

Also, if I delete that spec file, it just goes to the next
alphabetical file and gives the same error for that model name.

http://gist.github.com/452385

(It’s the default generated from rails g rspec:install).

I’m not sure what else it could be. I literally change my Gemfile
from beta.12 (where specs work) to beta.13 run ‘bundle install/update’
and it then fails.

On Jun 24, 2010, at 11:05 PM, geetarista wrote:

http://gist.github.com/452385

(It’s the default generated from rails g rspec:install).

I’m not sure what else it could be. I literally change my Gemfile
from beta.12 (where specs work) to beta.13 run ‘bundle install/update’
and it then fails.

I seriously doubt this will fix the problem, but try changing Rspec to
RSpec on line 11.

That did not fix it.

On Jun 24, 2010, at 10:36 PM, geetarista wrote:

run ‘rake spec’, I get an ‘uninitialized constant Comment’ error.

I’m using Rails master.

I’m at a loss. Please run “rake spec --trace” and post the full backtrace.
Here’s the backtrace and the spec file: http://gist.github.com/452355

Also, if I delete that spec file, it just goes to the next
alphabetical file and gives the same error for that model name.

What’s in spec_helper.rb? The backtace makes It look as though the rails
framework is not loaded.

El 25/06/2010, a las 15:38, geetarista
escribió:

That did not fix it.

What have you got in your Gemfile?

Cheers,
Wincent

Gemfile: http://gist.github.com/453032

El 25/06/2010, a las 17:44, geetarista
escribió:

Gemfile: http://gist.github.com/453032

On Jun 25, 7:41 am, Wincent C. [email protected] wrote:

El 25/06/2010, a las 15:38, geetarista escribió:

That did not fix it.

What have you got in your Gemfile?

(Aside: please don’t top-post; it makes your replies cumbersome to
read.)

Was kind of hoping I’d see something glaringly weird in your Gemfile,
but nothing leaps out at me.

Why do you have the “:require => nil” for RSpec in your test
environment? AFAIK this won’t explain the failure you’re seeing, but I
still wonder why you’re doing it.

On a tangent, you’re 10 releases of Haml behind, and a lot of Rails 3
fixes have been made since 3.0.3.

Cheers,
Wincent

Sorry about that. For some reason I thought Google Reader stripped
that automatically.

I added “:require => nil” because I had read somewhere that it was
good to do so. Can’t remember why or where. Taking it out does not
fix the failure.

I just haven’t upgraded Haml because it’s not top priority and I
haven’t run into any issues yet.

On Jun 25, 2010, at 4:51 PM, geetarista wrote:

Sorry about that. For some reason I thought Google Reader stripped
that automatically.

I added “:require => nil” because I had read somewhere that it was
good to do so. Can’t remember why or where. Taking it out does not
fix the failure.

I just haven’t upgraded Haml because it’s not top priority and I
haven’t run into any issues yet.

I figured out the problem. It boils down to these two lines in
spec/spec_helper.rb

ENV[“RAILS_ENV”] ||= ‘test’
require File.dirname(FILE) + “/…/config/environment” unless
defined?(Rails)

I’m changing those to this for the next release:

ENV[‘RAILS_ENV’] = ENV[‘RSPEC_RAILS_ENV’] || ‘test’
require File.expand_path("…/…/config/environment", FILE)

Do that in your spec_helper now and it should work correctly. Please
confirm.

Thx,
David

On Jun 25, 2010, at 4:51 PM, geetarista wrote:

Sorry about that. For some reason I thought Google Reader stripped
that automatically.

I added “:require => nil” because I had read somewhere that it was
good to do so. Can’t remember why or where. Taking it out does not
fix the failure.

I just haven’t upgraded Haml because it’s not top priority and I
haven’t run into any issues yet.

I’ve been able to reproduce the issue, and should have a fix in place
soon.

Assuming I’ve got the fix, I’ll explain what happened once it’s pushed
to github.

Cheers,
David

On Jun 26, 2010, at 12:13 PM, David C. wrote:

haven’t run into any issues yet.

I’ve been able to reproduce the issue, and should have a fix in place soon.

Assuming I’ve got the fix, I’ll explain what happened once it’s pushed to github.

What I believe to be the fix is now up in github. Geetarista, would you
do me a favor and update your gemfile to point to the git repos:

gem “rspec-rails”, :git => “git://github.com/rspec/rspec-rails.git”
gem “rspec-core”, :git => “git://github.com/rspec/rspec-core.git”
gem “rspec-expectations”, :git =>
“git://github.com/rspec/rspec-expectations.git”
gem “rspec-mocks”, :git => “git://github.com/rspec/rspec-mocks.git”
gem “rspec”, :git => “git://github.com/rspec/rspec.git”

Need to get all of them from git for this to work (just temporary until
I get a release out).

Then ‘bundle install’ and ‘rake spec’ and let me know if all is well.

Thanks,
David

That fixed it. Thanks so much, David!

Thank you all for this discussion and the fix

I ran into the same issue this morning, but with “Factory” being the
class that was undefined (using Factory Girl)

The fix explained in this discussion worked for me.
As a reminder for others :

1 - update spec_helper
require File.expand_path("…/…/config/environment", FILE)
instead of
require File.dirname(FILE) + “/…/config/environment” unless
defined?(Rails)

2 - update gemfile
gem ‘rspec-rails’, “2.0.0.beta.14.1”

3 - bundle install or bundle update (depending on your version of
bundler)