Skip to content

Commit 96d2934

Browse files
committed
Updated to conform to olivine labs' style guide
1 parent 9e6b3f7 commit 96d2934

File tree

8 files changed

+380
-380
lines changed

8 files changed

+380
-380
lines changed

README.md

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

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

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

@@ -20,9 +20,9 @@ when(function() f() end)
2020
mach = require 'mach'
2121

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

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

@@ -31,42 +31,42 @@ when(function() o:m() end)
3131
```lua
3232
mach = require 'mach'
3333

34-
local someTable = {
34+
local some_table = {
3535
foo = function() end,
3636
bar = function() end
3737
}
3838

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

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

4545
## Mocking an Object
4646

4747
```lua
4848
mach = require 'mach'
4949

50-
local someObject = {}
51-
function someObject:foo() end
52-
function someObject:bar() end
50+
local some_object = {}
51+
function some_object:foo() end
52+
function some_object:bar() end
5353

54-
mockedObject = mach.mockObject(someObject)
54+
mocked_object = mach.mock_object(some_object)
5555

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

6060
## Multiple Expectations
6161

6262
```lua
6363
mach = require 'mach'
6464

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

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

@@ -75,7 +75,7 @@ when(function() f1(); f2() end)
7575
```lua
7676
mach = require 'mach'
7777

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

8080
mach(f):mayBeCalled():
8181
when(function() end)
@@ -86,21 +86,21 @@ when(function() end)
8686
```lua
8787
mach = require 'mach'
8888

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

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

99-
-- Use andAlso when order is unimportant
100-
mach(f):shouldBeCalledWith(1):
101-
andAlso(mach(f):shouldBeCalledWith(2)):
99+
-- Use and_also when order is unimportant
100+
mach(f):should_be_calledWith(1):
101+
and_also(mach(f):should_be_calledWith(2)):
102102
when(function()
103-
f(2) -- No error, order is not fixed when 'andAlso' is used
103+
f(2) -- No error, order is not fixed when 'and_also' is used
104104
f(1)
105105
end)
106106
```
@@ -110,12 +110,12 @@ end)
110110
```lua
111111
mach = require 'mach'
112112

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

115-
mach(f):shouldBeCalledWith(1):
116-
andAlso(mach(f):shouldBeCalledWith(2)):
117-
andThen(mach(f):shouldBeCalledWith(3)):
118-
andAlso(mach(f):shouldBeCalledWith(4)):
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)):
119119
when(function()
120120
f(2)
121121
f(1)
@@ -129,24 +129,24 @@ end)
129129
```lua
130130
mach = require 'mach'
131131

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

135-
function somethingShouldHappen()
136-
return mach(m1):shouldBeCalled()
135+
function something_should_happen()
136+
return mach(m1):should_be_called()
137137
end
138138

139-
function anotherThingShouldHappen()
140-
return mach(m2):shouldBeCalledWith(1, 2, 3)
139+
function another_thing_should_happen()
140+
return mach(m2):should_be_calledWith(1, 2, 3)
141141
end
142142

143-
function theCodeUnderTestRuns()
143+
function the_code_under_test_runs()
144144
m1()
145145
m2(1, 2, 3)
146146
end
147147

148148
-- Actual test:
149-
somethingShouldHappen():
150-
andAlso(anotherThingShouldHappen()):
151-
when(theCodeUnderTestRuns)
149+
something_should_happen():
150+
and_also(another_thing_should_happen()):
151+
when(the_code_under_test_runs)
152152
```

0 commit comments

Comments
 (0)