Skip to content

Instantly share code, notes, and snippets.

@chikamichi
Created March 10, 2010 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chikamichi/327345 to your computer and use it in GitHub Desktop.
Save chikamichi/327345 to your computer and use it in GitHub Desktop.
rails3 + cucumber ok
# features/authentication.feature
Feature: User authentication
To ensure the safety of the application
As a would-be player
I must register as a user
Scenario: Fail Login
Given I am not authenticated
When I go to the homepage
Then I should be redirect to the login form
# features/step_definitions/authentication_steps.rb
Given /^I am not authenticated$/ do
# do nothing
end
# When I go to the homepage is already defined within features/step_definitions/web_steps.rb
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta"
gem "sqlite3-ruby", :require => "sqlite3"
gem "test-unit"
gem "rspec-rails", ">= 2.0.0.beta.1"
gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
$ cucumber --backtrace
Using the default profile...
..U
1 scenario (1 undefined)
3 steps (1 undefined, 2 passed)
0m0.018s
You can implement step definitions for undefined steps with these snippets:
Then /^I should be redirect to the login form$/ do
pending # express the regexp above with the code you wish you had
end
rails3+cucumber+capybara:
1. create a new app.
rails test
cd test
2. edit Gemfile (see Gemfile).
bundle install
3. install/bootstrap rspec and cucumber:
rails g rspec:install
rails g cucumber:skeleton
4. add a new feature and its step definitions file (see authentication.feature and authentication_steps.rb)
5. run cucumber:
cucumber --backtrace
Notes:
- if one ever move feature/steps from a subdir to another or to the root features directory, it's messed up. My initial quickfix was to backup the files, get rid of all the cucumber/rspec files (steps/ and features/, but also the rake tasks, initializers, everything created during initial bootstrapping), issue export RAILS_ENV=test, bootstrap again, and get the files back in their proper location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment