[rspec-users] Side Effects in Stories

Pat Maddox pergesu at gmail.com
Fri Oct 19 14:56:10 EDT 2007


On 10/19/07, s.ross <cwdinfo at gmail.com> wrote:
>
>
>
> On Oct 18, 2007, at 6:09 AM, Daniel N wrote:
>
>
> On 9/11/07, s.ross <cwdinfo at gmail.com> wrote:
> > I have a story where the user resets the password [hey, this story
> > thing really rocks!]. It is expected that the password will change
> > and that the user will be redirected to a login screen. A side effect
> > is that the user will receive email with his/her new password.
> >
> > Where I'm stuck is in ascertaining whether mail was generated.
> >
> > Any thoughts on how this might be accomplished?
> >
> > Thanks
> >
> > -----------------
> >
> > Story: Reset the Password
> >
> >    As a registered user
> >    I want to be able to reset the password and have it emailed to me
> >    And then I want to log in
> >
> >
> > Scenario: Reset password for an account
> >
> >    Given A valid account is given:   joe at schmoe.com
> >
> >    When Resetting password for joe at schmoe.com
> >
> >    Then Password state should change in database joe at schmoe.com
> >    And Registered user should be redirected to login screen
> >    And Email should be sent to the registered user
> >    And the new password should work :)
> > _______________________________________________
>
> Hi s.ross
>
> I know this was a while ago that you asked this question, but did  you end
> up coming up with a solution?
>
> -Daniel
>
> Nope, and embarrassingly, I took a different direction without preserving
> any traces of what I had been doing (can you say "frequent checkins?").
> Ooops. Everything but verifying that the email was sent was running, but I
> never figured out how to verify that.
>
> --steve
>
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

I don't have the agile book on hand, but in the chapter on testing
they show how to test whether an email gets delivered.  I imagine it
would be the same thing.  You set the mail delivery mechanism to test
(which is done by default in environments/test.rb) and then check the
test mail queue.  See if that works.

Pat


More information about the rspec-users mailing list