Skip to content
This repository
Browse code

refactored a cucumber step definition

  • Loading branch information...
commit 8892d2721c1f4cecb0412a79e282ea0253beffe9 1 parent 1c1344d
Paul Jensen paulbjensen authored

Showing 1 changed file with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. +8 5 features/step_definitions/myStepDefinitions.coffee
13 features/step_definitions/myStepDefinitions.coffee
@@ -36,6 +36,9 @@ detectButton = (name, cb) ->
36 36 else throw new Error "Could not find button for #{name}"
37 37 cb selector
38 38
  39 +shouldBeOnThePage = (browser, callback, selector) ->
  40 + wrap browser.chain.waitForElementPresent(selector), callback
  41 +
39 42 module.exports = ->
40 43
41 44 @World = require("../support/world.coffee").World
@@ -95,16 +98,14 @@ module.exports = ->
95 98 else
96 99 callback.fail "Expected there to be 1 user record with username #{username}, but found #{docs.length}"
97 100
98   - # TODO - refactor these 3 common step definitions
99   -
100 101 @Given /^I should be on the dashboard page$/, (callback) ->
101   - wrap @browser.chain.waitForElementPresent('css=.dashboard'), callback
  102 + shouldBeOnThePage @browser, callback, 'css=.dashboard'
102 103
103 104 @Given /^I should be on the home page$/, (callback) ->
104   - wrap @browser.chain.waitForElementPresent('css=.homepage'), callback
  105 + shouldBeOnThePage @browser, callback, 'css=.dashboard'
105 106
106 107 @Given /^I should be on the account page$/, (callback) ->
107   - wrap @browser.chain.waitForElementPresent('css=.account'), callback
  108 + shouldBeOnThePage @browser, callback, 'css=.dashboard'
108 109
109 110 @Given /^I reload the page$/, (callback) ->
110 111 wrap @browser.chain.refresh(), callback
@@ -300,6 +301,8 @@ module.exports = ->
300 301 json = "{\"version\":\"2\"}"
301 302 wrap @browser.chain.focus("//textarea").type("//textarea",json), callback
302 303
  304 + # TODO - refactor the 3 following steps, the logic is the same, variables change
  305 +
303 306 @Given /^the widget for dashboard "([^"]*)" should have the html "([^"]*)"$/, (name, html, callback) ->
304 307 Dashboard.findOne {name}, (err, dashboard) ->
305 308 if err?

0 comments on commit 8892d27

Please sign in to comment.
Something went wrong with that request. Please try again.