Skip to content

Instantly share code, notes, and snippets.

@sixtyfive
Created September 14, 2011 10:01
Show Gist options
  • Select an option

  • Save sixtyfive/1216232 to your computer and use it in GitHub Desktop.

Select an option

Save sixtyfive/1216232 to your computer and use it in GitHub Desktop.
Scenario: User signs in successfully # features/users/sign_in.feature:22
Given I am not logged in # features/step_definitions/user_steps.rb:32
And I am a user with username "testuser", email "testuser@domain.tld" and password "password" # features/step_definitions/user_steps.rb:5
When I go to the sign in page # features/step_definitions/web_steps.rb:48
And I sign in as "testuser/password" # features/step_definitions/user_steps.rb:16
Then I should see "Erfolgreich angemeldet." # features/step_definitions/web_steps.rb:105
expected there to be content "Erfolgreich angemeldet." in "Falscher Benutzername oder falsches Passwort.\n\n\nAnmeldung\n\n\nBenutzername:\n\n\nPasswort:\n\n\nAngemeldet bleiben?\n\n\n\n\n\n" (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/web_steps.rb:107:in `/^(?:|I )should see "([^"]*)"$/'
features/users/sign_in.feature:27:in `Then I should see "Erfolgreich angemeldet."'
And I should be signed in # features/step_definitions/user_steps.rb:24
When I return next time # features/step_definitions/user_steps.rb:28
Then I should be already signed in
---
Given /^no user exists with a username of "(.*)"$/ do |username|
User.find(:first, :conditions => {:username => username}).should be_nil
end
Given /^I am a user with username "([^"]*)", email "([^"]*)" and password "([^"]*)"$/ do |username, email, password|
User.new(:username => username,
:email => email,
:password => password,
:password_confirmation => password).save!
end
Then /^I should be already signed in$/ do
And %{I should see "Abmelden"}
end
When /^I sign in as "(.*)\/(.*)"$/ do |username, password|
Given %{I am not logged in}
When %{I go to the sign in page}
And %{I fill in "user[username]" with "#{username}"}
And %{I fill in "user[password]" with "#{password}"}
And %{I press "Anmelden"}
end
Then /^I should be signed in$/ do
Then %{I should see "Erfolgreich angemeldet."}
end
When /^I return next time$/ do
And %{I go to the activities page}
end
Given /^I am not logged in$/ do
Given %{I sign out}
end
Then /^I sign out$/ do
visit('/users/sign_out')
end
Then /^I should be signed out$/ do
And %{I should see "Anmeldung"}
And %{I should not see "Abmelden"}
end
---
Feature: Sign in
In order to get access to protected sections of the site
A user
Should be able to sign in
Scenario: User does not exist
Given I am not logged in
And no user exists with a username of "badguy"
When I go to the sign in page
And I sign in as "badguy/password"
Then I should see "Falscher Benutzername oder falsches Passwort."
And I should be signed out
Scenario: User enters wrong password
Given I am not logged in
And I am a user with username "testuser", email "testuser@domain.tld" and password "password"
When I go to the sign in page
And I sign in as "testuser/wrongpassword"
Then I should see "Falscher Benutzername oder falsches Passwort."
And I should be signed out
Scenario: User signs in successfully
Given I am not logged in
And I am a user with username "testuser", email "testuser@domain.tld" and password "password"
When I go to the sign in page
And I sign in as "testuser/password"
Then I should see "Erfolgreich angemeldet."
And I should be signed in
When I return next time
Then I should be already signed in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment