Michael Miller
4500ebcddc
Update old references to Value and Block
2021-01-16 11:02:29 -07:00
Michael Miller
e09f5c960a
Change Assertions to Expectations
...
Start expectation rework.
2021-01-16 10:22:23 -07:00
Michael Miller
a74957204b
Introduce abstract generic value type
...
Sits between AbstractExpression and Value and Block.
2021-01-15 22:32:02 -07:00
Michael Miller
4ed8c4a573
Implement remaining assertion macros
...
Move "should" methods.
2021-01-10 11:09:28 -07:00
Michael Miller
096c31d7f5
Initial work on assertions
2021-01-09 19:50:32 -07:00
Michael Miller
122395837f
Implement remaining value DSL macros
2021-01-09 17:36:50 -07:00
Michael Miller
391325d431
Initial work on values DSL
2021-01-09 17:01:33 -07:00
Michael Miller
7451769a29
Pass current example as block argument
2021-01-09 13:34:15 -07:00
Michael Miller
009ca4776a
Cleanup new DSL macros
2021-01-09 13:17:42 -07:00
Michael Miller
df096d91aa
Capture source info for hooks
2021-01-09 11:30:00 -07:00
Michael Miller
2ecd4ded6d
Fix line numbers being wrong with macro expansion
...
Addresses https://github.com/icy-arctic-fox/spectator/issues/18
2021-01-08 15:32:15 -07:00
Michael Miller
4c6b6e6436
Merge branch 'master' into example-api
2020-12-23 14:52:53 -07:00
Michael Miller
f465df48d4
Fix copy/paste fail docs
2020-12-23 13:18:36 -07:00
Michael Miller
5ec7e25d57
Remove splat
2020-12-23 12:54:44 -07:00
Michael Miller
0540f94823
Add contain_elements and have_elements variants
2020-12-23 12:38:37 -07:00
Michael Miller
0279606a1c
Placeholder code for after hooks
2020-11-15 11:22:06 -07:00
Michael Miller
b4e74444d1
Some work on hooks in DSL
2020-11-08 22:21:52 -07:00
Michael Miller
7d54884196
Don't pass context, get/cast from example instance
2020-11-08 16:53:54 -07:00
Michael Miller
b8dc83286c
Upcast context to reduce method instances generated by compiler
2020-11-08 16:52:08 -07:00
Michael Miller
f433405ece
Scratch work
...
Trying to implement hooks. Ran into a problem with contexts.
2020-11-08 15:06:49 -07:00
Michael Miller
688c08b087
Initial work on hooks rework
2020-11-07 22:04:37 -07:00
Michael Miller
1f319a70ce
Add docs
2020-11-07 22:04:21 -07:00
Michael Miller
e8afe5070b
Address Ameba issues
2020-10-19 20:34:18 -06:00
Michael Miller
c36e006c85
Move top-level DSL to its own module
2020-10-17 22:57:27 -06:00
Michael Miller
79499c5d2e
Add config to spec builder
2020-10-17 17:40:38 -06:00
Michael Miller
788b12a8bc
Fix example methods overriding previously defined methods
2020-10-17 12:12:04 -06:00
Michael Miller
579fcacfde
Move spec builder
2020-09-26 22:51:58 -06:00
Michael Miller
543df88d39
Forward build method
2020-09-26 22:25:04 -06:00
Michael Miller
4567162459
Prevent defining an example or group in a test
2020-09-26 19:23:57 -06:00
Michael Miller
99a9d7960a
Formatting
2020-09-26 19:23:16 -06:00
Michael Miller
60795a371d
Reorganize
2020-09-26 19:15:34 -06:00
Michael Miller
b8ba38152e
Cleanup example description handling
2020-09-26 19:14:08 -06:00
Michael Miller
1d359efcb0
Improve source line detection
2020-09-26 19:12:42 -06:00
Michael Miller
1ad41ac016
Cleanup group description handling
2020-09-26 19:11:52 -06:00
Michael Miller
96a7989815
Remove unreferenced code
2020-09-26 18:14:41 -06:00
Michael Miller
acb3b16496
Add some docs
2020-09-26 18:14:22 -06:00
Michael Miller
de99fce5b1
Merge branch 'master' into example-api
2020-09-26 11:10:55 -06:00
Michael Miller
6363436afa
Nested macros for defining DSL keywords
2020-09-25 21:44:17 -06:00
Michael Miller
a0af1e7cd1
Allow string interpolation in some macros
...
Enables interpolation in example and group descriptions, as well as
anonymous doubles.
Addresses https://github.com/icy-arctic-fox/spectator/issues/10
2020-09-17 09:35:49 -06:00
Michael Miller
9103bfde0f
Playing around with line numbers
...
Trying to find some pattern in the line descripancies reported to the
macros compared to the source file.
2020-09-14 20:00:17 -06:00
Michael Miller
bc602d9b62
Working example creation from DSL
2020-09-14 13:55:07 -06:00
Michael Miller
7c44cba667
Fix group creation via DSL
2020-09-12 18:40:56 -06:00
Michael Miller
dad669686c
Temporarily disable running examples
2020-09-12 18:40:36 -06:00
Michael Miller
67ac06e4d6
Some initial spec builder code
2020-09-12 18:37:14 -06:00
Michael Miller
225c358cb8
Some initial work on cleaned up groups
2020-09-12 16:01:29 -06:00
Michael Miller
8f0718db86
Handle splat in macro for matcher DSL
...
Should fix https://github.com/icy-arctic-fox/spectator/issues/8
2020-08-11 14:37:37 -06:00
Michael Miller
9c14c69bba
Change "ditto" to ":ditto:"
2020-08-06 19:20:18 -06:00
Michael Miller
7fc25b84c3
Fix bug when using multiple short-hand block expects in one test
...
For instance, this would fail:
```
it "does something" do
expect(&.foo).to be_true
expect(&.false).to be_false
end
```
2020-05-29 20:06:37 -06:00
Michael Miller
476e54bb2b
Store expected value as array
...
Fixes issue where contain_exactly matcher would try to append to a tuple
(which isn't allowed).
2020-05-28 22:23:29 -06:00
Michael Miller
d02b848ad5
Use the exact text from the describe value
...
This fixes described_class.new when using a generic type.
2020-04-26 11:13:07 -06:00
Michael Miller
e126cb744b
Ensure that a TypeNode is resolved
...
When describing a constant, the `resolve?` method can return a
non-TypeNode, which is the constant's value.
The Crystal docs seem to indicate this should only return `TypeNode` or
`NilLiteral`.
But, I can see when this would be useful to resolve a constant in a
macro.
To work around this, `described_class` and `subject` should only be
defined when it resolves to a `TypeNode`.
Fixes arctic-fox/spectator#40
Fixes arctic-fox/spectator#41
2020-03-04 23:16:29 -07:00
Michael Miller
d0f229c659
Pass example proc to around_each hook if there are no arguments
2020-03-03 15:20:25 -07:00
Michael Miller
e92aa7ed57
Implicit subject should not use .new with modules
...
Fixes GitHub issue https://github.com/icy-arctic-fox/spectator/issues/6
2020-02-22 22:59:09 -07:00
Davide Paolo Tua
ce9bf918c1
Fix syntax errors in be_between matcher
2020-02-21 12:48:22 +01:00
Michael Miller
3aaab0e74f
Fix memoized subject from context description another way
...
The other method gave a strange compiler error when running specs.
Something to do with "K" not having an inspect method.
In /usr/share/crystal/src/hash.cr:1826:13
1826 | key.inspect(io)
^------
Error: undefined method 'inspect' for K
2020-02-16 19:50:20 -07:00
Michael Miller
dd48bf6f25
Fix subject not being memoized when using described_class
2020-02-16 19:34:48 -07:00
Michael Miller
7a8e570bea
Fix typo with should_eventually
2020-02-10 17:50:35 -07:00
Michael Miller
b1984b343a
Add should
keywords to examples
...
Allows short-hand like:
it { should be_empty }
2020-01-19 22:12:06 -07:00
Michael Miller
e60c287216
Fix a dumb with merge
2020-01-19 10:05:21 -07:00
Michael Miller
f825a34771
Fix issue with implicit vs. explicit subject
...
Addresses the issue pointed out in !25
There was a recent change that set a subject to the first argument of
`describe` and `context`. This prevented an explicitly defined subject
from being accessible in nested groups.
2020-01-17 14:53:03 +03:00
Michael Miller
c48b9ed9e1
Resolve let! not working on uninferable types
...
Resolves https://github.com/icy-arctic-fox/spectator/issues/4
Use ValueWrapper trick again and initialize immediately with before_each
hook.
2020-01-14 20:07:56 -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
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
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
71740113d5
Allow subject for non-class types
2020-01-02 19:30:46 -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
067c789019
Initial work on type reflection for verifying doubles
2019-12-08 14:52:54 -07:00
Michael Miller
8b0f509689
Detect when to use a verifying double
2019-12-08 11:37:08 -07:00
Michael Miller
27acf7bced
Allow receive block syntax
2019-11-19 17:28:00 -07:00
Michael Miller
1a3f663b70
Name is optional for doubles
2019-11-17 10:47:51 -07:00
Michael Miller
ac9b3ad1fe
Implement expect_any_instance_of
2019-11-16 21:27:18 -07:00
Michael Miller
72e4ac8fe9
Remove unnecessary free variables
2019-11-16 08:17:46 -07:00
Michael Miller
acad88204a
Fix issues with creating anonymous null doubles
2019-11-14 17:55:56 -07:00
Michael Miller
b9fe1b6a60
Initial code to support anonymous doubles
2019-11-12 21:55:16 -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
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
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
a2b72eaa36
Implement allow_any_instance_of
2019-11-10 09:46:23 -07:00
Michael Miller
66dc6bf098
Uncomment predicate matcher
2019-11-09 09:38:11 -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
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
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
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
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
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
42aaae7908
Some initial work on mocks
2019-11-02 19:58:47 -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
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
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
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
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
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
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
5d9e7002d6
Some initial work on sample groups
2019-09-26 12:31:23 -06:00
Michael Miller
00d1cd9ea3
Address warnings with return types in generated types
2019-09-23 20:42:04 -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
24eb5e419a
Get around_each hooks working again
2019-09-18 21:51:35 -06:00
Michael Miller
52ef5e5ced
Some DSL methods for hooks
2019-09-15 10:40:53 -06:00
Michael Miller
7002564ebd
Add let and subject with variants
...
New behavior mimics RSpec - bang variant defines immediately instead of
not storing.
2019-09-15 09:45:48 -06:00
Michael Miller
c94b284ab3
Replace large DSL files with smaller, logical groups
2019-09-15 09:15:33 -06:00
Michael Miller
3f7c16c888
Move all DSL to one module, but separate files
2019-09-13 14:33:46 -06:00
Michael Miller
fafe5606e6
Rename DSL::Builder to SpecBuilder
...
Place all builders under SpecBuilder.
2019-09-13 14:10:25 -06:00
Michael Miller
5d86b4f50e
Get examples working again
2019-09-12 20:26:54 -06:00
Michael Miller
08ee03b1de
Quickly get things somewhat working again
2019-09-12 20:16:41 -06:00
Michael Miller
e304224bd6
Move stack handling to its own type
2019-09-08 09:59:25 -06:00
Michael Miller
f25eb9164f
Some test creation rewrite
2019-09-08 09:58:15 -06:00
Michael Miller
1c5b46b981
Use fresh variables
2019-09-01 00:54:04 -06:00
Michael Miller
19913a28d1
Gut factories and example structure code
2019-08-31 13:12:40 -06:00
Michael Miller
bfe641e07e
Move sample values to group instance
...
The goal is to construct examples with a parameterless initializer.
This doesn't quite work, since the sample values are retrieved via the
harness, which doesn't have an active example when the sample values are
created.
2019-08-30 14:46:24 -06:00
Michael Miller
4ecc2c6004
Include ExampleDSL at root
...
Will need to check if methods can run in that scope.
2019-08-30 13:14:48 -06:00
Michael Miller
64045171c2
Change contexts from modules to classes
2019-08-30 12:39:03 -06:00
Michael Miller
6e9633d001
Hacked in double instance creation
2019-08-26 22:48:15 -06:00
Michael Miller
3462bdea1a
Some initial double code
2019-08-26 21:49:47 -06:00
Michael Miller
70e01364ce
Address Ameba issue
2019-08-26 21:11:21 -06:00
Michael Miller
4abf97139b
Experimenting with auto-mocking methods
2019-08-26 21:06:06 -06:00
Michael Miller
c36859b42b
Correct docs
2019-08-17 08:10:26 -06:00