3
votes

I have a small test project that I'm using to test the waters for a much larger project. I am using rspec on rails for testing, but recently looked into Cucumber. It looks very nice, but I'm wondering if there's a way for cucumber to run my spec tests, or for rspec (autospec) to run my cucumber features. I've looked around extensively, but have yet to find a solid conclusion.

Thanks,

Mike

3

3 Answers

4
votes

I've been experimenting with Cucumber as well. It supports autotest:

AUTOFEATURE=true autospec

That runs both the rspec & cucumber test suite continuously.

3
votes

An easy way to do this would be to create a Rake task that invokes both tools, such as this minimal example:

desc 'Run rspec + cucumber'
task :build => [:spec, :features]

Then you can build both with:

rake build

Both RSpec and Cucumber come with some default tasks which work with Rails, but you can customize the tasks to suit your needs. There's more info on writing rake tasks here.

1
votes

Depends on what you are looking for, but the best way to run cucumber tests with rspec is to use turnip, which uses exactly the same feature syntax as cucumber (the syntax is called gherkin), but allows you to use most of the functionality of rspec. https://github.com/jnicklas/turnip.

If you want to take things one step further, you can run your features from inside rspec _spec.rb files using a gem we created called rutabaga. https://github.com/simplybusiness/rutabaga

In both cases, all the tests can be run by executing rspec or bundle exec rspec as needed.