Skip to content

Commit 9fd4589

Browse files
committed
Updated README to consistently use 'mach' instead of 'mock'
1 parent dd6fcdb commit 9fd4589

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,99 +6,99 @@ Simple mocking framework for Lua inspired by CppUMock and designed for readabili
66
## Mocking a Function
77

88
```lua
9-
mock = require 'mach'
9+
mach = require 'mach'
1010

11-
local f = mock.mockFunction()
11+
local f = mach.mockFunction()
1212

13-
mock(f):shouldBeCalled():
13+
mach(f):shouldBeCalled():
1414
when(function() f() end)
1515
```
1616

1717
## Mocking a Method
1818

1919
```lua
20-
mock = require 'mach'
20+
mach = require 'mach'
2121

2222
local o = {}
23-
o.m = mock.mockMethod()
23+
o.m = mach.mockMethod()
2424

25-
mock(m):shouldBeCalled():
25+
mach(m):shouldBeCalled():
2626
when(function() o:m() end)
2727
```
2828

2929
## Mocking a Table
3030

3131
```lua
32-
mock = require 'mach'
32+
mach = require 'mach'
3333

3434
local someTable = {
3535
foo = function() end,
3636
bar = function() end
3737
}
3838

39-
mockedTable = mock.mockTable(someTable)
39+
mockedTable = mach.mockTable(someTable)
4040

41-
mock(mockedTable.foo):shouldBeCalled():
41+
mach(mockedTable.foo):shouldBeCalled():
4242
when(function() mockedTable.foo() end)
4343
```
4444

4545
## Mocking an Object
4646

4747
```lua
48-
mock = require 'mach'
48+
mach = require 'mach'
4949

5050
local someObject = {}
5151
function someObject:foo() end
5252
function someObject:bar() end
5353

54-
mockedObject = mock.mockObject(someObject)
54+
mockedObject = mach.mockObject(someObject)
5555

56-
mock(mockedObject.foo):shouldBeCalled():
56+
mach(mockedObject.foo):shouldBeCalled():
5757
when(function() mockedObject:foo() end)
5858
```
5959

6060
## Multiple Expectations
6161

6262
```lua
63-
mock = require 'mach'
63+
mach = require 'mach'
6464

65-
local f1 = mock.mockFunction()
66-
local f2 = mock.mockFunction()
65+
local f1 = mach.mockFunction()
66+
local f2 = mach.mockFunction()
6767

68-
mock(f1):shouldBeCalled():
69-
andAlso(mock(f2):shouldBeCalled()):
68+
mach(f1):shouldBeCalled():
69+
andAlso(mach(f2):shouldBeCalled()):
7070
when(function() f1(); f2() end)
7171
```
7272

7373
## Optional Expectations
7474

7575
```lua
76-
mock = require 'mach'
76+
mach = require 'mach'
7777

78-
local f = mock.mockFunction()
78+
local f = mach.mockFunction()
7979

80-
mock(f):mayBeCalled():
80+
mach(f):mayBeCalled():
8181
when(function() end)
8282
```
8383

8484
## Optional Ordering
8585

8686
```lua
87-
mock = require 'mach'
87+
mach = require 'mach'
8888

89-
local f = mock.mockFunction()
89+
local f = mach.mockFunction()
9090

9191
-- Use andAlso when order is important
92-
mock(f):shouldBeCalledWith(1):
93-
andThen(mock(f):shouldBeCalledWith(2)):
92+
mach(f):shouldBeCalledWith(1):
93+
andThen(mach(f):shouldBeCalledWith(2)):
9494
when(function()
9595
f(2) -- Error, out of order call
9696
f(1)
9797
end)
9898

9999
-- Use andAlso when order is unimportant
100-
mock(f):shouldBeCalledWith(1):
101-
andAlso(mock(f):shouldBeCalledWith(2)):
100+
mach(f):shouldBeCalledWith(1):
101+
andAlso(mach(f):shouldBeCalledWith(2)):
102102
when(function()
103103
f(2) -- No error, order is not fixed when 'andAlso' is used
104104
f(1)
@@ -108,14 +108,14 @@ end)
108108
## Mixed Ordering
109109

110110
```lua
111-
mock = require 'mach'
111+
mach = require 'mach'
112112

113-
local f = mock.mockFunction()
113+
local f = mach.mockFunction()
114114

115-
mock(f):shouldBeCalledWith(1):
116-
andAlso(mock(f):shouldBeCalledWith(2)):
117-
andThen(mock(f):shouldBeCalledWith(3)):
118-
andAlso(mock(f):shouldBeCalledWith(4)):
115+
mach(f):shouldBeCalledWith(1):
116+
andAlso(mach(f):shouldBeCalledWith(2)):
117+
andThen(mach(f):shouldBeCalledWith(3)):
118+
andAlso(mach(f):shouldBeCalledWith(4)):
119119
when(function()
120120
f(2)
121121
f(1)
@@ -127,17 +127,17 @@ end)
127127
## Flexible Syntax
128128

129129
```lua
130-
mock = require 'mach'
130+
mach = require 'mach'
131131

132-
local m1 = mock.mockFunction()
133-
local m2 = mock.mockFunction()
132+
local m1 = mach.mockFunction()
133+
local m2 = mach.mockFunction()
134134

135135
function somethingShouldHappen()
136-
return mock(m1):shouldBeCalled()
136+
return mach(m1):shouldBeCalled()
137137
end
138138

139139
function anotherThingShouldHappen()
140-
return mock(m2):shouldBeCalledWith(1, 2, 3)
140+
return mach(m2):shouldBeCalledWith(1, 2, 3)
141141
end
142142

143143
function theCodeUnderTestRuns()

0 commit comments

Comments
 (0)