[rspec-users] Login testing ideas

barsalou barjunk at attglobal.net
Thu Oct 11 14:48:36 EDT 2007


I've been going through Pat's example story and noticed that there was 
no checking for a bad login.  I assume this is because that would have 
made the article bigger and more complicated than it needed to be.

So the question that comes of of this is:

How do folks normally handle the negative case?  My plan was to just 
use another scenario, but as a new person to BDD/TDD, etc, I didn't 
want to start teaching myself bad habits.

So my thought was to do something like:

Story "The saga of the login" do

   Scenario "Good login" do
     Given "a valid user/pass pair", "gooduser", "goodpass" do
       #my needed code
     end
     Then "User should login ok" do
       # more needed code
     end
   end
   Scenario "Bad login" do
     Given "a invalid user/pass pair", "baduser", "badpass" do
       #my needed code
     end
     Then "User should get rejected" do
       # more needed code
     end
   end
end

Another idea was to do this:
Story "The saga of the login" do

   Scenario "Good login" do
     Given "Logging in" do
       #my needed code
     end
     When "with a valid user/pass pair", "gooduser", "goodpass" do
       #my needed code
     end
     Then "User should login ok" do
       # more needed code
     end
     When "with an invalid user/pass pair", "baduser", "badpass" do
       #my needed code
     end
     Then "User should get rejected" do
       # more needed code
     end
   end
end

This doesn't even address the issue of a good user with a bad password, 
but that seemed like overkill.

The second seemed more fluid for me.

Do people even bother with this level of granularity?

I'm probably over complicating the problem.

Thanks for any insight you can provide.

Mike B.



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the rspec-users mailing list