Installation
$ gem install cucumber_scaffold
Usage
Install the support files (you should also do this when updating the gem):
$ rails generate cucumber_scaffold:install
Run the built-in Rails scaffold generator:
$ rails generate scaffold Post name:string body:text rating:integer published:boolean
Then run the cucumber_scaffold generator with the same parameters:
$ rails generate cucumber_scaffold:feature Post name:string body:text rating:integer published:boolean
Notes
-
By default the generated features are targeted at the Rails scaffold generator
-
Only tested with Rails 3 and Capybara (not webrat)
-
Only supports string, text, integer, decimal and boolean fields at present
-
References (belongs_to) are partly supported
Contributors
zuf[https://github.com/zuf]
Sample Output
# Generated by cucumber_scaffold - http://github.com/andyw8/cucumber_scaffold
Feature: Manage posts
In order to [goal]
[stakeholder]
wants [behaviour]
Scenario: List all posts
Given the following posts:
| name | body | rating | published |
| name 1 | body 1 | 11 | true |
| name 2 | body 2 | 12 | true |
| name 3 | body 3 | 13 | true |
When I go to the posts page
Then I should see the following posts:
| Name | Body | Rating | Published |
| name 1 | body 1 | 11 | true |
| name 2 | body 2 | 12 | true |
| name 3 | body 3 | 13 | true |
And the heading should be "Listing posts"
Scenario: View a post
Given the following posts:
| name | body | rating | published |
| name 1 | body 1 | 11 | true |
| name 2 | body 2 | 12 | true |
| name 3 | body 3 | 13 | true |
When I go to the posts page
And I click "Show" in the 2nd row
Then I should see the following post:
| Name: | name 2 |
| Body: | body 2 |
| Rating: | 12 |
| Published: | true |
When I follow "Back"
Then I should be on the posts page
Scenario: Edit a post
Given the following post:
| name | name 10 |
| body | body 10 |
| rating | 20 |
| published | true |
When I go to the page for that post
And I follow "Edit"
Then I should see the following form field values:
| Name | name 10 |
| Body | body 10 |
| Rating | 20 |
| Published | [x] |
Then the heading should be "Editing post"
When I follow "Show"
Then I should be on the page for that post
Scenario: Delete a post via the index page
Given the following posts:
| name | body | rating | published |
| name 1 | body 1 | 11 | true |
| name 2 | body 2 | 12 | true |
| name 3 | body 3 | 13 | true |
When I go to the posts page
And I click "Destroy" in the 2nd row
Then I should see the following posts:
| Name | Body | Rating | Published |
| name 1 | body 1 | 11 | true |
| name 3 | body 3 | 13 | true |
And I should be on the posts page
Scenario: New post page
Given I am on the posts page
When I follow "New Post"
Then I should be on the new post page
When I follow "Back"
Then I should be on the posts page
Scenario: Create a new post
Pending
# Given I am on the new post page
# When I fill in the form with:
# | Name | name 10 |
# | Body | body 10 |
# | Rating | 20 |
# | Published | [x] |
# And I press "Create"
# Then I should see "Post was successfully created."
# And I should see the following post:
# | Name: | name 10 |
# | Body: | body 10 |
# | Rating: | 20 |
# | Published: | true |
Scenario: Attempt to create a new post with invalid input
Pending
# You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required
# Given I am on the new post page
# When I fill in the form with:
# | Name | name 10 |
# | Body | body 10 |
# | Rating | 20 |
# | Published | [x] |
# And I press "Create"
# Then I should see "1 error prohibited this post from being saved:"
#
# [You should add checks for specific errors here. It may be appropriate to add extra scenarios.]
#
# And I should see the following form field values:
# | Name | name 10 |
# | Body | body 10 |
# | Rating | 20 |
# | Published | [x] |
Scenario: Attempt to update a post with invalid input
Pending
# You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required
# Given a post exists
# When I go to the edit page for that post
# And I fill in the form with:
# | Name | name 10 |
# | Body | body 10 |
# | Rating | 20 |
# | Published | [x] |
# And I press "Update"
# Then I should see "1 error prohibited this post from being saved:"
#
# [You should add checks for specific errors here. It may be appropriate to add extra scenarios.]
#
# And I should see the following form field values:
# | Name | name 10 |
# | Body | body 10 |
# | Rating | 20 |
# | Published | [x] |
Scenario: Update a post
Given the following post:
| name | name 10 |
| body | body 10 |
| rating | 20 |
| published | true |
When I go to the edit page for that post
And I fill in the form with:
| Name | name 10 updated |
| Body | body 10 updated |
| Rating | -20 |
| Published | [ ] |
And I press "Update"
Then I should be on the page for that post
And I should see "Post was successfully updated."
And I should see the following post:
| Name: | name 10 updated |
| Body: | body 10 updated |
| Rating: | -20 |
| Published: | false |
Scenario: Navigate from posts page to the edit post page
Given the following posts:
| name | body | rating | published |
| name 1 | body 1 | 11 | true |
| name 2 | body 2 | 12 | true |
| name 3 | body 3 | 13 | true |
When I go to the posts page
And I click "Edit" in the 2nd row
Then I should be on the edit page for the 2nd post
Scenario: Navigate from edit post page to the posts page
Given a post exists
When I go to the edit page for that post
And I follow "Back"
Then I should be on the posts page