Michael Miller
5fa6b5d549
Fix negation expectation text
2020-01-06 22:11:36 -07:00
Michael Miller
590d81979e
Workaround typing issues
2020-01-06 22:04:05 -07:00
Michael Miller
5673144527
Fix negative match case for contain/cover matcher
2020-01-05 23:01:25 -07:00
Michael Miller
b7c686e836
Add cover
matcher
...
Works the same as `contain` but is for ranges.
2020-01-05 22:49:27 -07:00
Michael Miller
8143229fdb
Fix failure message
2020-01-05 22:47:57 -07:00
Michael Miller
034c1cd6cb
Change array matcher to allow any order
2020-01-05 11:42:39 -07:00
Michael Miller
93c442d1e2
Add instance_of matcher to check exact type
2020-01-04 12:46:08 -07:00
Michael Miller
8cfed440ed
Fix typo with be_a matcher
2020-01-04 12:45:49 -07:00
Michael Miller
c3688807d4
Add kind_of aliases for be_a matcher
2020-01-04 10:08:01 -07:00
Michael Miller
34060ce181
Ensure top-level Crystal types are used
2020-01-04 09:49:28 -07:00
Michael Miller
c4a97230f1
Remove unecessary members provided by ValueMatcher
2020-01-04 09:33:14 -07:00
Michael Miller
4c9d767137
Add missing description arguments
2020-01-04 09:32:56 -07:00
Michael Miller
71740113d5
Allow subject for non-class types
2020-01-02 19:30:46 -07:00
Michael Miller
88ed415191
Bubble up matcher description
...
The last run matcher's description is used if one wasn't provided by the
user.
Only applies to examples that actually run and have expectations.
2020-01-02 19:19:55 -07:00
Michael Miller
d64ecc4192
Store matcher description in MatchData
2020-01-02 19:16:33 -07:00
Michael Miller
00fe913d77
Add predicate method to check for description
2020-01-02 18:43:30 -07:00
Michael Miller
ff2cbcd4c7
Allow test description to be blank
...
Currently defaults to the example's source.
2020-01-02 18:40:25 -07:00
Michael Miller
061028782b
Workaround for what seems to be a Crystal macro bug
...
The syntax:
stub instance.==(other) { true }
effectively becomes:
stub instance.==(other { true })
2020-01-01 21:48:58 -07:00
Michael Miller
8ccc08b472
Fix reflection (verify double) on self arg type
...
There is still an issue with using _ for a placeholder.
2019-12-13 20:25:18 -07:00
Michael Miller
16625cf495
Registry#expect takes a stub
2019-12-13 19:56:43 -07:00
Michael Miller
a38625f8a7
Remove GenericMethodCall
...
This type isn't needed. MethodCall is suitable after moving arguments to
it.
2019-12-13 19:54:06 -07:00
Michael Miller
a6aa00eb38
Fix double default stub with type
2019-12-13 19:17:08 -07:00
Michael Miller
4c9bbbe07b
Formatting
2019-12-08 15:11:23 -07:00
Michael Miller
0ae5cdc9ae
Remove debug
2019-12-08 15:11:08 -07:00
Michael Miller
1a30a56f2a
Better stringified call
2019-12-08 15:10:49 -07:00
Michael Miller
91696d490f
Check if underlying type responds to method
2019-12-08 15:08:13 -07:00
Michael Miller
067c789019
Initial work on type reflection for verifying doubles
2019-12-08 14:52:54 -07:00
Michael Miller
074aff531c
Add "anything" which always returns true when compared against
2019-12-08 14:52:28 -07:00
Michael Miller
07ce835724
VerifyingDouble should be abstract
2019-12-08 14:51:48 -07:00
Michael Miller
8b0f509689
Detect when to use a verifying double
2019-12-08 11:37:08 -07:00
Michael Miller
8197a82ace
Expect stubs not method names
...
Needed for argument syntax:
`expect(dbl).to receive(:foo).with(:bar)`
2019-11-29 09:25:58 -07:00
Michael Miller
c710961be1
Fix returned type inferred to NoReturn
2019-11-29 08:53:36 -07:00
Michael Miller
d6c1169bc3
Fix dumb syntax
2019-11-20 20:40:53 -07:00
Michael Miller
5d84536e1e
Implement and_call_original
2019-11-20 19:17:51 -07:00
Michael Miller
f8563e86c7
Pass along original block
2019-11-20 16:29:06 -07:00
Michael Miller
2dee50f19e
Pass original (and type constraint) to stub via block
2019-11-20 15:43:45 -07:00
Michael Miller
51a47fec98
Remove unused RT parameter
2019-11-20 15:05:04 -07:00
Michael Miller
27acf7bced
Allow receive block syntax
2019-11-19 17:28:00 -07:00
Michael Miller
b062472d98
Revert "Initial support for and_yield"
...
This reverts commit e49bd0d57a
.
Removing support for stubbed yield.
Attempting to yield with different a different arity or argument types causes compilation errors.
I don't see any easy fix for this.
I would rather have no yield support than broken support.
2019-11-17 13:30:09 -07:00
Michael Miller
e49bd0d57a
Initial support for and_yield
2019-11-17 13:12:39 -07:00
Michael Miller
b896a7f1d5
Implement stub that raises
2019-11-17 12:53:18 -07:00
Michael Miller
6e287f864b
Implement returning multiple values
2019-11-17 12:26:02 -07:00
Michael Miller
1a3f663b70
Name is optional for doubles
2019-11-17 10:47:51 -07:00
Michael Miller
a63d3d05a5
Negation for receive matchers
2019-11-17 10:32:37 -07:00
Michael Miller
5da231a5e8
Check expectations for anonymous double
2019-11-17 10:14:03 -07:00
Michael Miller
45fe6217b4
Missing args
2019-11-17 09:42:19 -07:00
Michael Miller
ac9b3ad1fe
Implement expect_any_instance_of
2019-11-16 21:27:18 -07:00
Michael Miller
a15e2a97b1
Allow deferred expectation of multiple stubs
2019-11-16 15:24:23 -07:00
Michael Miller
a8e0f46645
Revert "Coerce operations in match? to booleans"
...
This reverts commit 76c21d447a
.
Should no longer be needed since mocks and doubles should indirectly leak into StandardMatcher types.
2019-11-16 15:15:53 -07:00
Michael Miller
d9d30c57d0
Merge ReceiveArgumentsMatcher and ReceiveMatcher
...
Finally found the issue causing other matchers derived from
StandardMatcher to be "leaked" doubles and mocks indirectly.
The if-condition in ExpectationPartial#to and #to_not caused the matcher
to be given the StandardMatcher type instead of a union type.
This lead to really strange compilation errors and wasted a lot of
hours.
2019-11-16 15:14:38 -07:00
Michael Miller
f0bfd8b6d4
Switch to run-time error for unsupported negation
2019-11-16 13:18:09 -07:00
Michael Miller
201fe614d1
Expect messages on double, but don't stub them
2019-11-16 10:59:13 -07:00
Michael Miller
186fa15a1a
Add method to check for stub
2019-11-16 10:06:11 -07:00
Michael Miller
8dbfb2d6ec
Revert "Allow expected value to receive stub"
...
This reverts commit 6cd410c4c7
.
Should not stub the method.
The end-user needs to do this.
2019-11-16 09:23:45 -07:00
Michael Miller
c9fb4d2d33
Don't run deferred blocks if the test fails
...
This also prevents overriding the test's original error with on that may
occur in the deferred blocks.
2019-11-16 09:06:47 -07:00
Michael Miller
23d8f4b5a6
Formatting
2019-11-16 09:03:24 -07:00
Michael Miller
ca85acefaf
Resolve issue trying to splat union of named tuples
2019-11-16 09:02:57 -07:00
Michael Miller
85531fecf9
Fix truthy values not being strings
2019-11-16 09:01:03 -07:00
Michael Miller
76c21d447a
Coerce operations in match? to booleans
...
The compiler is merging null-doubles with these matchers.
Methods that normally return a boolean instead return the instance
(self).
This causes a return type-mismatch.
There should be a better alternative to this.
2019-11-16 08:49:09 -07:00
Michael Miller
6cd410c4c7
Allow expected value to receive stub
2019-11-16 08:32:13 -07:00
Michael Miller
72e4ac8fe9
Remove unnecessary free variables
2019-11-16 08:17:46 -07:00
Michael Miller
3c94d1f8fd
Workaround for generic argument type issue
2019-11-15 21:18:51 -07:00
Michael Miller
2dc86c05ac
Initial work on deferred have_received check
2019-11-14 19:35:13 -07:00
Michael Miller
98bfed2f83
Expose name and source
2019-11-14 19:17:55 -07:00
Michael Miller
ac3a5c8515
Store GenericArguments
2019-11-14 19:15:51 -07:00
Michael Miller
763c99f338
Formatting
2019-11-14 18:48:43 -07:00
Michael Miller
28ec1062e8
Merge branch 'release/0.9' into dev/mocks-and-doubles
2019-11-14 18:47:25 -07:00
Michael Miller
6b3885af30
Run deferred blocks
2019-11-14 18:41:26 -07:00
Michael Miller
2128184659
Implement defer logic in harness
2019-11-14 18:30:48 -07:00
Michael Miller
173f7bfa13
Add should_eventually and should_never methods
2019-11-14 18:26:24 -07:00
Michael Miller
a80d018ff6
Remove type annotation/requirement
2019-11-14 18:23:45 -07:00
Michael Miller
bd0396c001
Add to_eventually and to_never operations
...
This defines what they should look like.
2019-11-14 18:19:37 -07:00
Michael Miller
b40abe8057
Fix GenericArguments#to_s
2019-11-14 18:06:20 -07:00
Michael Miller
acad88204a
Fix issues with creating anonymous null doubles
2019-11-14 17:55:56 -07:00
Michael Miller
e44f0229d6
Allow stubbing/overriding anonymous double methods
2019-11-14 17:12:27 -07:00
Michael Miller
b9fe1b6a60
Initial code to support anonymous doubles
2019-11-12 21:55:16 -07:00
Michael Miller
b0562981f7
Change double name to string
2019-11-12 21:54:55 -07:00
Michael Miller
38ec44c9ac
Simplify type resolution code
2019-11-12 21:46:33 -07:00
Michael Miller
cb466b4ff5
Display better error when a double isn't found/defined
2019-11-12 21:44:35 -07:00
Michael Miller
87a60cf92a
Split out double macros
2019-11-12 21:21:30 -07:00
Michael Miller
f50e71606e
Make derived double names safer
2019-11-12 21:13:44 -07:00
Michael Miller
94e210c306
Implement null doubles
2019-11-11 23:40:08 -07:00
Michael Miller
48ea53c2f5
Formatting
2019-11-11 23:30:36 -07:00
Michael Miller
c3cba6962c
Get stubs on class methods (self.) working
2019-11-11 23:30:30 -07:00
Michael Miller
233e9573de
Placeholders for delayed message expectation
2019-11-11 22:36:29 -07:00
Michael Miller
20f68e956d
Add receive_messages macro to stub multiple methods
2019-11-11 22:27:53 -07:00
Michael Miller
9c161a07ff
Support for canned responses in double creation
2019-11-11 22:17:37 -07:00
Michael Miller
73e3f8fd66
Raise on non-defined methods
2019-11-11 22:11:58 -07:00
Michael Miller
925af7908b
Raise UnexpectedMessageError
2019-11-11 22:08:36 -07:00
Michael Miller
18b3879dce
Treat symbols and non-symbols the same
2019-11-11 20:59:33 -07:00
Michael Miller
fd2c6d3d8c
Remove reference to test
...
Disallows group context values being used within double definitions.
This had an adverse effect where context values could be called on the
double (dbl.foo).
2019-11-11 20:59:12 -07:00
Michael Miller
96aae8f6d5
Use harness variable
2019-11-10 13:49:10 -07:00
Michael Miller
6c0693f2a4
Add default stubs from parent contexts
2019-11-10 13:22:18 -07:00
Michael Miller
d2e27d1e6e
Pass test context to registry
2019-11-10 13:08:43 -07:00
Michael Miller
2bc4f71edb
Add stubs in reverse order
2019-11-10 13:04:28 -07:00
Michael Miller
4fea5ea435
Add ability to define default stub for mocks
2019-11-10 12:49:36 -07:00
Michael Miller
eb1a99b3ab
Fix deque creation
2019-11-10 12:49:24 -07:00
Michael Miller
14876a8e9a
Add default stubs to TestContext
...
Pass default stubs into mocks registry on example startup.
2019-11-10 12:35:03 -07:00
Michael Miller
a2b72eaa36
Implement allow_any_instance_of
2019-11-10 09:46:23 -07:00
Michael Miller
f816a64770
Resolve issue with harness trying to be used outside of test
2019-11-10 07:27:59 -07:00
Michael Miller
11ea7bf2ce
Move mock containment to harness
2019-11-09 23:22:21 -07:00
Michael Miller
e4aae1f60a
Change Registry to a class
2019-11-09 23:05:22 -07:00
Michael Miller
e0d12e9d0d
Use class name instead of hash of type
...
Hash of type could collide, though unlikely.
2019-11-09 22:32:49 -07:00
Michael Miller
0471794814
Store stubs in reverse order
2019-11-09 22:13:02 -07:00
Michael Miller
17695d35cf
Fix cast to nil when nil is expected
...
Resolves `TypeCastError: The return type of stub #... : Nil at ...:##
doesn't match the expected type Nil`
2019-11-09 21:30:59 -07:00
Michael Miller
e9f7e65ac9
Add mock registry prep
2019-11-09 10:49:29 -07:00
Michael Miller
74eb4fc11a
Reset stubs after each test
2019-11-09 10:39:02 -07:00
Michael Miller
c03808dfce
Handle super vs previous_def
2019-11-09 09:45:57 -07:00
Michael Miller
66dc6bf098
Uncomment predicate matcher
2019-11-09 09:38:11 -07:00
Michael Miller
48363951c2
Update receive matchers to use registry
2019-11-09 09:23:01 -07:00
Michael Miller
9e8286f892
Move double info to registry
2019-11-09 09:18:34 -07:00
Michael Miller
5a072301af
Don't require registration
2019-11-09 09:15:41 -07:00
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
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
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
Michael Miller
47ca96801b
Mark internal class as private
...
Minimal doubles should be done.
2019-10-05 22:06:03 -06:00
Michael Miller
00c0553426
Get contextual values working with doubles
2019-10-05 07:38:13 -06:00
Michael Miller
d08ec75db7
Minimal working double
2019-10-04 23:16:40 -06:00
Michael Miller
bff2668ad4
Remove old files
2019-10-04 23:16:22 -06:00
Michael Miller
c458a490bf
Remove usage of sample values
2019-10-04 23:01:46 -06:00
Michael Miller
8c180e818f
Merge remote-tracking branch 'origin/release/0.9' into mocks-and-doubles
2019-09-27 14:12:29 -06:00
Michael Miller
425240e66f
Merge branch 'release/0.9' into mocks-and-doubles
2019-09-27 14:07:02 -06:00
Michael Miller
0e3727b504
Run after-all hooks correctly
2019-09-26 22:53:16 -06:00
Michael Miller
60ca4361de
Fix implicit subject
2019-09-26 21:44:25 -06:00
Michael Miller
f47c48b483
Add pre- and post-conditions
2019-09-26 21:37:29 -06:00
Michael Miller
1eec9190dd
Workaround for subject evaluation
2019-09-26 21:24:50 -06:00
Michael Miller
07aeaecca4
Add support for pending tests
2019-09-26 20:46:28 -06:00
Michael Miller
25778d7b41
Change "what" to "description"
2019-09-26 16:49:44 -06:00
Michael Miller
edabaa9447
Dumb auto-format
2019-09-26 16:25:43 -06:00
Michael Miller
e3e4cac9c1
Add source to example groups
2019-09-26 16:23:13 -06:00
Michael Miller
dacca0bf1e
Add implicit subject
2019-09-26 16:02:24 -06:00
Michael Miller
a261592776
Add given group
2019-09-26 15:56:48 -06:00
Michael Miller
6ae817d4bc
Add random sample
2019-09-26 15:49:06 -06:00
Michael Miller
3d37a94aaf
Add optional count to sample group
2019-09-26 15:41:58 -06:00
Michael Miller
311b4b0f2f
Use name instead of block_arg
2019-09-26 15:30:29 -06:00
Michael Miller
7e6080aa5f
Move harness out of internals
2019-09-26 15:11:54 -06:00
Michael Miller
0067191423
Remove reference to Internals namespace
2019-09-26 15:11:36 -06:00
Michael Miller
1f300a4a18
Use label in sub-group name
2019-09-26 15:05:28 -06:00
Michael Miller
c3ea34e762
Retrieve test value for sample group
2019-09-26 14:57:31 -06:00
Michael Miller
f6e95719ad
Remove unnecessary quotes in example name
2019-09-26 14:08:17 -06:00
Michael Miller
e5bd582f5f
Handle collection for sample group
2019-09-26 14:05:55 -06:00
Michael Miller
cd0ba81417
Pass test values to test instance
2019-09-26 13:00:23 -06:00
Michael Miller
3c9846ae9b
Remove reference to internals
2019-09-26 12:59:42 -06:00
Michael Miller
5d9e7002d6
Some initial work on sample groups
2019-09-26 12:31:23 -06:00
Michael Miller
422c805e21
Rename SampleValues to TestValues
...
Move out of internal namespace.
2019-09-26 10:26:37 -06:00
Michael Miller
73cef75fcb
Remove dummy example
2019-09-26 09:56:54 -06:00
Michael Miller
a355b59f3e
Type annotations for return types
2019-09-25 09:12:03 -06:00
Michael Miller
d4e890af4c
Merge remote-tracking branch 'origin/master' into example-restructure
2019-09-23 21:30:12 -06:00
Michael Miller
3a6fcb9b0d
Fix value negation of attribute matcher
2019-09-23 20:52:03 -06:00
Michael Miller
00d1cd9ea3
Address warnings with return types in generated types
2019-09-23 20:42:04 -06:00
Michael Miller
43dc106c18
Add return type annotations
...
Addresses Crystal compiler warning about abstract method return types.
2019-09-23 20:32:21 -06:00
Michael Miller
adbfb7da7c
Use integer division - Crystal 0.31.0 change
2019-09-23 19:38:15 -06:00
Michael Miller
24ccb77595
Expose running example to before-each and after-each hooks
2019-09-22 11:27:18 -06:00
Michael Miller
5f3c9d2f63
Distinguish group variables
2019-09-22 11:02:53 -06:00
Michael Miller
24eb5e419a
Get around_each hooks working again
2019-09-18 21:51:35 -06:00