Michael Miller
8d73434e0b
Add ability to mark example skipped/pending mid-test
2021-06-09 21:57:17 -06:00
Michael Miller
a08d5202fe
Implement pending examples as lighweight examples
...
Drop test code block if a pending, skip, or x-prefix macro is used.
2021-06-05 12:51:46 -06:00
Michael Miller
6bea36d8b6
Move Node out of Spec namespace
2021-05-07 20:09:33 -06:00
Michael Miller
f24d634ccb
Merge branch 'release/0.10' into specs
2021-04-26 17:19:25 -06:00
Michael Miller
29594eefab
Merge branch 'master' into release/0.10
2021-04-26 11:19:08 -06:00
Michael Miller
93e270f87a
Support variables and methods for type matcher (be_a).
...
Addresses https://github.com/icy-arctic-fox/spectator/issues/25
2021-04-17 09:38:29 -06:00
Michael Miller
d612657b15
Merge branch 'release/0.10' into specs
2021-03-31 15:28:16 -06:00
Michael Miller
3d702f9bc6
Merge branch 'master' into release/0.10
2021-03-31 15:19:30 -06:00
matthewmcgarvey
8fafd2467d
Allow matching any line number of example in filter
2021-03-30 00:18:08 -04:00
Michael Miller
74b78b7ca8
Rename Source to Location
2021-02-12 22:46:22 -07:00
Michael Miller
08451df643
Add matcher to check compiled type of values
2021-02-12 18:33:50 -07:00
Michael Miller
3083f82132
Change DSL::Values to DSL::Memoize
2021-02-10 17:07:49 -07:00
Michael Miller
3cd569e639
Prevent using reserved keywords in let and subject
2021-02-10 16:58:17 -07:00
Michael Miller
8232da1167
Mark DSL generated methods as private
2021-02-09 22:40:15 -07:00
Michael Miller
8d48e441b2
Fix generating source from brace-less examples.
...
Addresses https://github.com/icy-arctic-fox/spectator/issues/20
2021-02-03 10:06:00 -07:00
Michael Miller
0363c43dff
Fix described_class
...
Must be a macro, otherwise the return type becomes a union of all nested
described_class methods, which can cause weird errors.
2021-01-31 00:38:17 -07:00
Michael Miller
e275711f2b
Formatting
2021-01-30 23:48:59 -07:00
Michael Miller
078058ad05
Fix various issues with subjects
...
All tests in crystal spec pass!
2021-01-30 20:38:09 -07:00
Michael Miller
e8b284fc60
Fix namepsaces
...
crystal spec compiles again!
2021-01-30 17:40:33 -07:00
Michael Miller
d3ad0963cd
Minor fixes
2021-01-30 17:31:50 -07:00
Michael Miller
73985772b7
DSL fully added back in
2021-01-30 16:43:13 -07:00
Michael Miller
20680f37cb
Add docs
2021-01-30 15:39:29 -07:00
Michael Miller
ba967218fa
Move tags code to a common location
2021-01-30 15:34:17 -07:00
Michael Miller
bd942bb644
Shorten tag method names
...
Plain `tags` is safe to use as a class method on the group.
2021-01-30 14:13:27 -07:00
Michael Miller
e093ec788e
Clean up tags method generation by moving it to another macro
2021-01-30 14:08:42 -07:00
Michael Miller
803a09464d
Initial work to pass along pre-set tags
...
Define pending examples and groups using this method.
2021-01-30 12:32:13 -07:00
Michael Miller
de779fdf61
Remove unecessary type name
2021-01-30 12:26:29 -07:00
Michael Miller
db877da984
Change tags to symbols
2021-01-30 12:03:38 -07:00
Michael Miller
5166cd7778
Fix case with no tags and some metadata
...
Simplify tag set construction code.
2021-01-30 12:01:49 -07:00
Michael Miller
467f0d3ad4
Pass along tags
2021-01-30 11:34:01 -07:00
Michael Miller
e77d6f0a4f
Change groups from metadata to tags
2021-01-30 11:21:49 -07:00
Michael Miller
8cf498c9e9
Switch to using tags instead of metadata
2021-01-30 11:13:30 -07:00
Michael Miller
a56b1e0eb1
Somewhat functional metadata unwrap
2021-01-30 01:16:26 -07:00
Michael Miller
466a388558
Initial code for example metadata
2021-01-30 00:40:59 -07:00
Michael Miller
5cccf5b4cb
Support example as block argument to let and subject
...
Surprisingly, RSpec supports this.
https://relishapp.com/rspec/rspec-core/v/3-10/docs/metadata/current-example
2021-01-22 23:00:17 -07:00
Michael Miller
b7ed4ec14c
Nest spec types
2021-01-21 00:03:39 -07:00
Michael Miller
ce6f77656a
Use ExpectationFailed instead of AssertionFailed
2021-01-20 21:38:34 -07:00
Michael Miller
98a29309ff
Remove assert methods
2021-01-20 21:36:18 -07:00
Michael Miller
153933b044
Add DSL and code to create around_each hooks
2021-01-16 16:47:40 -07:00
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