Skip to content

Commit 1f7706d

Browse files
committed
Add with_result as an alias for and_will_return
1 parent cdee93b commit 1f7706d

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ local f = mach.mock_function('f')
7777
f.should_be_called().and_will_return(1, 4).when(function()
7878
local x, y = f()
7979
end)
80+
81+
f.should_be_called().with_result(1, 4).when(function()
82+
local x, y = f()
83+
end)
8084
```
8185

8286
## Raising Errors

rockspecs/mach-5.1-0.rockspec

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package = 'mach'
2+
version = '5.1-0'
3+
source = {
4+
url = 'https://github.com/ryanplusplus/mach.lua/archive/v5.1-0.tar.gz',
5+
dir = 'mach.lua-5.1-0/src'
6+
}
7+
description = {
8+
summary = 'Simple mocking framework for Lua inspired by CppUMock and designed for readability.',
9+
homepage = 'https://github.com/ryanplusplus/mach.lua/',
10+
license = 'MIT <http://opensource.org/licenses/MIT>'
11+
}
12+
dependencies = {
13+
'lua >= 5.1'
14+
}
15+
build = {
16+
type = 'builtin',
17+
modules = {
18+
['mach'] = 'mach.lua',
19+
['mach.Expectation'] = 'mach/Expectation.lua',
20+
['mach.ExpectedCall'] = 'mach/ExpectedCall.lua',
21+
['mach.CompletedCall'] = 'mach/CompletedCall.lua',
22+
['mach.unexpected_call_error'] = 'mach/unexpected_call_error.lua',
23+
['mach.unexpected_args_error'] = 'mach/unexpected_args_error.lua',
24+
['mach.out_of_order_call_error'] = 'mach/out_of_order_call_error.lua',
25+
['mach.not_all_calls_occurred_error'] ='mach/not_all_calls_occurred_error.lua',
26+
['mach.format_call_status'] = 'mach/format_call_status.lua',
27+
['mach.format_arguments'] = 'mach/format_arguments.lua',
28+
['mach.format_value'] = 'mach/format_value.lua',
29+
['mach.deep_compare_matcher'] = 'mach/deep_compare_matcher.lua',
30+
['mach.match'] = 'mach/match.lua',
31+
['mach.any'] = 'mach/any.lua',
32+
}
33+
}

spec/mach_spec.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ describe('The mach library', function()
7878
f.should_be_called().and_will_return(4).when(function()
7979
assert.is.equal(f(), 4)
8080
end)
81+
82+
f.should_be_called().with_result(4).when(function()
83+
assert.is.equal(f(), 4)
84+
end)
8185
end)
8286

8387
it('should allow you to specify multiple return values for a mocked function', function()

src/mach/Expectation.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ return function(handle_mock_calls, m)
3232
return o
3333
end)
3434

35+
o.with_result = o.and_will_return
36+
3537
o.and_will_raise_error = wrap(function(...)
3638
if not call_specified then
3739
error('cannot set error for an unspecified call', 2)

0 commit comments

Comments
 (0)