Skip to content

Instantly share code, notes, and snippets.

@teamon
Created January 2, 2009 18:41
Show Gist options
  • Save teamon/42634 to your computer and use it in GitHub Desktop.
Save teamon/42634 to your computer and use it in GitHub Desktop.
[ 19:40:35 teamon ~/Sites/current/merb-user ] cucumber -r features features/authentication/login.feature --quiet
Feature: Login
To ensure the safety of the application
A regular user of the system
Must authenticate before using the app
Scenario: Failed Login
Given I am not authenticated
When I go to /login
And I fill in "login" with "i_dont exist"
And I fill in "password" with "me either"
And I press "Log In"
Then the login request should fail
And I should see an error message
Scenario: Successful Login
Given I am not authenticated
And only user with login "teamon", email "[email protected]" and password "monkey" exists
And user "teamon" is activated
When I go to /login
And I fill in "login" with "teamon"
And I fill in "password" with "monkey"
And I press "Log In"
Then the login request should success
And I should see a notice message
When I go to homepage
~ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>
session.authenticated?:
false
</title>
<meta content='text/html; charset=utf-8' http-equiv='content-type' />
<link charset='utf-8' href='/stylesheets/master.css' media='screen' rel='stylesheet' type='text/css' />
</head>
<body>
<div id='main'>
<div id='top'>
<h1><a href="/">Site Name</a></h1>
<ul id='nav'>
<li><a href="/login">Log in</a></li>
<li><a href="/forgot_password">Forgot password</a></li>
<li><a href="/signup">Sign up</a></li>
</ul>
</div>
<div id='message'></div>
<div id='content'>
<div class='entry'>
<h2>homepage</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</body>
</html>
Then I should see "Logged in as teamon"
expected: /Logged in as teamon/m,
got: #<struct #<Class:0x22e44cc> status=200, headers={"Content-Type"=>"text/html; charset=utf-8"}, body=#<Merb::Rack::StreamWrapper:0x22e44e0 @body="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\n session.authenticated?:\n false\n </title>\n <meta content='text/html; charset=utf-8' http-equiv='content-type' />\n <link charset='utf-8' href='/stylesheets/master.css' media='screen' rel='stylesheet' type='text/css' />\n </head>\n <body>\n <div id='main'>\n <div id='top'>\n <h1><a href=\"/\">Site Name</a></h1>\n <ul id='nav'>\n <li><a href=\"/login\">Log in</a></li>\n <li><a href=\"/forgot_password\">Forgot password</a></li>\n <li><a href=\"/signup\">Sign up</a></li>\n </ul>\n </div>\n <div id='message'></div>\n <div id='content'>\n <div class='entry'>\n <h2>homepage</h2>\n <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>\n </div>\n </div>\n </div>\n </body>\n</html>\n">, url="http://example.orghomepage", original_env={:input=>"", :method=>"GET", "HTTP_COOKIE"=>"", :headers=>{"HTTP_REFERER"=>"/login"}, :params=>nil}> (using =~)
Diff:
@@ -1,2 +1,15 @@
-/Logged in as teamon/m
+#<struct
+ status=200,
+ headers={"Content-Type"=>"text/html; charset=utf-8"},
+ body=
+ #<Merb::Rack::StreamWrapper:0x22e44e0
+ @body=
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\n session.authenticated?:\n false\n </title>\n <meta content='text/html; charset=utf-8' http-equiv='content-type' />\n <link charset='utf-8' href='/stylesheets/master.css' media='screen' rel='stylesheet' type='text/css' />\n </head>\n <body>\n <div id='main'>\n <div id='top'>\n <h1><a href=\"/\">Site Name</a></h1>\n <ul id='nav'>\n <li><a href=\"/login\">Log in</a></li>\n <li><a href=\"/forgot_password\">Forgot password</a></li>\n <li><a href=\"/signup\">Sign up</a></li>\n </ul>\n </div>\n <div id='message'></div>\n <div id='content'>\n <div class='entry'>\n <h2>homepage</h2>\n <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>\n </div>\n </div>\n </div>\n </body>\n</html>\n">,
+ url="http://example.orghomepage",
+ original_env=
+ {:input=>"",
+ :method=>"GET",
+ "HTTP_COOKIE"=>"",
+ :headers=>{"HTTP_REFERER"=>"/login"},
+ :params=>nil}> (Spec::Expectations::ExpectationNotMetError)
./features/steps/result_steps.rb:3:in `Then /^I should see "(.*)"$/'
features/authentication/login.feature:26:in `Then I should see "Logged in as teamon"'
17 steps passed
1 steps failed
[ 19:41:23 teamon ~/Sites/current/merb-user ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment