Created
August 30, 2013 21:20
-
-
Save andrewhavens/6394386 to your computer and use it in GitHub Desktop.
Cucumber example, declarative style
This file contains 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: Widget Management | |
Background: | |
Given I am logged in as a user | |
Scenario: Creating a new widget | |
When I create a widget | |
Then I should see "Widget was successfully created." |
This file contains 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
Given /^I am logged in as an user/ do | |
@user = Fabricate(:user) | |
visit auth_login_path | |
fill_in "Username", with: @user.username | |
fill_in "Password", with: "password" | |
click_button "Log In" | |
end |
This file contains 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 /^I create a widget/ do | |
visit root_url | |
click_link "New Widget" | |
fill_in "Name", with: "Awesome Widget" | |
click_button "Create Widget" | |
end |
This file contains 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
Then /^I (should|should not) see "(.*)"$/ do |action, text| | |
if action == 'should' | |
page.should have_content(text) | |
else | |
page.should_not have_content(text) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compare to Capybara feature file, declarative style