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

Feature

Feature: Delete a keychain record
  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: A user deletes a keychain record
    Given an existing keychain with name "mouse"
    When the user goes to view the keychain with the name "mouse"
    Then the user should be shown the keychain with the name "mouse"
    When the user clicks on the delete keychain link
    Then the keychain with the name "mouse" should be deleted
    And the keychains listing page is presented
    

Step definitions

When(/^the user clicks on the delete keychain link$/) do
  click_on('Delete')
end

Then(/^the keychain with the name "(.*?)" should be deleted$/) do |name|
  keychains = Keychain.where('name = ?', name)
  keychains.size.should eq(0)
end