Forum: RSpec cucumber question - uninitialized constant creating object in model

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2008-11-24 16:43
(Received via mailing list)
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
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-11-24 16:59
(Received via mailing list)
On Sun, Nov 23, 2008 at 11:50 AM, Tim Walker <walketim@gmail.com> wrote:
>
> 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.

Have you read and followed
http://github.com/aslakhellesoy/cucumber/wikis/ruby-on-rails?
F68f69615423aa3851bd445409754dbf?d=identicon&s=25 Joseph Wilk (joesniff)
on 2008-11-24 17:01
(Received via mailing list)
Tim Walker wrote:
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@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
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 aslak hellesoy (Guest)
on 2008-11-24 17:11
(Received via mailing list)
On Sun, Nov 23, 2008 at 6:50 PM, Tim Walker <walketim@gmail.com> wrote:

>
> 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.
>

What version/revision of cucumber?
What's in your features directory?
What's the contents of your env.rb file?
What's the full stack trace?

Aslak
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2008-11-25 15:14
(Received via mailing list)
Thanks very much for this information guys. I got side-tracked with a
dev issue and hope to have time to work on this this morning. No doubt
my env.rb is jacked. What part of the install creates that?  I see it
in the downloaded project but not in my development project after
installing cucumber. Should this like in config and is it specific to
cucumber? Many thanks again as I get up to speed.

Also, any chance to be a Beta read of the RSpec book?

Sincerely,

Tim
On Mon, Nov 24, 2008 at 8:50 AM, aslak hellesoy
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2008-11-25 15:16
(Received via mailing list)
Typo in last is confusing '

"Should this LIKE in config"

should be...

 "Should this LIVE in config".

T
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-11-25 15:52
(Received via mailing list)
On Tue, Nov 25, 2008 at 8:13 AM, Tim Walker <walketim@gmail.com> wrote:
> Thanks very much for this information guys. I got side-tracked with a
> dev issue and hope to have time to work on this this morning. No doubt
> my env.rb is jacked. What part of the install creates that?  I see it
> in the downloaded project but not in my development project after
> installing cucumber. Should this like in config and is it specific to
> cucumber? Many thanks again as I get up to speed.
>
> Also, any chance to be a Beta read of the RSpec book?

Coming in December.

http://www.pragprog.com/titles/achbd/the-rspec-book

Cheers,
David
3464536ce6396bacc132ad18d2c46489?d=identicon&s=25 Tim Walker (timw)
on 2008-11-25 17:37
(Received via mailing list)
Thank you. I have the env.rb loading the environment now and am making
progress.

Question:

In Cucumber when you're writing code to satisfy steps and accessing
the model objects directly, what support for asserts, responses, etc.
do people use. (the equivalent of ActionController::TestCase and
ActiveSupport::TestCase), Fixtures, etc.

Many thanks,

Tim
This topic is locked and can not be replied to.