All my steps are skipped!

5,417 views
Skip to first unread message

jkp

unread,
Jun 14, 2010, 3:18:23 AM6/14/10
to Cukes
All

I'm new to Cucumber and BDD in general but am giving it a go on a new
rails 3 project I'm starting. I've read a few tutorials and watched
an introductory screencast or two so I feel fairly confident about
getting up and running but I'm hitting an issue almost straight away
that I cannot seem to solve.

In my project I started off by writing the following cucumber spec:

-------------------------------------------------------------------------------

Feature: Manage releases
In order to release new software
As a developer
I want to create and manage software releases

Scenario: List releases
Given I have releases named 1.0, 1.1
When I go to the list of software releases
Then I should see "1.0"
And I should see "1.1"

-------------------------------------------------------------------------------

After which I ran Cucumber and was given this output:

-------------------------------------------------------------------------------

KidA% cucumber
Using the default profile...
FU---F

Failing Scenarios:
cucumber features/manage_releases.feature:6 # Scenario: List releases

1 scenario (1 failed)
4 steps (3 skipped, 1 undefined)
0m0.004s

You can implement step definitions for undefined steps with these
snippets:

Given /^I have releases named 1\.0, 1\.1$/ do
pending # express the regexp above with the code you wish you had
end

-------------------------------------------------------------------------------

So now I define the missing step as follows:

-------------------------------------------------------------------------------


Given /^I have releases named (.+)$/ do |names|
names.split(', ').each do |name|
Release.create!(:name => name)
end
end

-------------------------------------------------------------------------------

...and rerun cucumber only to get the following output:

-------------------------------------------------------------------------------

F----F

Failing Scenarios:
cucumber features/manage_releases.feature:6 # Scenario: List releases

1 scenario (1 failed)
4 steps (4 skipped)
0m0.004s

-------------------------------------------------------------------------------

So, Cucumber resolves the missing step now but for some reason it
doesn't want to run any of them. I can't for the life of me figure
out what I'm doing wrong. I would have expected it to try to run the
first step but to tell me that "Release" was an undefined constant.
Can someone point out if I'm doing something incorrect?

I'm using Cucumber 0.8 on rails 3 beta 3.

Thanks in advance.



Ants Pants

unread,
Jun 14, 2010, 5:07:43 AM6/14/10
to cu...@googlegroups.com
I'm also new to this but will try and help.

The given you whacked in your step file, is it still pending or have you put some code in there.

At the moment, when a step is provided by Cukes, I put it in a step file as is and expect to see the pending. That way I know it's being found.




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


Jamie Kirkpatrick

unread,
Jun 14, 2010, 5:13:36 AM6/14/10
to cu...@googlegroups.com
The step I pasted is in a step file and gets resolved but it doesnt seem to be run at all.  I go from having 1 undefined step and 3 skipped steps to 4 skipped steps.  I don't get any advice about why it was skipped from Cucumber.

-- 
Jamie Kirkpatrick
07818 422311

Matt Wynne

unread,
Jun 14, 2010, 5:26:35 AM6/14/10
to cu...@googlegroups.com
On 14 Jun 2010, at 10:13, Jamie Kirkpatrick wrote:

The step I pasted is in a step file and gets resolved but it doesnt seem to be run at all.  I go from having 1 undefined step and 3 skipped steps to 4 skipped steps.  I don't get any advice about why it was skipped from Cucumber.

This looks to me like it's just a bug in the summary description. Try using the 'pretty' formatter, which should show you more about what's going on:

    cucumber -f pretty

Jamie Kirkpatrick

unread,
Jun 14, 2010, 5:29:35 AM6/14/10
to cu...@googlegroups.com
Hi Matt

The output I get in this case is as follows:

KidA%     cucumber -f pretty
Using the default profile...
Feature: Manage releases
  In order to release new software
  As a developer
  I want to create and manage software releases

  Scenario: List releases                      # features/manage_releases.feature:6
  undefined method `use_transactional_fixtures' for Cucumber::Rails::World:Class (NoMethodError)
  /Users/jkp/Development/KirkCode/website.git/RAILS_ENV=test/gems/cucumber-rails-0.3.1/lib/cucumber/rails/active_record.rb:3:in `Before'
  undefined method `use_transactional_fixtures=' for Cucumber::Rails::World:Class (NoMethodError)
  /Users/jkp/Development/KirkCode/website.git/RAILS_ENV=test/gems/cucumber-rails-0.3.1/lib/cucumber/rails/active_record.rb:7:in `Before'
  undefined method `use_transactional_fixtures' for Cucumber::Rails::World:Class (NoMethodError)
  /Users/jkp/Development/KirkCode/website.git/RAILS_ENV=test/gems/cucumber-rails-0.3.1/lib/cucumber/rails/active_record.rb:15:in `Before'
    Given I have releases named 1.0, 1.1       # features/step_definitions/release_steps.rb:1
    When I go to the list of software releases # features/step_definitions/web_steps.rb:23
    Then I should see "1.0"                    # features/step_definitions/web_steps.rb:107
    And I should see "1.1"                     # features/step_definitions/web_steps.rb:107
      undefined method `use_transactional_fixtures' for Cucumber::Rails::World:Class (NoMethodError)
      /Users/jkp/Development/KirkCode/website.git/RAILS_ENV=test/gems/cucumber-rails-0.3.1/lib/cucumber/rails/active_record.rb:24:in `After'

Failing Scenarios:
cucumber features/manage_releases.feature:6 # Scenario: List releases

1 scenario (1 failed)
4 steps (4 skipped)
0m0.005s


Any clues in that?

-- 
Jamie Kirkpatrick
07818 422311

Matt Wynne

unread,
Jun 14, 2010, 5:44:44 AM6/14/10
to cu...@googlegroups.com
Indeed there are. It hasn't even got as far as running the first step (see how the exception is printed after the Scenario and before the Given?). In trying to prepare to run the first step it's fallen over trying to call some internal gubbins that makes sure the scenario runs inside a database transaction. So actually the summary (1 scenario failed, 4 steps skipped) was entirely accurate.

This is pretty weird. What versions of everything (ruby, rails, cucumber, cucumber-rails) are you on? and did you use the rails generator (script/generate cucumber) to create your features folder?

Jamie Kirkpatrick

unread,
Jun 14, 2010, 6:54:11 AM6/14/10
to cu...@googlegroups.com
Hi Matt

Well, first up I should say that I'm pretty new to rails, I'm a big Python man so it's not all unfamiliar territory but I'm only just trying out my first projects on the dark side ;)

Sencond I should say that I'm using a fairly non-standard setup in that I'm not using ActiveRecord, but rather MongoID to map to a Mongo DB backend.

In my rails env.rb I had to comment out this line to make things run at all, and it seems to have something more to do with why things are failing:

# Cucumber::Rails::World.use_transactional_fixtures = true

In terms of the versions of things I'm using they are as follows:

  gem 'rails', '3.0.0.beta3'
  gem 'mongoid', '2.0.0.beta6'
  gem 'cucumber-rails'
  gem 'cucumber', '0.7.2'
  gem 'rspec-rails', '2.0.0.beta.8'

I'm on Ruby 1.8.7 as shipped with OS X 10.6.

-- 
Jamie Kirkpatrick
07818 422311

Jamie Kirkpatrick

unread,
Jun 14, 2010, 6:58:09 AM6/14/10
to cu...@googlegroups.com
One thing that might be worth mentioning: it seems that perhaps cucumber / rails are not resolving the fact that I'm not using ActiveRecord at all: look at this line...

  undefined method `use_transactional_fixtures' for Cucumber::Rails::World:Class (NoMethodError)
  /Users/jkp/Development/KirkCode/website.git/RAILS_ENV=test/gems/cucumber-rails-0.3.1/lib/cucumber/rails/active_record.rb:15:in `Before'

Why is it using the active_record code?  My application.rb file looks like this:

require File.expand_path('../boot', __FILE__)

# Pick the frameworks you want:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require 'mongoid/railtie'


# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

module Kirkcode
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Add additional load paths for your own custom dirs
    # config.load_paths += %W( #{config.root}/extras )

    # Only load the plugins named here, in the order given (default is alphabetical).
    # :all can be used as a placeholder for all plugins not explicitly named
    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

    # Activate observers that should always be running
    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # Configure generators values. Many other options are available, be sure to check the documentation.
    # config.generators do |g|
    #   g.orm             :active_record
    #   g.template_engine :erb
    #   g.test_framework  :test_unit, :fixture => true
    # end
    
    config.generators do |g|
      g.orm             :mongoid
      g.test_framework  :rspec, :fixture => false
    end

    # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]
  end
end



-- 
Jamie Kirkpatrick
07818 422311

aslak hellesoy

unread,
Jun 14, 2010, 7:01:19 AM6/14/10
to cu...@googlegroups.com
On Mon, Jun 14, 2010 at 12:54 PM, Jamie Kirkpatrick
<j...@kirkconsulting.co.uk> wrote:
> Hi Matt
> Well, first up I should say that I'm pretty new to rails, I'm a big Python
> man so it's not all unfamiliar territory but I'm only just trying out my
> first projects on the dark side ;)
> Sencond I should say that I'm using a fairly non-standard setup in that I'm
> not using ActiveRecord, but rather MongoID to map to a Mongo DB backend.
> In my rails env.rb I had to comment out this line to make things run at all,
> and it seems to have something more to do with why things are failing:
> # Cucumber::Rails::World.use_transactional_fixtures = true
> In terms of the versions of things I'm using they are as follows:
>   gem 'rails', '3.0.0.beta3'
>   gem 'mongoid', '2.0.0.beta6'
>   gem 'cucumber-rails'

Make sure you have 'cucumber-rails', 0.3.2

>   gem 'cucumber', '0.7.2'

Make sure you have 'cucumber', 0.8.0 (The explicit dependency is
unnecessary, as cucumber-rails depends on it. I recommend you remove
it)

>   gem 'rspec-rails', '2.0.0.beta.8'

Should be 2.0.0.beta.11

> I'm on Ruby 1.8.7 as shipped with OS X 10.6.
>

Try to specify this in your Gemfile and run rails g cucumber:install again.

Matt Wynne

unread,
Jun 14, 2010, 7:03:55 AM6/14/10
to cu...@googlegroups.com
On 14 Jun 2010, at 11:54, Jamie Kirkpatrick wrote:

Hi Matt

Well, first up I should say that I'm pretty new to rails, I'm a big Python man so it's not all unfamiliar territory but I'm only just trying out my first projects on the dark side ;)

Then welcome!

Sencond I should say that I'm using a fairly non-standard setup in that I'm not using ActiveRecord, but rather MongoID to map to a Mongo DB backend.

OK well we'll try our best but since you're on territory I've not walked myself, you'll probably find I'm more giving you the tools to help figure it out for yourself than just giving you answers.

In my rails env.rb I had to comment out this line to make things run at all, and it seems to have something more to do with why things are failing:

# Cucumber::Rails::World.use_transactional_fixtures = true

So you see the line in the exception, quoting cucumber/rails/active_record.rb:3:in `Before' ?

That's your problem. That line is a Hook [1] supplied by cucumber-rails which is going to try and make sure the SQL database is clear before running the scenario. You probably don't even have AR loaded, so the hook is freaking out.

Have a root around in your features/support/env.rb file for a line like this:

    require 'cucumber/rails/active_record'

...and delete it.

If you're using Mongo you'll need to write your own hooks to reset the database contents after each scenario (you really don't want state leaking between scenarios). There was someone talking about this on the list a few weeks back I think but I don't remember any neat answers to that problem yet.

Jamie Kirkpatrick

unread,
Jun 14, 2010, 7:09:52 AM6/14/10
to cu...@googlegroups.com
W00t!

That did the trick...fantastic :)

So, yes, I've noticed that things don't seem to be set up in an appropriate manner for auto-detection of my ORM to happen.  I actually had to manually tell cucumber to configure DatabaseCleaner to use mongoid in env.rb.  This seems wrong, it seems like it should be picked up because I have it set in application.rb right?  Does application.rb get read by cucumber at all or are they totally separate mechanisms?

I'll have a look at writing the correct hooks for mongoid if I can understand what is and isn't taken into account properly :)

Thanks again for the help...

-- 
Jamie Kirkpatrick
07818 422311

Matt Wynne

unread,
Jun 14, 2010, 7:19:07 AM6/14/10
to cu...@googlegroups.com
On 14 Jun 2010, at 12:09, Jamie Kirkpatrick wrote:

W00t!

That did the trick...fantastic :)

So, yes, I've noticed that things don't seem to be set up in an appropriate manner for auto-detection of my ORM to happen.  I actually had to manually tell cucumber to configure DatabaseCleaner to use mongoid in env.rb.  

Yeah we're on pretty new ground here, it's only recently that anyone other than early-adopters-who-don't-really-use-generators have started asking about how to use non-AR back-ends.

This seems wrong, it seems like it should be picked up because I have it set in application.rb right?  Does application.rb get read by cucumber at all or are they totally separate mechanisms?

I have no idea, though I'm sure it's possible. If it is, it'll be done by the cucumber-rails generator scripts. Have a look at those.

Jamie Kirkpatrick

unread,
Jun 14, 2010, 7:22:52 AM6/14/10
to cu...@googlegroups.com
Hey Matt

Thanks for the pointers.  I think for now I'll run with what I have and see how far I get...as you say I'm on pretty new ground but since I'm just picking this all up it didn't really seem worth learning rails 2 when 3 is just getting pushed out the door.  I'm deploying on Heroku and it supports rails 3 so it seemed like a good bet.  

Issues like these where the warts are exposed that are character building anyway! (they are usually a good way to learn how things fit together).

-- 
Jamie Kirkpatrick
07818 422311

aslak hellesoy

unread,
Jun 14, 2010, 9:09:33 AM6/14/10
to cu...@googlegroups.com
On Mon, Jun 14, 2010 at 1:22 PM, Jamie Kirkpatrick
<j...@kirkconsulting.co.uk> wrote:
> Hey Matt
> Thanks for the pointers.  I think for now I'll run with what I have and see
> how far I get...as you say I'm on pretty new ground but since I'm just
> picking this all up it didn't really seem worth learning rails 2 when 3 is
> just getting pushed out the door.  I'm deploying on Heroku and it supports
> rails 3 so it seemed like a good bet.
> Issues like these where the warts are exposed that are character building
> anyway! (they are usually a good way to learn how things fit together).
>

FYI: There is a ticket for this already:
http://github.com/aslakhellesoy/cucumber-rails/issues#issue/18

Aslak

Reply all
Reply to author
Forward
0 new messages