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.
Tim W. (Guest)
on 2008-11-24 17: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
David C. (Guest)
on 2008-11-24 17:59
(Received via mailing list)
On Sun, Nov 23, 2008 at 11:50 AM, Tim W. <removed_email_address@domain.invalid> 
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?
Joseph W. (Guest)
on 2008-11-24 18:01
(Received via mailing list)
Tim W. wrote:
>
> _______________________________________________
> rspec-users mailing list
> removed_email_address@domain.invalid
> 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 W.
http://blog.josephwilk.net
aslak hellesoy (Guest)
on 2008-11-24 18:11
(Received via mailing list)
On Sun, Nov 23, 2008 at 6:50 PM, Tim W. <removed_email_address@domain.invalid> 
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
Tim W. (Guest)
on 2008-11-25 16: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
Tim W. (Guest)
on 2008-11-25 16:16
(Received via mailing list)
Typo in last is confusing '

"Should this LIKE in config"

should be...

 "Should this LIVE in config".

T
David C. (Guest)
on 2008-11-25 16:52
(Received via mailing list)
On Tue, Nov 25, 2008 at 8:13 AM, Tim W. <removed_email_address@domain.invalid> 
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
Tim W. (Guest)
on 2008-11-25 18: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.