Posts

Showing posts with the label Cucumber

Dry up your code: Decisive OR clause [2nd mile]

2 . Decisive OR clause Lets take step #3 of the same scenario: #1 - Given the "user" launches the app  #2 - When he logs in #3 - Then he sees the home page   Poss ible (logical) variation s o f step #3 could be # 3 .0 - Then he sees the home page         Def #1: T hen /^he sees the home page $/ do               @home_ page. should be _displayed             end          # 3 .1 -  Then he does not see the home page                 Def #2: T hen /^ he does not see the home page $/ do               @home_ page. should _not be _displayed             end  Now lets use the power of Decisive OR c lause to define the step as Def: T hen /^he ( sees|does not see) the home pa...

Dry up your code: Simple OR clause [1st mile]

1. Simple OR clause Consider the following scenario, #1 - Given the "user" launches the app  #2 - When he logs in #3 - Then he sees the home page Lets look at step #2 closer and identify possible variations of it #2.0 - When he logs in                 [Def #1: When /^he logs in$/ ] #2.1 - When "user" logs in           [Def #2: When /^"([^"]*)" logs in$/ ] #2.2 - When "admin" logs in        [Def #2: When /^"([^"]*)" logs in$/ ] #2.3 -  When she logs in              [Def #3: When /^she logs in$/ ] Believe me variation #2.3 will be used a lot if your team has a healthy gender ratio. Now do we need 3 step definitions to capture all the 4 variations. Nope (otherwise why am I writing this blog anyways :-) Step...