Skip to content

Instantly share code, notes, and snippets.

@sircharleswatson
Created July 28, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sircharleswatson/922141a432ddd9309814 to your computer and use it in GitHub Desktop.
Save sircharleswatson/922141a432ddd9309814 to your computer and use it in GitHub Desktop.
User Registration Tests
Feature: User Registration
As Impatient Ivan
I want to register an account as quickly as possible
So that I can start using the app
Background:
Given I am not logged in
@dev
Scenario: Create an account with valid credentials]
When I create an account with valid credentials
Then I should be logged in
And I should see a welcome message
@dev
Scenario: Create an account with invalid credentials
When I create an account with invalid credentials
Then I should receive an error message
'use strict';
module.exports = function () {
this.Given(/^I am not logged in$/, function (callback) {
return this.client.executeAsync(function (done) {
done(Meteor.userId());
}, function (err, result) {
assert.equal(result, undefined);
callback();
});
});
this.When(/^I create an account with valid credentials$/, function () {
return this.client
.waitForExist('#registrationEmail')
.waitForExist('#registrationPassword')
.setValue('#registrationEmail', 'ivan@impatient.com')
.setValue('#registrationPassword', 'hurryup')
.click('#register');
});
this.Then(/^I should be logged in$/, function (callback) {
return this.client.executeAsync(function (done) {
done(Meteor.user());
}, function (err, result) {
assert.equal(result.emails[0], 'ivan@impatient.com');
callback();
});
});
this.Then(/^I should see a welcome message$/, function () {
return this.client
.waitForExist('#welcome')
.getText('#welcome').should.become('Welcome to TaskHero!');
});
this.When(/^I create an account with invalid credentials$/, function () {
return this.client
.waitForExist('#registrationEmail')
.waitForExist('#registrationPassword')
.setValue('#registrationEmail', 'impatientivan.com')
.setValue('#registrationPassword', 'hurry')
.click('#register');
});
this.Then(/^I should receive an error message$/, function () {
return this.client
.waitForExist('#error')
.getText('#error').should.become('You username/password were invalid');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment