Skip to content

Commit f870c47

Browse files
committed
Cleaned up API
1 parent 3592d8a commit f870c47

File tree

3 files changed

+102
-98
lines changed

3 files changed

+102
-98
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mach = require 'mach'
1010

1111
local f = mach.mock_function()
1212

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

@@ -22,7 +22,7 @@ mach = require 'mach'
2222
local o = {}
2323
o.m = mach.mach_method()
2424

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

@@ -38,7 +38,7 @@ local some_table = {
3838

3939
mocked_table = mach.mockTable(some_table)
4040

41-
mach(mocked_table.foo):should_be_called():
41+
mocked_table.foo:should_be_called():
4242
when(function() mocked_table.foo() end)
4343
```
4444

@@ -53,7 +53,7 @@ function some_object:bar() end
5353

5454
mocked_object = mach.mock_object(some_object)
5555

56-
mach(mocked_object.foo):should_be_called():
56+
mocked_object.foo:should_be_called():
5757
when(function() mocked_object:foo() end)
5858
```
5959

@@ -65,8 +65,8 @@ mach = require 'mach'
6565
local f1 = mach.mock_function()
6666
local f2 = mach.mock_function()
6767

68-
mach(f1):should_be_called():
69-
and_also(mach(f2):should_be_called()):
68+
f1:should_be_called():
69+
and_also(f2:should_be_called()):
7070
when(function() f1(); f2() end)
7171
```
7272

@@ -77,7 +77,7 @@ mach = require 'mach'
7777

7878
local f = mach.mock_function()
7979

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

@@ -89,16 +89,16 @@ mach = require 'mach'
8989
local f = mach.mock_function()
9090

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

9999
-- Use and_also when order is unimportant
100-
mach(f):should_be_calledWith(1):
101-
and_also(mach(f):should_be_calledWith(2)):
100+
f:should_be_called_with(1):
101+
and_also(f:should_be_called_with(2)):
102102
when(function()
103103
f(2) -- No error, order is not fixed when 'and_also' is used
104104
f(1)
@@ -112,10 +112,10 @@ mach = require 'mach'
112112

113113
local f = mach.mock_function()
114114

115-
mach(f):should_be_calledWith(1):
116-
and_also(mach(f):should_be_calledWith(2)):
117-
andThen(mach(f):should_be_calledWith(3)):
118-
and_also(mach(f):should_be_calledWith(4)):
115+
f:should_be_called_with(1):
116+
and_also(f:should_be_called_with(2)):
117+
andThen(f:should_be_called_with(3)):
118+
and_also(f:should_be_called_with(4)):
119119
when(function()
120120
f(2)
121121
f(1)
@@ -133,11 +133,11 @@ local m1 = mach.mock_function()
133133
local m2 = mach.mock_function()
134134

135135
function something_should_happen()
136-
return mach(m1):should_be_called()
136+
return m1:should_be_called()
137137
end
138138

139139
function another_thing_should_happen()
140-
return mach(m2):should_be_calledWith(1, 2, 3)
140+
return m2:should_be_called_with(1, 2, 3)
141141
end
142142

143143
function the_code_under_test_runs()

0 commit comments

Comments
 (0)