Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Little bit of cleanup of Smoke's namespace pollution on mocked object…

…s by prefixing Smoke-internal functions with an underscore.

(Might want to put these under a "_smoke" data structure in the future?)
  • Loading branch information...
commit bf422f750fcee0c36f093c70bdfb155de833cf06 1 parent e759795
Larry Karnowski authored
Showing with 12 additions and 12 deletions.
  1. +6 −6 lib/smoke.mock.js
  2. +6 −6 spec/mock_spec.js
12 lib/smoke.mock.js
View
@@ -11,7 +11,7 @@ Smoke.failed = function(mock, message){
// Some helpers
Smoke.reset = function(){
Smoke.mocks = Smoke.mocks || [];
- for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i].resetMocks();
+ for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i]._resetMocks();
Smoke.mocks = [];
Smoke.passCount = 0;
Smoke.failCount = 0;
@@ -19,7 +19,7 @@ Smoke.reset = function(){
Smoke.reset();
Smoke.checkExpectations = function(){
- for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i].checkExpectations();
+ for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i]._checkExpectations();
};
Smoke.Mock = function(originalObj) {
@@ -41,24 +41,24 @@ Smoke.Mock = function(originalObj) {
return expectation;
};
- obj.checkExpectations = function(){
+ obj._checkExpectations = function(){
for(var e in this._expectations) {
var expectations = this._expectations[e]
for(var i=0; i < expectations.length; i++) expectations[i].check();
};
};
- obj.resetMocks = function(){
+ obj._resetMocks = function(){
for(var attr in this._valuesBeforeMocking) {
this[attr] = this._valuesBeforeMocking[attr];
}
delete this._valuesBeforeMocking;
delete this._expectations;
+ delete this._resetMocks;
+ delete this._checkExpectations;
delete this.stub;
delete this.should_receive;
- delete this.checkExpectations;
- delete this.resetMocks;
};
Smoke.mocks.push(obj);
12 spec/mock_spec.js
View
@@ -150,18 +150,18 @@ Screw.Unit(function() {
expect(obj._expectations).to_not(equal, null);
expect(obj.stub).to_not(equal, null);
expect(obj.should_receive).to_not(equal, null);
- expect(obj.checkExpectations).to_not(equal, null);
- expect(obj.resetMocks).to_not(equal, null);
+ expect(obj._checkExpectations).to_not(equal, null);
+ expect(obj._resetMocks).to_not(equal, null);
- obj.resetMocks();
+ obj._resetMocks();
Smoke.mocks = [];
expect(obj._valuesBeforeMocking).to(equal, null);
expect(obj._expectations).to(equal, null);
expect(obj.stub).to(equal, null);
expect(obj.should_receive).to(equal, null);
- expect(obj.checkExpectations).to(equal, null);
- expect(obj.resetMocks).to(equal, null);
+ expect(obj._checkExpectations).to(equal, null);
+ expect(obj._resetMocks).to(equal, null);
});
it("should replace the original functionality to the object", function(){
@@ -169,7 +169,7 @@ Screw.Unit(function() {
mock(obj).should_receive("shout").and_return("some string");
expect(obj.shout()).to(equal, "some string");
- obj.resetMocks();
+ obj._resetMocks();
Smoke.mocks = [];
expect(obj.shout()).to(equal, "HELLO");
Please sign in to comment.
Something went wrong with that request. Please try again.