[rspec-users] cucumber question - uninitialized constant creating object in model

Joseph Wilk josephwilk at joesniff.co.uk
Mon Nov 24 10:54:29 EST 2008


Tim Walker wrote:
> Sorry if this is a really basic question. Scanned the past several
> months archives, didn't see it.
>
> When I am running "cucumber features"
>
> I get the error:
>
>  "uninitialized constant Thing (NameError)"
>
> With step code being executed as...
>
> Given /^a thing consisting of "L1" $/ do
>    Thing.new
> end
>
> I understand that this probably a basic question but it's like
> cucumber isn't loading my rails environment.
>
> Many thanks in advance.
>
> T
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>   
Sounds like your env.rb file is either not being required or it does not 
contain the rails require.

If you have a env.rb check it requires rails
@@@
...
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + 
'/../../../config/environment')
...
@@@

Also make sure when you run the cucumber command that it either 
automatically (it will include siblings or below) or explicitly though a 
--require includes your env.rb

--
Joseph Wilk
http://blog.josephwilk.net




More information about the rspec-users mailing list