Skip to content

Commit 8803d44

Browse files
committed
Refactored variable names in tests
1 parent 0ed2ccd commit 8803d44

File tree

3 files changed

+54
-62
lines changed

3 files changed

+54
-62
lines changed

test/data/adapters/inMemory_test.coffee

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
66
'': {
77
topic: () -> new InMemoryDataAdapter(),
88

9-
'it should require no constructor arguments': (instance) ->
10-
should.exist(instance)
9+
'it should require no constructor arguments': (adapter) ->
10+
should.exist(adapter)
1111

12-
'it should be empty when nothing has been added': (instance) ->
13-
instance.items.should.eql({})
12+
'it should be empty when nothing has been added': (adapter) ->
13+
adapter.items.should.eql({})
1414

1515
'when saving a new item': {
16-
topic: (instance) ->
17-
instance.save('testObjects', sampleObjects[0], @callback)
16+
topic: (adapter) ->
17+
adapter.save('testObjects', sampleObjects[0], @callback)
1818

1919
'it should pass back the original attributes': (err, attributes) ->
2020
should.not.exist(err)
@@ -23,7 +23,7 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
2323
attributes.items.should.eql(['one', 'two'])
2424

2525
'it should not simply use the same object in memory': (err, attributes) ->
26-
# strict equal compares memory addresses
26+
# standard equal compares memory addresses
2727
attributes.should.not.equal(sampleObjects[0])
2828

2929
'it should add an _id attribute': (err, attributes) ->
@@ -32,8 +32,8 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
3232
}
3333

3434
'when updating an existing item': {
35-
topic: (instance) ->
36-
instance.save('testObjects', {
35+
topic: (adapter) ->
36+
adapter.save('testObjects', {
3737
'_id': 0
3838
'newObject': sampleObjects[1]
3939
}, @callback)
@@ -46,8 +46,8 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
4646
}
4747

4848
'when finding an object by real id': {
49-
topic: (instance) ->
50-
instance.find('testObjects', {
49+
topic: (adapter) ->
50+
adapter.find('testObjects', {
5151
'_id': 0
5252
}, @callback)
5353

@@ -60,8 +60,8 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
6060
}
6161

6262
'when finding an object by a fake id': {
63-
topic: (instance) ->
64-
instance.find('testObjects', {
63+
topic: (adapter) ->
64+
adapter.find('testObjects', {
6565
'_id': 1
6666
}, @callback)
6767

@@ -72,8 +72,8 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
7272
}
7373

7474
'when finding an object in a non-existent collection': {
75-
topic: (instance) ->
76-
instance.find('noTestObjects', {
75+
topic: (adapter) ->
76+
adapter.find('noTestObjects', {
7777
'_id': 0
7878
}, @callback)
7979

@@ -84,8 +84,8 @@ vows.describe('In-memory store (data/adapters/inMemory)').addBatch(
8484
}
8585

8686
'when searching with no parameters': {
87-
topic: (instance) ->
88-
instance.find('testObjects', {}, @callback)
87+
topic: (adapter) ->
88+
adapter.find('testObjects', {}, @callback)
8989

9090
'it should return all items in the collection': (err, items) ->
9191
should.not.exist(err)

test/data/storedObject_test.coffee

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,32 @@ StoredObject = require '../../data/storedObject'
44

55
vows.describe('Base stored object (data/storedObject)').addBatch(
66
'': {
7-
topic: () -> getTopic()
7+
topic: () -> getStoredObject()
88

99
'when save() is called': {
10-
topic: (instance) ->
11-
instance.save('testCollection', {
10+
topic: (storedObject) ->
11+
storedObject.save('testCollection', {
1212
'one': true
1313
}, @callback)
1414

1515
'it should call the adapter\'s save() method': (err, attributes) ->
16-
callCount.should.equal(1)
16+
callsToSave.should.have.length(1)
1717

1818
'it should pass collection and attributes to the adapter': (err, attributes) ->
19-
args.should.have.length(1)
20-
args[0].should.have.length(3)
21-
args[0][0].should.equal('testCollection')
22-
args[0][1].should.eql({ 'one': true })
23-
args[0][2].should.equal(@callback)
19+
callsToSave[0].should.have.length(3)
20+
callsToSave[0][0].should.equal('testCollection')
21+
callsToSave[0][1].should.eql({ 'one': true })
22+
callsToSave[0][2].should.equal(@callback)
2423
}
2524
}
2625
).export(module)
2726

28-
callCount = 0
29-
args = []
27+
callsToSave = []
3028

31-
getTopic = () ->
32-
topic = new StoredObject()
33-
topic._adapter =
29+
getStoredObject = () ->
30+
storedObject = new StoredObject()
31+
storedObject._adapter =
3432
save: (collection, attributes, callback) ->
35-
callCount++;
36-
args.push([collection, attributes, callback])
33+
callsToSave.push([collection, attributes, callback])
3734
callback(null, attributes)
38-
return topic
35+
return storedObject

test/models/model_test.coffee

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,52 @@ Model = require '../../models/model'
55

66
vows.describe('Base model (models/model)').addBatch(
77
'': {
8-
topic: () -> getTopic()
8+
topic: () -> getModel()
99

10-
'when toJSON() is called with no attributes': {
11-
topic: (instance) ->
12-
instance.toJSON()
10+
'when toJSON() is called when the model has no attributes': {
11+
topic: (model) ->
12+
model.toJSON()
1313

1414
'it should return an empty object': (jsonObject) ->
1515
jsonObject.should.eql({})
1616
}
1717

18-
'when toJSON() is called with attributes': {
19-
topic: (instance) ->
20-
instance.attributes = { 'two': false }
21-
instance.toJSON()
18+
'when toJSON() is called when the model has attributes': {
19+
topic: (model) ->
20+
model.attributes = { 'two': false }
21+
model.toJSON()
2222

2323
'it should return the attributes object': (jsonObject) ->
2424
jsonObject.should.eql({ 'two': false })
2525
}
2626

2727
'when save() is called': {
28-
topic: (instance) ->
29-
instance.attributes = {
30-
'one': true
31-
}
32-
instance.save('testCollection', @callback)
28+
topic: (model) ->
29+
model.attributes = { 'one': true }
30+
model.save('testCollection', @callback)
3331

3432
'it should call save() on the base object': (err, attributes) ->
35-
callCount.should.equal(1)
36-
args.should.have.length(1)
33+
callsToSave.should.have.length(1)
3734

3835
'it should pass model.attributes to the save()': (err, attributes) ->
39-
args[0].should.have.length(3)
40-
args[0][1].should.eql({ 'one': true })
36+
callsToSave[0].should.have.length(3)
37+
callsToSave[0][1].should.eql({ 'one': true })
4138

4239
'it should pass collection and callback to base': (err, attributes) ->
43-
args[0].should.have.length(3)
44-
args[0][0].should.equal('testCollection')
45-
args[0][2].should.not.be.null
40+
callsToSave[0].should.have.length(3)
41+
callsToSave[0][0].should.equal('testCollection')
42+
callsToSave[0][2].should.not.be.null
4643
}
4744
}
4845
).export(module)
4946

50-
callCount = 0
51-
args = []
47+
callsToSave = []
5248

53-
getTopic = () ->
54-
topic = new Model()
55-
topic._adapter =
49+
getModel = () ->
50+
model = new Model()
51+
model._adapter =
5652
save: (collection, attributes, callback) ->
57-
callCount++;
58-
args.push([collection, attributes, callback])
53+
callsToSave.push([collection, attributes, callback])
5954
callback(null, attributes)
60-
return topic
55+
return model
6156

0 commit comments

Comments
 (0)