Cucumber features for listing keychain records - moralesalberto/personal GitHub Wiki

Feature

Feature: Display a list of keychains
  Background: A user logs into the application
    Given a user is not logged in
    And is a valid user with email "[email protected]" and password "working123"
    When the user goes to the root page of the application
    Then the user should be redirected to the login page
    When the user enters his correct credentials in the login page, email: "[email protected]" and password "working123"    
    And submits the login page
    Then the user should be shown the root page

  Scenario: An authorized user sees the list of keychains
    Given there are several keychains in the system, with names "foo, bar, other"
    When the user goes to the listing of keychains page
    Then the keychains listing page is presented
    And the list of keychains should be shown, with names "foo, bar, other"

Step definitions

Given(/^there are several keychains in the system, with names "(.*?)"$/) do |names|
  names = names.split(",").map {|name| name.strip}
  names.each do |name|
    FactoryGirl.create(:keychain, :name => name)
  end
end

When(/^the user goes to the listing of keychains page$/) do
  visit(keychains_path)
end

Then(/^the keychains listing page is presented$/) do
  page.current_path.should eq(keychains_path)
end

Then(/^the list of keychains should be shown, with names "(.*?)"$/) do |names|
  names = names.split(",").map {|name| name.strip}
  names.each do |name|
    page.should have_content(name)
  end
end