Skip to content

Instantly share code, notes, and snippets.

@kristianmandrup
Created February 22, 2010 22:35
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 kristianmandrup/311597 to your computer and use it in GitHub Desktop.
Save kristianmandrup/311597 to your computer and use it in GitHub Desktop.
Create Rails 3 app
------------------------------
$ rails cucumber-rails3-demo
$ cd cucumber-rails3-demo
------------------------------
Use Rspec as testing framework
------------------------------
$ mate config/application.rb
---
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework :rspec, :fixture => true
end
---
------------------------------
$ mate Gemfile
---
source 'http://gemcutter.org'
gem "rails", :git => "git://github.com/rails/rails.git"
gem "database_cleaner", :git => "git://github.com/bmabey/database_cleaner.git"
gem "cucumber", :git => "git://github.com/aslakhellesoy/cucumber.git"
gem "cucumber-rails", "0.2.7", :git => "http://github.com/kristianmandrup/cucumber-rails.git"
gem "sqlite3-ruby", :require => "sqlite3"
group :test do
gem "test-unit"
gem "webrat"
gem "rspec-rails", ">= 2.0.0.a8"
end
---
------------------------------
Install gems
------------------------------
$ bundle install
------------------------------
Setup cucumber
------------------------------
$ rails g cucumber:skeleton
------------------------------
Scaffold Person
------------------------------
$ rails g scaffold Person name:string
$ rails g cucumber:feature Person name:string
------------------------------
Scaffold Post
------------------------------
$ rails g scaffold Post title:string
$ rails g cucumber:feature Post title:string
------------------------------
Configure database for use with tests
------------------------------
$ rake db:migrate
$ rake db:test:load
------------------------------
Run cucumber features!
------------------------------
$ cucumber features
------
RESULT
------
Feature: Manage people
In order to [goal]
[stakeholder]
wants [behaviour]
Scenario: Register new person # features/manage_people.feature:6
Given I am on the new person page # features/step_definitions/web_steps.rb:13
When I fill in "Name" with "name 1" # features/step_definitions/web_steps.rb:33
And I press "Create" # features/step_definitions/web_steps.rb:21
Then I should see "name 1" on the people page # features/step_definitions/web_steps.rb:150
Feature: Manage posts
In order to [goal]
[stakeholder]
wants [behaviour]
Scenario: Register new post # features/manage_posts.feature:6
Given I am on the new post page # features/step_definitions/web_steps.rb:13
When I fill in "Title" with "title 1" # features/step_definitions/web_steps.rb:33
And I press "Create" # features/step_definitions/web_steps.rb:21
Then I should see "title 1" on the posts page # features/step_definitions/web_steps.rb:150
2 scenarios (2 passed)
8 steps (8 passed)
0m0.305s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment