Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 2 changed files with 12 additions and 12 deletions. Show diff stats Hide diff stats

  1. +6 6 lib/smoke.mock.js
  2. +6 6 spec/mock_spec.js
12 lib/smoke.mock.js
@@ -11,7 +11,7 @@ Smoke.failed = function(mock, message){
11 11 // Some helpers
12 12 Smoke.reset = function(){
13 13 Smoke.mocks = Smoke.mocks || [];
14   - for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i].resetMocks();
  14 + for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i]._resetMocks();
15 15 Smoke.mocks = [];
16 16 Smoke.passCount = 0;
17 17 Smoke.failCount = 0;
@@ -19,7 +19,7 @@ Smoke.reset = function(){
19 19 Smoke.reset();
20 20
21 21 Smoke.checkExpectations = function(){
22   - for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i].checkExpectations();
  22 + for(var i=0; i<Smoke.mocks.length; i++) Smoke.mocks[i]._checkExpectations();
23 23 };
24 24
25 25 Smoke.Mock = function(originalObj) {
@@ -41,24 +41,24 @@ Smoke.Mock = function(originalObj) {
41 41 return expectation;
42 42 };
43 43
44   - obj.checkExpectations = function(){
  44 + obj._checkExpectations = function(){
45 45 for(var e in this._expectations) {
46 46 var expectations = this._expectations[e]
47 47 for(var i=0; i < expectations.length; i++) expectations[i].check();
48 48 };
49 49 };
50 50
51   - obj.resetMocks = function(){
  51 + obj._resetMocks = function(){
52 52 for(var attr in this._valuesBeforeMocking) {
53 53 this[attr] = this._valuesBeforeMocking[attr];
54 54 }
55 55
56 56 delete this._valuesBeforeMocking;
57 57 delete this._expectations;
  58 + delete this._resetMocks;
  59 + delete this._checkExpectations;
58 60 delete this.stub;
59 61 delete this.should_receive;
60   - delete this.checkExpectations;
61   - delete this.resetMocks;
62 62 };
63 63
64 64 Smoke.mocks.push(obj);
12 spec/mock_spec.js
@@ -150,18 +150,18 @@ Screw.Unit(function() {
150 150 expect(obj._expectations).to_not(equal, null);
151 151 expect(obj.stub).to_not(equal, null);
152 152 expect(obj.should_receive).to_not(equal, null);
153   - expect(obj.checkExpectations).to_not(equal, null);
154   - expect(obj.resetMocks).to_not(equal, null);
  153 + expect(obj._checkExpectations).to_not(equal, null);
  154 + expect(obj._resetMocks).to_not(equal, null);
155 155
156   - obj.resetMocks();
  156 + obj._resetMocks();
157 157 Smoke.mocks = [];
158 158
159 159 expect(obj._valuesBeforeMocking).to(equal, null);
160 160 expect(obj._expectations).to(equal, null);
161 161 expect(obj.stub).to(equal, null);
162 162 expect(obj.should_receive).to(equal, null);
163   - expect(obj.checkExpectations).to(equal, null);
164   - expect(obj.resetMocks).to(equal, null);
  163 + expect(obj._checkExpectations).to(equal, null);
  164 + expect(obj._resetMocks).to(equal, null);
165 165 });
166 166
167 167 it("should replace the original functionality to the object", function(){
@@ -169,7 +169,7 @@ Screw.Unit(function() {
169 169 mock(obj).should_receive("shout").and_return("some string");
170 170 expect(obj.shout()).to(equal, "some string");
171 171
172   - obj.resetMocks();
  172 + obj._resetMocks();
173 173 Smoke.mocks = [];
174 174
175 175 expect(obj.shout()).to(equal, "HELLO");

0 comments on commit bf422f7

Please sign in to comment.
Something went wrong with that request. Please try again.