Skip to content

Instantly share code, notes, and snippets.

@lykmapipo
Last active August 29, 2015 14:23
Show Gist options
  • Save lykmapipo/f126e7db673ad542078e to your computer and use it in GitHub Desktop.
Save lykmapipo/f126e7db673ad542078e to your computer and use it in GitHub Desktop.
Mocha as Cucumber
Feature: get cash from an ATM
  Background:
    Given the ATM has 1000
    And the user John is authenticated
    And the user's account has 5000
  Scenario: success
    When the user asks the ATM for 500
    Then the ATM will have 500
    And the user's account will have 4500
    And the ATM will provide 500 in cash
  Scenario: not enough money in the ATM
    When the user asks the ATM for 1500
    Then the ATM will have 1000
    And the user's account will have 5000
    And the ATM will notify the user it does not have enough cash
describe('Feature: get cash from an ATM:', function() {
  context('Scenario: success', function() {
    describe('When the user asks the ATM for 500', function() {

      it('Then the ATM will have 500', function() {
        expect(world().getATM().remainingCash()).to.be.eql(500);
      });

      it("Then the user's account will have 4500", function(done) {
        world().getDB().accountFor(userId).then(function(acc) {
          expect(cash).to.be.eql(acc.cash);
        }).then(done, done);
      });

    });
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment