Created
November 14, 2012 15:11
-
-
Save erithmetic/4072673 to your computer and use it in GitHub Desktop.
Code for EU Cuke post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
click 'add Widget' | |
page.should have_content('widget added') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find('a[rel~=create-form]').click | |
page.should have_selector('.status.success') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Don't do this! | |
When %r{I try to add a widget with a missing type} do | |
step %{I go to the widget form} | |
step %{I fill in "name" with "test"} | |
step %{I fill in "color" with "red"} | |
step %{I choose "safe" from "safety_rating"} | |
step %{I submit the form} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When %r{I add a valid widget} do | |
visit '/widgets/new' | |
fill_in :name, with: 'test' | |
fill_in :type, with: 'alpha' | |
fill_in :color, with: 'red' | |
select 'safe', from: 'safety_rating' | |
find('input[type=submit]').click | |
end | |
When %r{I try to add a widget with a missing type} do | |
visit '/widgets/new' | |
fill_in :name, with: 'test' | |
fill_in :color, with: 'red' | |
select 'safe', from: 'safety_rating' | |
find('input[type=submit]').click | |
end | |
Then %r{the form submission should be successful} do | |
find('span.error') | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Adding a widget | |
Scenario: Successful add | |
When I add a valid widget | |
Then the form submission should be successful | |
Scenario: Missing fields | |
When I try to add a widget with a missing type | |
Then the form submission should fail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Adding a widget | |
Scenario: Successful add | |
When I go to the widget form | |
And I fill in "name" with "test" | |
And I fill in "type" with "alpha" | |
And I fill in "color" with "red" | |
And I choose "safe" from "safety_rating" | |
And I submit the form | |
Then I should see "Widget added successfully" | |
Scenario: Missing fields | |
When I go to the widget form | |
And I fill in "name" with "test" | |
And I fill in "color" with "red" | |
And I choose "safe" from "safety_rating" | |
And I submit the form | |
Then I should see "Widget could not be added" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment