Exemplo n.º 1
0
  it("replaces floats", function(test) {
    test.stub(utils, 'selectStepDefinition').returns({
      pattern: /^I have <exp> amount of money$/
    });

    step = ['Given', 4, 'I have 25.34 amount of money'];

    var formattedStep = formatter.formatStep(step, {stepArgs: {}}, file);
    formattedStep.stepDefinition.args.should.include(25.34);
    test.finish();
  });
Exemplo n.º 2
0
  it("replaces a number with an argument", function(test) {
    test.stub(utils, 'selectStepDefinition').returns({
      pattern : /^the number (\d+) is everything$/
    });

    step = ['Given', 4, 'the number 42 is everything'];

    var formattedStep = formatter.formatStep(step, {stepArgs: {}}, file);
    formattedStep.stepDefinition.args.should.include(42);
    test.finish();
  });
Exemplo n.º 3
0
  it("should replace text between quotes with a string containing a single quote", function(test) {
    test.stub(utils, 'selectStepDefinition').returns({
      pattern : /^the "([^"]*?)" is tasty$/
    });

    step = ['Given', 4, 'the "argument\'s pancake" is tasty'];

    var formattedStep = formatter.formatStep(step, {stepArgs: {}}, file);
    formattedStep.stepDefinition.args.should.include("argument's pancake");
    test.finish();
  });
Exemplo n.º 4
0
  it("should replace text between quotes with a string argument", function(test) {
    test.stub(utils, 'selectStepDefinition').returns({
      pattern : /^the "([^"]*?)" is something$/
    });

    step = ['Given', 4, 'the "argument" is something'];

    var formattedStep = formatter.formatStep(step, {stepArgs: {}}, file);
    formattedStep.stepDefinition.args.should.include('argument');
    test.finish();
  });
Exemplo n.º 5
0
  it("replaces two types of arguments correctly", function(test) {
    test.stub(utils, 'selectStepDefinition').returns({
      pattern : /^the number (\d+) is "([^"]*?)"$/
    });

    step = ['Given', 4, 'the number 42 is "everything"'];

    var formattedStep = formatter.formatStep(step, {stepArgs: {}}, file);
    formattedStep.stepDefinition.args.should.include(42);
    formattedStep.stepDefinition.args.should.include('everything');
    test.finish();
  });
Exemplo n.º 6
0
  it("replaces multiple numbers correctly", function(test) {
    test.stub(utils, 'selectStepDefinition').returns({
      pattern : /^the number (\d+) is greater than (\d+)$/
    });

    step = ['Given', 4, 'the number 42 is greater than 23'];

    var formattedStep = formatter.formatStep(step, {stepArgs: {}}, file);
    formattedStep.pattern.should.eql('the number (\\d*\\.)?(\\d+) is greater than (\\d*\\.)?(\\d+)')
    formattedStep.stepDefinition.args.should.include(42);
    formattedStep.stepDefinition.args.should.include(23);
    test.finish();
  });