On 25.01.2009, at 21:49, Shalon Wood wrote:

> Hmm. The thing is, that's fairly long:
>
> Given I am not authenticated
>    When I go to http://playground.playground.pele.cx/login
>    And I fill in "username" with "<mail>"
>    And I fill in "password" with "<password>"
>    And I press "Log In"
>
> All before I start the stuff that's actually relevant to the  
> scenario in
> question, which is why I was hoping to be able to say 'Given I am  
> logged
> in as <foo>'.


Given %r{^I am authenticated as "(.*)"$}i do |credentials|
   email, password = credentials.split("/")
   Given %{I was registered with "#{email}/#{password}"}
   Then %{I can log in as "#{email}/#{password}"}
end

Then %r{^I can log in as "(.*)"$}i do |credentials|
   email, password = credentials.split("/")
   When %{I try to log in as "#{email}/#{password}"}
   Then %{I should be redirected to "http://myapp.com/start"}
end

Then %r{^I can not log in as "([^/\s]+)/(\S+)"}i do |email, password|
   When %{I try to log in as "#{email}/#{password}"}
   Then %{I should be redirected to "http://myapp.com/sessions"}
   And %{I should see "Oops. We could not sign you in."}
end

When %r{^I try to log in as "([^/\s]+)/(\S+)"$}i do |email, password|
   When 'I go to "http://myapp.com/signin";'
   And %{I fill in "email" with "#{email}"}
   And %{I fill in "password" with "#{password}"}
   And %{I press "Sign In"}
end

When %r{^I log out$}i do
   When %{I follow "Sign out"}
end


"I was registered as" step usually tries to find user in preloaded  
test data before creating a new record.

MK


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to