Rails3 + Cucumber

114 views
Skip to first unread message

Brian McManus

unread,
Mar 17, 2010, 11:47:17 PM3/17/10
to Cukes
I'm trying to get Cucumber working in a new Rails 3 app but I'm
running into a problem with it not recognizing matchers like
#have_content in my step definitions. Here's a gist of the full thing

http://gist.github.com/336021

but the short version is:

undefined method `have_content' for #<Cucumber::Rails::World:
0x2365782> (NoMethodError)

I've tried have_css as well and get the same thing.

aslak hellesoy

unread,
Mar 18, 2010, 2:41:51 AM3/18/10
to cu...@googlegroups.com
On Thu, Mar 18, 2010 at 4:47 AM, Brian McManus <bdm...@gmail.com> wrote:
I'm trying to get Cucumber working in a new Rails 3 app but I'm
running into a problem with it not recognizing matchers like
#have_content in my step definitions.  Here's a gist of the full thing

http://gist.github.com/336021


Looks like you didn't use --rspec when you set up cucumber i your app. That means you'll have Test::Unit instead.
You're trying to use RSpec APIs (have_content).

Aslak
 
but the short version is:

undefined method `have_content' for #<Cucumber::Rails::World:
0x2365782> (NoMethodError)

I've tried have_css as well and get the same thing.

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.


Brian McManus

unread,
Mar 18, 2010, 2:56:48 AM3/18/10
to Cukes
Thanks Aslak! Figured it was something dumb, must have missed that in
the readme here: http://github.com/aslakhellesoy/cucumber-rails/blob/master/README.rdoc

Re-ran `rails generate cucumber:skeleton --rspec` and now things are
good to go.

~Brian

On Mar 18, 1:41 am, aslak hellesoy <aslak.helle...@gmail.com> wrote:


> On Thu, Mar 18, 2010 at 4:47 AM, Brian McManus <bdma...@gmail.com> wrote:
> > I'm trying to get Cucumber working in a new Rails 3 app but I'm
> > running into a problem with it not recognizing matchers like
> > #have_content in my step definitions.  Here's a gist of the full thing
>
> >http://gist.github.com/336021
>
> Looks like you didn't use --rspec when you set up cucumber i your app. That
> means you'll have Test::Unit instead.
> You're trying to use RSpec APIs (have_content).
>
> Aslak
>
> > but the short version is:
>
> > undefined method `have_content' for #<Cucumber::Rails::World:
> > 0x2365782> (NoMethodError)
>
> > I've tried have_css as well and get the same thing.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Cukes" group.
> > To post to this group, send email to cu...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > cukes+un...@googlegroups.com <cukes%2Bunsu...@googlegroups.com>.

Brian McManus

unread,
Mar 18, 2010, 3:09:09 AM3/18/10
to Cukes
I just updated the README to mention that --rspec flag in the hopes
that it can save some other fool my confusion. Pull request sent.

~Brian

rjunee

unread,
Mar 18, 2010, 4:58:22 AM3/18/10
to Cukes
I'm having a similar issue, although it is the visit matcher that's
failing (which seemed to work for OP)

I have rails 3, cucumber 0.6.3, cucumber-rails 0.3.0. I used the --
rspec flag when setting up cucumber in my app. I get the error:

undefined method `visit' for #<Cucumber::Rails::World:0x86fb56c4>
(NoMethodError)
./features/step_definitions/web_steps.rb:19:in `/^(?:|I )go to (.
+)$/'
features/request_membership.feature:9:in `When I go to the
landing page'

My world:
Cucumber::Rails::World
NavigationHelpers
Cucumber::Web::Tableish
Cucumber::RbSupport::RbWorld
Rspec::Rails::Matchers
Rspec::Matchers
ActionDispatch::Integration::Runner
ActiveRecord::TestFixtures
ActiveSupport::Testing::Pending
ActiveSupport::Testing::Deprecation
ActiveSupport::Testing::Assertions
ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit
ActiveSupport::Callbacks
ActiveSupport::Testing::SetupAndTeardown
ActiveSupport::Testing::Default
Test::Unit::Util::BacktraceFilter
Test::Unit::Assertions
Test::Unit::Priority
Test::Unit::NotificationHandler
Test::Unit::TestCaseNotificationSupport
Test::Unit::OmissionHandler
Test::Unit::TestCaseOmissionSupport
Test::Unit::PendingHandler
Test::Unit::TestCasePendingSupport
Test::Unit::FailureHandler
Test::Unit::ErrorHandler
Test::Unit::ExceptionHandler
Test::Unit::Fixture
Test::Unit::Attribute
Rspec::Core::SharedExampleGroup
Rspec::Core::KernelExtensions
JSON::Ext::Generator::GeneratorMethods::Object
ActiveSupport::Dependencies::Loadable
Arel::Sql::ObjectExtensions
Arel::ObjectExtensions
Kernel


Any ideas?

Ryan

Joaquin Rivera Padron

unread,
Mar 18, 2010, 5:42:43 AM3/18/10
to cu...@googlegroups.com
hi
visit is a webrat method, do you have it installed?

joaquin
2010/3/18 rjunee <ry...@junee.org>
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/cukes?hl=en.




--
www.least-significant-bit.com

aslak hellesoy

unread,
Mar 18, 2010, 5:43:21 AM3/18/10
to cu...@googlegroups.com

There should be Capybara or Webrat mixed into your world. Try generating your cucumber skeleton again with --capybara (or webrat if you wish to use that).
You'll also have to update your Gemfile.
 
Any ideas?

Ryan
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.

rjunee

unread,
Mar 18, 2010, 6:21:30 PM3/18/10
to Cukes
I regenerated with --capybara and it works. Thanks!

On Mar 18, 2:43 am, aslak hellesoy <aslak.helle...@gmail.com> wrote:

> > cukes%2Bunsu...@googlegroups.com<cukes%252Buns...@googlegroups.com >

Jonathan Linowes

unread,
Mar 26, 2010, 4:17:32 PM3/26/10
to cu...@googlegroups.com
hi,

I have a simple Rails 3 app running with Mongodb (using mongoid), one model, one controller. I can run rspecs fine.

I created the app using something like
$ rails appname --skip-prototype --skip-activerecord

When I run rake cucumber, I get
Don't know how to build task 'db:test:prepare'

and rake -T says there are no db: tasks

and running

$ cucumber
Using the default profile...
uninitialized constant ActionDispatch::Integration::Session::Test (NameError)
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:116:in `const_missing'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/actionpack-3.0.0.beta/lib/action_dispatch/testing/integration.rb:127
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:169:in `require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:169:in `require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-rails-0.3.0/lib/cucumber/rails/world.rb:22
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:169:in `require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:169:in `require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-rails-0.3.0/lib/cucumber/rails/rspec.rb:1
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:169:in `require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:169:in `require'
/Users/jonathan/rails/rr3/features/support/env.rb:11
/Users/jonathan/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Users/jonathan/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `polyglot_original_require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/rb_support/rb_language.rb:124:in `load_code_file'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:85:in `load_code_file'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:77:in `load_code_files'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:76:in `each'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/step_mother.rb:76:in `load_code_files'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/cli/main.rb:48:in `execute!'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/../lib/cucumber/cli/main.rb:20:in `execute'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/cucumber-0.6.3/bin/cucumber:8
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/bin/cucumber:19:in `load'
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/bin/cucumber:19


I dont know if these are 2 separate problems, and what to do for them. Thanks.

Here's my gems

$ bundle show
Gems included by the bundle:
* abstract (1.0.0)
* actionmailer (3.0.0.beta)
* actionpack (3.0.0.beta)
* activemodel (3.0.0.beta)
* activerecord (3.0.0.beta)
* activeresource (3.0.0.beta)
* activesupport (3.0.0.beta)
* arel (0.2.1)
* builder (2.1.2)
* bundler (0.9.13)
* capybara (0.3.6)
* columnize (0.3.1)
* compass (0.10.0.rc1)
* compass-colors (0.3.1)
* cucumber (0.6.3)
* cucumber-rails (0.3.0)
* culerity (0.2.9)
* database_cleaner (0.5.0)
* diff-lcs (1.1.2)
* erubis (2.6.5)
* fancy-buttons (0.4.1)
* ffi (0.6.3)
* haml (2.2.22)
* has_scope (0.4.2)
* i18n (0.3.6)
* inherited_resources (1.1.0)
* json_pure (1.2.3)
* linecache (0.43)
* mail (2.1.3)
* memcache-client (1.7.8)
* mime-types (1.16)
* mongo (0.19.1)
* mongo_ext (0.19.1)
* mongoid (2.0.0.beta1)
* mustache (0.7.0)
* nifty-generators (0.3.1)
* nokogiri (1.4.1)
* polyglot (0.3.0)
* rack (1.1.0)
* rack-mount (0.4.7)
* rack-test (0.5.3)
* rails (3.0.0.beta)
* railties (3.0.0.beta)
* rake (0.8.7)
* responders (0.5.5)
* rspec (2.0.0.beta.4)
* rspec-core (2.0.0.beta.4)
* rspec-expectations (2.0.0.beta.4)
* rspec-mocks (2.0.0.beta.4)
* rspec-rails (2.0.0.beta.4)
* ruby-debug (0.10.3)
* ruby-debug-base (0.10.3)
* selenium-webdriver (0.0.17)
* term-ansicolor (1.0.5)
* text-format (1.0.0)
* text-hyphen (1.0.0)
* thor (0.13.4)
* treetop (1.4.4)
* tzinfo (0.3.17)
* webrat (0.7.0)
* will_paginate (3.0.pre)


aslak hellesoy

unread,
Mar 26, 2010, 4:31:49 PM3/26/10
to cu...@googlegroups.com
On Fri, Mar 26, 2010 at 9:17 PM, Jonathan Linowes <lin...@gmail.com> wrote:
hi,

I have a simple Rails 3 app running with Mongodb (using mongoid), one model, one controller. I can run rspecs fine.

I created the app using something like
 $ rails appname --skip-prototype --skip-activerecord

When I run rake cucumber, I get
 Don't know how to build task 'db:test:prepare'

and rake -T says there are no db: tasks


Can you please create an issue in cucumber-rails' github issue tracker? We need better handling of AR-less projects in the generated Rake tasks.
 
and running

$ cucumber
Using the default profile...
uninitialized constant ActionDispatch::Integration::Session::Test (NameError)
--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cu...@googlegroups.com.
To unsubscribe from this group, send email to cukes+un...@googlegroups.com.

Jonathan Linowes

unread,
Mar 26, 2010, 8:46:45 PM3/26/10
to cu...@googlegroups.com
On Mar 26, 2010, at 4:31 PM, aslak hellesoy wrote:



On Fri, Mar 26, 2010 at 9:17 PM, Jonathan Linowes <lin...@gmail.com> wrote:
hi,

I have a simple Rails 3 app running with Mongodb (using mongoid), one model, one controller. I can run rspecs fine.

I created the app using something like
 $ rails appname --skip-prototype --skip-activerecord

When I run rake cucumber, I get
 Don't know how to build task 'db:test:prepare'

and rake -T says there are no db: tasks


Can you please create an issue in cucumber-rails' github issue tracker? We need better handling of AR-less projects in the generated Rake tasks.

Done.

 
and running

$ cucumber
Using the default profile...
uninitialized constant ActionDispatch::Integration::Session::Test (NameError)

Thanks.
Now I get

undefined method `use_transactional_fixtures='

I comment the line out of env.rb, then I get

undefined method `subclasses' for Rails::Generators:Module (NoMethodError)
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/railties-3.0.0.beta/lib/rails/generators/base.rb:214:in `inherited'

??

-- jonathan linowes
    parkerhill technology group llc
    office: 603-838-2884

    killer app: http://reviewramp.com
    tech blog: http://vaporbase.com
    personal blog: http://jon.linow.es
    twitter: @linojon



Jonathan Linowes

unread,
Mar 26, 2010, 8:55:59 PM3/26/10
to cu...@googlegroups.com
On Mar 26, 2010, at 8:46 PM, Jonathan Linowes wrote:


On Mar 26, 2010, at 4:31 PM, aslak hellesoy wrote:



On Fri, Mar 26, 2010 at 9:17 PM, Jonathan Linowes <lin...@gmail.com> wrote:
hi,

I have a simple Rails 3 app running with Mongodb (using mongoid), one model, one controller. I can run rspecs fine.

I created the app using something like
 $ rails appname --skip-prototype --skip-activerecord

When I run rake cucumber, I get
 Don't know how to build task 'db:test:prepare'

and rake -T says there are no db: tasks


Can you please create an issue in cucumber-rails' github issue tracker? We need better handling of AR-less projects in the generated Rake tasks.

Done.

 
and running

$ cucumber
Using the default profile...
uninitialized constant ActionDispatch::Integration::Session::Test (NameError)

Thanks.
Now I get

undefined method `use_transactional_fixtures='

I comment the line out of env.rb, then I get

undefined method `subclasses' for Rails::Generators:Module (NoMethodError)
/Users/jonathan/.rvm/gems/ruby-1.8.7-p249/gems/railties-3.0.0.beta/lib/rails/generators/base.rb:214:in `inherited'

??

Nevermind. Sort of.

It runs when I do 
  $ cucumber

but not when i use a 'cuke' alias I had setup for my rails 2.3.5 project
  alias cuke='cucumber --require features --require features/support --require lib --guess'

I guess that's unnecessary now?


Reply all
Reply to author
Forward
0 new messages