A quick question on cucumber steps...

12 views
Skip to first unread message

Doon

unread,
Jun 26, 2010, 10:47:34 PM6/26/10
to TechValley Ruby Brigade
Sorry to Distract from Rails on Windows/Instal Feast Discussion..

I am trying to Figure out the best way to test account locking out/
unlocking via email.

basically I have this...

Scenario: Lock and Unlock via email
Given I have one user "testuser" with email address
"te...@inoc.net", password "foobar1234", account_number "123456789",
and pin "1234"
And I am confirmed
And I am not authenticated
When I go to the sign in page
And I fill in "user_username" with "testuser"
And I fill in "user_password" with "foobar"
And I press "user_submit"
Then I should see "Invalid username or password."

Now in order to trigger the account getting locked out, I need to fail
logging in 10 times in a row. IS there an easy way to repeat a block
in cucumber? or would it be "acceptable" to just add another given
that says Given I have already failed (\d+) times, and just just set
the failed login_count to that?, so the next failed login would
trigger the account locking out..

On a side note I've been playing with email_spec for validating the
emails, and clicking links inside them, and it is working very
well.....


Mark Menard

unread,
Jun 27, 2010, 9:16:13 AM6/27/10
to techva...@googlegroups.com
I'd just make the failed n-times step.

Mark

--
Mark Menard
518 369 7356
ma...@mjm.net
Business: http://www.vitarara.net/
Personal: http://www.vitarara.org/

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google Groups "TechValley Ruby Brigade" group.
> To post to this group, send email to techva...@googlegroups.com.
> To unsubscribe from this group, send email to techvalleyrb...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/techvalleyrb?hl=en.
>

Doon

unread,
Jun 27, 2010, 11:20:28 AM6/27/10
to TechValley Ruby Brigade

On Jun 27, 9:16 am, Mark Menard <mark.menard....@gmail.com> wrote:
> I'd just make the failed n-times step.
>
> Mark
>

Thanks. That is what I wound up doing.

here is my completed scenario
Scenario: Lock and Unlock via email
Given I have one user "testuser" with email address
"exa...@example.com", password "foobar1234", account_number
"123456789", and pin "1234"
And I am confirmed
And I am not authenticated
And I have already failed 10 times
And no emails have been sent
When I go to the sign in page
And I fill in "user_username" with "testuser"
And I fill in "user_password" with "foobar"
And I press "user_submit"
Then I should see "Your account is locked"
And I should receive an email with subject "Unlock Instructions"
When I open the email
Then I should see it is a multi-part email
And I should see "online account has been temporarily suspended"
in the email html part body
And I should see "online account has been temporarily suspended"
in the email text part body
When I click the first link in the email
Then I should see "Your account was successfully unlocked. You are
now signed in."


-Patrick

Thomas Porter

unread,
Jun 27, 2010, 3:10:20 PM6/27/10
to techva...@googlegroups.com
So you can stack when/then sets under a given? Will second and third
when/then sets inherit the state set in prior when/then's?

Sent from my iPhone

Marnen Laibow-Koser

unread,
Jun 27, 2010, 4:01:37 PM6/27/10
to techva...@googlegroups.com

On Jun 27, 2010, at 3:10 PM, Thomas Porter <tom.x....@gmail.com> wrote:

> So you can stack when/then sets under a given? Will second and third when/then sets inherit the state set in prior when/then's?
>

You're overthinking it. Cucumber is actually pretty dumb inside. Given, When, and Then all have the same meaning to it. Cucumber just runs through all the steps for a given scenario in order, maintaining state till the end of the scenario.

>

Note, however, that if you have go back and forth too much between When and Then in one scenario, you might be better advised to split it into several scenarios.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Thomas Porter

unread,
Jun 27, 2010, 8:56:05 PM6/27/10
to techva...@googlegroups.com
Thanks Marnen,

I think this was the key point for me, which I suspected:
"...maintaining state till the end of the scenario..."

I have to repeat to myself some times "It's still just ruby under the hood".

Tom P

Mark Menard

unread,
Jun 29, 2010, 4:20:01 AM6/29/10
to techva...@googlegroups.com
Although you can do the multiple "then" sections I'd really recommend
against it. I'm a bit tired now or I'd write more. We can talk at the
next TVrb about it.

Mark

> --
> You received this message because you are subscribed to the Google Groups "TechValley Ruby Brigade" group.
> To post to this group, send email to techva...@googlegroups.com.
> To unsubscribe from this group, send email to techvalleyrb...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/techvalleyrb?hl=en.
>
>

--
Mark Menard
518.369.7356
http://www.vitarara.net/
Twitter: @mark_menard
AIM: MJFXMenard

Doon

unread,
Jun 29, 2010, 8:33:26 AM6/29/10
to TechValley Ruby Brigade
On Jun 29, 4:20 am, Mark Menard <m...@mjm.net> wrote:
> Although you can do the multiple "then" sections I'd really recommend
> against it. I'm a bit tired now or I'd write more. We can talk at the
> next TVrb about it.

I contemplated breaking it up, and was going back and forth between
should I break it into separate steps, or should I just do the one
long version that actually runs through everything that the user
would. I voted on the latter.


I'll see you thursday night at the training..

-Patrick
Reply all
Reply to author
Forward
0 new messages