Skip to content

Commit 9fb06dd

Browse files
committed
Show named mocks in all examples
1 parent 2d744ef commit 9fb06dd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Simple mocking framework for Lua inspired by CppUMock and designed for readabili
88
```lua
99
local mach = require 'mach'
1010

11-
local f = mach.mock_function()
11+
local f = mach.mock_function('f')
1212

1313
f:should_be_called():when(function() f() end)
1414
```
@@ -19,7 +19,7 @@ f:should_be_called():when(function() f() end)
1919
local mach = require 'mach'
2020

2121
local o = {}
22-
o.m = mach.mach_method()
22+
o.m = mach.mach_method('m')
2323

2424
m:should_be_called():when(function() o:m() end)
2525
```
@@ -34,7 +34,7 @@ local some_table = {
3434
bar = function() end
3535
}
3636

37-
mocked_table = mach.mockTable(some_table)
37+
mocked_table = mach.mockTable(some_table, 'some_table')
3838

3939
mocked_table.foo:should_be_called():when(function()
4040
mocked_table.foo()
@@ -50,7 +50,7 @@ local some_object = {}
5050
function some_object:foo() end
5151
function some_object:bar() end
5252

53-
mocked_object = mach.mock_object(some_object)
53+
mocked_object = mach.mock_object(some_object, 'some_object')
5454

5555
mocked_object.foo:should_be_called():when(function()
5656
mocked_object:foo()
@@ -62,8 +62,8 @@ end)
6262
```lua
6363
local mach = require 'mach'
6464

65-
local f1 = mach.mock_function()
66-
local f2 = mach.mock_function()
65+
local f1 = mach.mock_function('f1')
66+
local f2 = mach.mock_function('f2')
6767

6868
f1:should_be_called():
6969
and_also(f2:should_be_called()):
@@ -78,7 +78,7 @@ f1:should_be_called():
7878
```lua
7979
local mach = require 'mach'
8080

81-
local f = mach.mock_function()
81+
local f = mach.mock_function('f')
8282

8383
f:mayBeCalled():when(function() end)
8484
```
@@ -88,7 +88,7 @@ f:mayBeCalled():when(function() end)
8888
```lua
8989
local mach = require 'mach'
9090

91-
local f = mach.mock_function()
91+
local f = mach.mock_function('f')
9292

9393
-- Use and_then when order is important
9494
f:should_be_called_with(1):
@@ -112,7 +112,7 @@ f:should_be_called_with(1):
112112
```lua
113113
local mach = require 'mach'
114114

115-
local f = mach.mock_function()
115+
local f = mach.mock_function('f')
116116

117117
f:should_be_called_with(1):
118118
and_also(f:should_be_called_with(2)):
@@ -131,8 +131,8 @@ f:should_be_called_with(1):
131131
```lua
132132
local mach = require 'mach'
133133

134-
local m1 = mach.mock_function()
135-
local m2 = mach.mock_function()
134+
local m1 = mach.mock_function('m1')
135+
local m2 = mach.mock_function('m2')
136136

137137
function something_should_happen()
138138
return m1:should_be_called()

0 commit comments

Comments
 (0)