Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactored a cucumber step definition

  • Loading branch information...
commit 8892d2721c1f4cecb0412a79e282ea0253beffe9 1 parent 1c1344d
@paulbjensen paulbjensen authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 features/step_definitions/myStepDefinitions.coffee
View
13 features/step_definitions/myStepDefinitions.coffee
@@ -36,6 +36,9 @@ detectButton = (name, cb) ->
else throw new Error "Could not find button for #{name}"
cb selector
+shouldBeOnThePage = (browser, callback, selector) ->
+ wrap browser.chain.waitForElementPresent(selector), callback
+
module.exports = ->
@World = require("../support/world.coffee").World
@@ -95,16 +98,14 @@ module.exports = ->
else
callback.fail "Expected there to be 1 user record with username #{username}, but found #{docs.length}"
- # TODO - refactor these 3 common step definitions
-
@Given /^I should be on the dashboard page$/, (callback) ->
- wrap @browser.chain.waitForElementPresent('css=.dashboard'), callback
+ shouldBeOnThePage @browser, callback, 'css=.dashboard'
@Given /^I should be on the home page$/, (callback) ->
- wrap @browser.chain.waitForElementPresent('css=.homepage'), callback
+ shouldBeOnThePage @browser, callback, 'css=.dashboard'
@Given /^I should be on the account page$/, (callback) ->
- wrap @browser.chain.waitForElementPresent('css=.account'), callback
+ shouldBeOnThePage @browser, callback, 'css=.dashboard'
@Given /^I reload the page$/, (callback) ->
wrap @browser.chain.refresh(), callback
@@ -300,6 +301,8 @@ module.exports = ->
json = "{\"version\":\"2\"}"
wrap @browser.chain.focus("//textarea").type("//textarea",json), callback
+ # TODO - refactor the 3 following steps, the logic is the same, variables change
+
@Given /^the widget for dashboard "([^"]*)" should have the html "([^"]*)"$/, (name, html, callback) ->
Dashboard.findOne {name}, (err, dashboard) ->
if err?
Please sign in to comment.
Something went wrong with that request. Please try again.