Last active
August 29, 2015 14:22
-
-
Save shrop/93cadd5949a696deb67f to your computer and use it in GitHub Desktop.
Meteor cucumber steps for using a logged in user via @patrickml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
module.exports = function () { | |
var url = require('url'); | |
this.Given(/^I am a new user$/, function () { | |
//Reset the Database and reseed it | |
return this.server.call('reset'); | |
}); | |
this.Given(/^I am logged out/, function (callback) { | |
this.client.url(url.resolve(process.env.ROOT_URL, '/logout')). | |
call(callback); | |
}); | |
this.When(/^I navigate to "([^"]*)"$/, function (relativePath, callback) { | |
this.client.url(url.resolve(process.env.ROOT_URL, relativePath)). | |
call(callback); | |
}); | |
this.When(/^I enter "([^"]*)" into the "([^"]*)" field$/, function (text, targetElement, callback) { | |
this.client.setValue(targetElement, text). | |
call(callback); | |
}); | |
this.When(/^I click on "([^"]*)"/, function (targetElement, callback) { | |
this.client.click(targetElement). | |
call(callback); | |
}); | |
this.Then(/^I should see the title "([^"]*)"$/, function (expectedTitle, callback) { | |
this.client. | |
waitForVisible('body *'). | |
getTitle().should.become(expectedTitle).and.notify(callback); | |
}); | |
this.Then(/^I should be on the "([^"]*)" page$/, function (path, callback) { | |
var self = this; | |
self.client. | |
waitForVisible('body *') | |
.url(function(err,res) { | |
console.log(res); | |
}).call(callback); | |
}); | |
}; | |
})(); | |
/* Feature File */ | |
Feature: User Login | |
As a User | |
I want to be able to login to the app | |
So that I can use the application | |
As a user we need to make sure that depending on our user type we are taken to the correct place. | |
Such as a buyer should land on /buyer and a supplier should land on /supplier | |
Background: | |
Given I am a new user | |
And I am logged out | |
@dev | |
Scenario: Logging in as a buyer | |
When I navigate to "/" | |
And I enter "[email protected]" into the "#username" field | |
And I enter "testpass" into the "#password" field | |
And I click on "#login-button" | |
Then I should be on the "/buyer" page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Router.route( '/logout', { | |
name: 'logout', | |
action: function() { | |
Meteor.logout(); | |
Router.go('login'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment