Commit graph

1074 commits

Author SHA1 Message Date
Michael Miller
fc0b46caca Use Registry for storing stubs 2019-11-09 09:08:09 -07:00
Michael Miller
aa33acd14e Anything can be passed to allow() 2019-11-09 09:07:54 -07:00
Michael Miller
8262bb0316 Rename OpenMock to Allow 2019-11-09 09:05:17 -07:00
Michael Miller
0698ed655d Switch to using Registry for mocks and fix various issues 2019-11-09 09:03:36 -07:00
Michael Miller
8c2f8d973b Don't embed mock info in type
This can cause problems. Need to use a registry approach.
2019-11-09 09:03:07 -07:00
Michael Miller
875333cffe Initial mock registry code 2019-11-06 21:02:24 -07:00
Michael Miller
cf8e028bd9 Some updates to mocks
Not working correctly for some cases, specifically String.
The default stub can seriously mess up Crystal internals.
It looks like the stubs and spy information will need to be kept outside 
the instance.
2019-11-03 15:07:25 -07:00
Michael Miller
db09274746 Forgot to check-in argument matcher 2019-11-03 14:50:51 -07:00
Michael Miller
e3b9cef221 Remove type restriction
Not sure if this will blow up the type resolution, but seems to fix 
argument comparison from recorded calls.
2019-11-03 14:49:10 -07:00
Michael Miller
82e01e44de Copy-paste and tweak to implement argument expectations 2019-11-03 14:48:08 -07:00
Michael Miller
4acf6aaa58 Add range to description and failure message 2019-11-03 14:28:57 -07:00
Michael Miller
46aff9e11c Add utility methods for setting count 2019-11-03 14:00:40 -07:00
Michael Miller
dabd3a7658 Use ranges to specify call count 2019-11-03 13:59:38 -07:00
Michael Miller
2048267eef Allow specifying receive count
Updated checks and failure output to support this.
2019-11-03 13:22:00 -07:00
Michael Miller
b107511c9e Include stub source in to_s 2019-11-03 13:13:54 -07:00
Michael Miller
59884f253f Better handling of casting with covariance and contravariance 2019-11-03 13:04:44 -07:00
Michael Miller
2a484d5816 Fix return type 2019-11-03 12:07:21 -07:00
Michael Miller
f1a7018718 Remove unnecessary initializer 2019-11-03 12:05:26 -07:00
Michael Miller
9294599440 Basic to_s for stubs 2019-11-03 11:59:12 -07:00
Michael Miller
d1b54ad48f Better error for when stubs don't match return type 2019-11-03 11:56:04 -07:00
Michael Miller
e6c1a6b2d2 Fix arg passing and implement arg matching 2019-11-03 11:42:31 -07:00
Michael Miller
1756670710 Add to_s method 2019-11-03 11:42:07 -07:00
Michael Miller
477271d297 Use NilMethodStub by default
Provides one place that #with can be defined and enforces ordering.
2019-11-03 11:23:04 -07:00
Michael Miller
af9104dfe4 Store arguments in method stub
Needed for matching arguments (setting constraints).
2019-11-03 11:18:46 -07:00
Michael Miller
20b80cc85a Formatting 2019-11-03 10:07:32 -07:00
Michael Miller
cab9366fe8 Merge branch 'dev/mocks-and-doubles' of gitlab.com:arctic-fox/spectator into dev/mocks-and-doubles 2019-11-03 10:07:11 -07:00
Michael Miller
3931f420fe Formatting 2019-11-03 10:03:09 -07:00
Michael Miller
5b143cb72c Change structure around 2019-11-03 10:02:53 -07:00
Michael Miller
c95e228bde Move mocks to their own module 2019-11-03 09:44:32 -07:00
Michael Miller
0c7de3d0d1 Merge branch 'dev/mocks-and-doubles' of gitlab.com:arctic-fox/spectator into dev/mocks-and-doubles 2019-11-02 19:58:56 -06:00
Michael Miller
42aaae7908 Some initial work on mocks 2019-11-02 19:58:47 -06:00
Michael Miller
541dc661ca Only accept exact parameters, don't use splats 2019-11-02 09:45:34 -06:00
Michael Miller
e035afa85f Rework let and subject to allow super
This addresses https://gitlab.com/arctic-fox/spectator/issues/32
2019-10-24 20:47:48 -06:00
Michael Miller
3dd691a990 Record call to stub 2019-10-13 18:50:19 -06:00
Michael Miller
76fa7e294f Friendlier descriptions of objects 2019-10-13 18:49:22 -06:00
Michael Miller
d422376aaf Initial work on have_received matcher 2019-10-13 18:41:10 -06:00
Michael Miller
8cbe2edf30 Formatting 2019-10-13 17:36:55 -06:00
Michael Miller
b09898d131 Rename @stubs to @spectator_stubs 2019-10-13 11:36:31 -06:00
Michael Miller
3befc8001b Basics of stubbing is done
Still need to handle some features of yielding.
Also needs error handling.
2019-10-13 11:21:23 -06:00
Michael Miller
aecdb514b3 Implement basic and_return 2019-10-12 22:35:07 -06:00
Michael Miller
27bc976ae3 Try handling different method signatures and blocks 2019-10-12 21:30:20 -06:00
Michael Miller
211050650e Remove internal double class
Stub handling method should be called from nested methods.
2019-10-12 21:08:49 -06:00
Michael Miller
c80a28d616 More work on method stubs 2019-10-12 20:53:17 -06:00
Michael Miller
0b6465e6bc Started playing around with method stubs 2019-10-12 16:30:46 -06:00
Michael Miller
4b57ddab80 Handle changing test scope
This matches the current pattern, where a nested scope can override 
values from a parent scope.
I think this solution is quite clever :)
2019-10-06 11:12:06 -06:00
Michael Miller
6e50e54e05 Add HTML as planned output type 2019-10-06 11:02:52 -06:00
Michael Miller
1bbe5067b6 Handle deferred stub with type 2019-10-06 10:24:51 -06:00
Michael Miller
49764e5873 Use do...end for multi-line stub def 2019-10-05 22:43:40 -06:00
Michael Miller
6b85bb7ed7 Default raise if stub is called without defintion 2019-10-05 22:42:33 -06:00
Michael Miller
0528ddc2ab Handle stubbed methods with arguments 2019-10-05 22:22:31 -06:00