Search code examples
ruby-on-railscucumberbdd

Cucumber can't find steps when running a single feature


I've just installed cucumber into a new rails project (first time setting it up from scratch) and it works wonderfully when running all tests (bundle exec cucumber) but can't find any of my steps when I run a single feature file. How might I start to debug this?

rails (3.2.13)
cucumber-rails (1.3.1)
cucumber (>= 1.2.0)

# file listing
features/
├── campaigns
│   ├── donating_campaigns.feature
│   └── viewing_campaigns.feature
├── step_definitions
│   └── campaign_steps.rb
└── support
    └── env.rb

Solution

  • It will only find files at the same level or lower in the features directory tree. So if you try to run just the scenarios in features/campaigns/donating_campaigns.feature it cannot find the step_definitions directory.

    You can use the --require flag to explicitly tell cucumber what to include before it runs your feature. For example:

    bundle exec cucumber --require features/step_definitions features/campaigns/donating_campaigns.feature