Skip to content

Commit

Permalink
Rename Cucumber.Types to Cucumber.Type (for consistency, every namesp…
Browse files Browse the repository at this point in the history
…ace is singular)
  • Loading branch information
jbpros committed Jul 17, 2011
1 parent d346ec3 commit b96e613
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 55 deletions.
9 changes: 3 additions & 6 deletions lib/cucumber.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Cucumber = function(featuresSource, supportCodeDefinition) {
var listeners = Cucumber.Types.Collection();
var listeners = Cucumber.Type.Collection();

var self = {
start: function start(callback) {
Expand Down Expand Up @@ -31,16 +31,13 @@ var Cucumber = function(featuresSource, supportCodeDefinition) {
};
return self;
};

Cucumber.START_MISSING_CALLBACK_ERROR = "Cucumber.start() expects a callback.";

Cucumber.Parser = require('./cucumber/parser');
Cucumber.Ast = require('./cucumber/ast');
Cucumber.SupportCode = require('./cucumber/support_code');
Cucumber.Runtime = require('./cucumber/runtime');
Cucumber.Listener = require('./cucumber/listener');
Cucumber.Types = require('./cucumber/types');
Cucumber.Type = require('./cucumber/type');
Cucumber.Util = require('./cucumber/util');
Cucumber.Debug = require('./cucumber/debug'); // Untested namespace

module.exports = Cucumber;
module.exports = Cucumber;
4 changes: 2 additions & 2 deletions lib/cucumber/ast/feature.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Feature = function(keyword, name, description, line) {
var Cucumber = require('../../cucumber');

var scenarios = Cucumber.Types.Collection();
var scenarios = Cucumber.Type.Collection();

var self = {
getKeyword: function getKeyword() {
Expand Down Expand Up @@ -32,4 +32,4 @@ var Feature = function(keyword, name, description, line) {
};
return self;
};
module.exports = Feature;
module.exports = Feature;
4 changes: 2 additions & 2 deletions lib/cucumber/ast/features.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Features = function() {
var Cucumber = require('../../cucumber');

var features = Cucumber.Types.Collection();
var features = Cucumber.Type.Collection();

var self = {
addFeature: function addFeature(feature) {
Expand All @@ -20,4 +20,4 @@ var Features = function() {
};
return self;
};
module.exports = Features;
module.exports = Features;
4 changes: 2 additions & 2 deletions lib/cucumber/ast/scenario.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Scenario = function(keyword, name) {
var Cucumber = require('../../cucumber');

var steps = Cucumber.Types.Collection();
var steps = Cucumber.Type.Collection();

var self = {
getKeyword: function getKeyword() {
Expand All @@ -28,4 +28,4 @@ var Scenario = function(keyword, name) {
};
return self;
};
module.exports = Scenario;
module.exports = Scenario;
2 changes: 1 addition & 1 deletion lib/cucumber/listener/progress_formatter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var ProgressFormatter = function(options) {
var Cucumber = require('../../cucumber');

var beforeEachScenarioUserFunctions = Cucumber.Types.Collection();
var beforeEachScenarioUserFunctions = Cucumber.Type.Collection();
var logs = "";
var passedScenarios = 0;
var passedSteps = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/support_code/library.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Library = function(supportCodeDefinition) {
var Cucumber = require('../../cucumber');

var stepDefinitions = Cucumber.Types.Collection();
var stepDefinitions = Cucumber.Type.Collection();

var self = {
lookupStepDefinitionByName: function lookupStepDefinitionByName(name) {
Expand Down Expand Up @@ -54,4 +54,4 @@ var Library = function(supportCodeDefinition) {

return self;
};
module.exports = Library;
module.exports = Library;
3 changes: 3 additions & 0 deletions lib/cucumber/type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var Type = {};
Type.Collection = require('./type/collection');
module.exports = Type;
File renamed without changes.
3 changes: 0 additions & 3 deletions lib/cucumber/types.js

This file was deleted.

8 changes: 4 additions & 4 deletions spec/cucumber/ast/feature_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Cucumber.Ast.Feature", function() {
spyOnStub(scenarioCollection, 'add');
spyOnStub(scenarioCollection, 'getLast').andReturn(lastScenario);
spyOnStub(scenarioCollection, 'forEach');
spyOn(Cucumber.Types, 'Collection').andReturn(scenarioCollection);
spyOn(Cucumber.Type, 'Collection').andReturn(scenarioCollection);
keyword = createSpy("Feature keyword");
name = createSpy("Feature name");
description = createSpy("Feature description");
Expand All @@ -20,7 +20,7 @@ describe("Cucumber.Ast.Feature", function() {

describe("constructor", function() {
it("creates a new collection to store scenarios", function() {
expect(Cucumber.Types.Collection).toHaveBeenCalled();
expect(Cucumber.Type.Collection).toHaveBeenCalled();
});
});

Expand All @@ -41,7 +41,7 @@ describe("Cucumber.Ast.Feature", function() {
expect(feature.getDescription()).toBe(description);
});
});

describe("addScenario()", function() {
it("adds the scenario to the scenarios (collection)", function() {
var scenario = createSpy("scenario AST element");
Expand All @@ -68,7 +68,7 @@ describe("Cucumber.Ast.Feature", function() {
visitor = createSpyWithStubs("Visitor", {visitScenario: null});
callback = createSpy("Callback");
});

it ("iterates over the scenarios with a user function and the callback", function() {
feature.acceptVisitor(visitor, callback);
expect(scenarioCollection.forEach).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions spec/cucumber/ast/features_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ describe("Cucumber.Ast.Features", function() {
spyOnStub(featureCollection, 'add');
spyOnStub(featureCollection, 'getLast').andReturn(lastFeature);
spyOnStub(featureCollection, 'forEach');
spyOn(Cucumber.Types, 'Collection').andReturn(featureCollection);
spyOn(Cucumber.Type, 'Collection').andReturn(featureCollection);
features = Cucumber.Ast.Features();
});

describe("constructor", function() {
it("creates a new collection to store features", function() {
expect(Cucumber.Types.Collection).toHaveBeenCalledWith();
expect(Cucumber.Type.Collection).toHaveBeenCalledWith();
});
});

Expand Down
12 changes: 6 additions & 6 deletions spec/cucumber/ast/scenario_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("Cucumber.Ast.Scenario", function() {
var Cucumber = require('cucumber');
var stepCollection, steps;
var scenario, keyword, name, lastStep;

beforeEach(function() {
keyword = createSpy("Feature keyword");
name = createSpy("Feature name");
Expand All @@ -13,13 +13,13 @@ describe("Cucumber.Ast.Scenario", function() {
spyOnStub(stepCollection, 'add');
spyOnStub(stepCollection, 'getLast').andReturn(lastStep);
spyOnStub(stepCollection, 'forEach');
spyOn(Cucumber.Types, 'Collection').andReturn(stepCollection);
spyOn(Cucumber.Type, 'Collection').andReturn(stepCollection);
scenario = Cucumber.Ast.Scenario(keyword, name);
});

describe("constructor", function() {
it("creates a new collection to store steps", function() {
expect(Cucumber.Types.Collection).toHaveBeenCalled();
expect(Cucumber.Type.Collection).toHaveBeenCalled();
});
});

Expand All @@ -34,7 +34,7 @@ describe("Cucumber.Ast.Scenario", function() {
expect(scenario.getName()).toBe(name);
});
});

describe("addStep()", function() {
it("adds the step to the steps (collection)", function() {
var step = createSpy("Step AST element");
Expand All @@ -61,7 +61,7 @@ describe("Cucumber.Ast.Scenario", function() {
visitor = createSpyWithStubs("Visitor", {visitStep: null});
callback = createSpy("Callback");
});

it ("iterates over the steps with a user function and the callback", function() {
scenario.acceptVisitor(visitor, callback);
expect(stepCollection.forEach).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions spec/cucumber/listener/progress_formatter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ describe("Cucumber.Listener.ProgressFormatter", function() {

beforeEach(function() {
beforeEachScenarioUserFunctions = createSpy("User Functions to call before each scenario");
spyOn(Cucumber.Types, 'Collection').andReturn(beforeEachScenarioUserFunctions);
spyOn(Cucumber.Type, 'Collection').andReturn(beforeEachScenarioUserFunctions);
listener = Cucumber.Listener.ProgressFormatter();
});

describe("constructor", function() {
it("creates a new collection to store user functions to call before each scenario", function() {
expect(Cucumber.Types.Collection).toHaveBeenCalled();
expect(Cucumber.Type.Collection).toHaveBeenCalled();
});
});

Expand Down
20 changes: 10 additions & 10 deletions spec/cucumber/support_code/library_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ describe("Cucumber.SupportCode.Library", function() {
createSpyWithStubs("Third step definition", {matchesStepName:false})
];
spyOnStub(stepDefinitionCollection, 'syncForEach').andCallFake(function(cb) { stepDefinitionCollection.forEach(cb); });
spyOn(Cucumber.Types, 'Collection').andReturn(stepDefinitionCollection);
spyOn(Cucumber.Type, 'Collection').andReturn(stepDefinitionCollection);
});

describe("constructor", function() {
it("creates a collection of step definitions", function() {
library = Cucumber.SupportCode.Library(rawSupportCode);
expect(Cucumber.Types.Collection).toHaveBeenCalled();
expect(Cucumber.Type.Collection).toHaveBeenCalled();
});

describe("before executing the raw support code", function() {
Expand All @@ -50,7 +50,7 @@ describe("Cucumber.SupportCode.Library", function() {
expect(given).toBe(library.defineThenStep);
});
});

it("executes the raw support code", function() {
library = Cucumber.SupportCode.Library(rawSupportCode);
expect(rawSupportCode).toHaveBeenCalled();
Expand All @@ -63,14 +63,14 @@ describe("Cucumber.SupportCode.Library", function() {
Cucumber.SupportCode.Library(rawSupportCode);
expect(Given).toBe(originalGiven);
});

it("restores the global 'When' to its original value", function() {
var originalWhen = createSpy("Original When");
When = originalWhen;
Cucumber.SupportCode.Library(rawSupportCode);
expect(When).toBe(originalWhen);
});

it("restores the global 'Then' to its original value", function() {
var originalThen = createSpy("Original Then");
Then = originalThen;
Expand All @@ -79,15 +79,15 @@ describe("Cucumber.SupportCode.Library", function() {
});
});
});

describe("lookupStepDefinitionByName()", function() {
var stepName;

beforeEach(function() {
library = Cucumber.SupportCode.Library(rawSupportCode);
stepName = createSpy("Step name");
});

it("asks each step definition in the library if they match the step name", function() {
library.lookupStepDefinitionByName(stepName);
stepDefinitionCollection.forEach(function(stepDefinition) {
Expand All @@ -106,7 +106,7 @@ describe("Cucumber.SupportCode.Library", function() {
describe(methodName + "()", function() {
var stepRegexp, stepCode;
var stepDefinition;

beforeEach(function() {
library = Cucumber.SupportCode.Library(rawSupportCode);
stepRegexp = createSpy("Step name");
Expand All @@ -120,14 +120,14 @@ describe("Cucumber.SupportCode.Library", function() {
library[methodName](stepRegexp, stepCode);
expect(Cucumber.SupportCode.StepDefinition).toHaveBeenCalledWith(stepRegexp, stepCode);
});

it("adds the step definition to the step definition collection", function() {
library[methodName](stepRegexp, stepCode);
expect(stepDefinitionCollection.add).toHaveBeenCalledWith(stepDefinition);
});
});
};

describeStepDefiner('defineGivenStep');
describeStepDefiner('defineWhenStep');
describeStepDefiner('defineThenStep');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require('../../support/spec_helper');

describe("Cucumber.Types.Collection", function() {
describe("Cucumber.Type.Collection", function() {
var Cucumber = require('cucumber');
var collection, itemArray;

beforeEach(function() {
itemArray = [1, 2, 3];
spyOn(itemArray, 'push');
spyOn(global, 'Array').andReturn(itemArray);
collection = Cucumber.Types.Collection();
collection = Cucumber.Type.Collection();
});

describe("constructor", function() {
Expand All @@ -24,12 +24,12 @@ describe("Cucumber.Types.Collection", function() {
expect(itemArray.push).toHaveBeenCalledWith(item);
});
});

describe("getLast()", function() {
it("returns the latest added item from the array", function() {
var lastItem = createSpy("last item");
itemArray[itemArray.length] = lastItem;
expect(collection.getLast()).toBe(lastItem);
expect(collection.getLast()).toBe(lastItem);
});
});

Expand Down Expand Up @@ -76,7 +76,7 @@ describe("Cucumber.Types.Collection", function() {
delayItemProcessing = true;
collection.forEach(userFunction, callback);
expect(allItemsProcessedBeforeCallback).toBeFalsy();
expect(callback).not.toHaveBeenCalled();
expect(callback).not.toHaveBeenCalled();
});

it("does not process the next item until the current one is finished", function() {
Expand All @@ -97,7 +97,7 @@ describe("Cucumber.Types.Collection", function() {

describe("syncForEach()", function() {
var userFunction = createSpy("userFunction");

it("calls foreach on the array", function() {
spyOn(itemArray, 'forEach');
collection.syncForEach(userFunction);
Expand Down
Loading

0 comments on commit b96e613

Please sign in to comment.