Michael Miller
033f753dca
Initial implementation of one-liner "it" syntax
2019-01-02 13:24:30 -07:00
Michael Miller
0c3b3da2b3
Quickly implement #random_sample
by copy-pasting
...
This should be DRY'd up in the future.
2019-01-02 12:45:46 -07:00
Michael Miller
b7d3648256
Clarify that #let
can use expressions
2019-01-02 11:00:38 -07:00
Michael Miller
e6fd716586
Run around_each hooks in same context as example code
2019-01-01 17:58:54 -07:00
Michael Miller
050251b491
before_each and after_each hooks now run in example scope
...
The entire example hooks class hierarchy is no longer needed.
This is an easier implementation than originally planned.
However, this is probably slower than the other method because each hook
has to cast and check the example instance.
2019-01-01 17:51:55 -07:00
Michael Miller
aee3ead578
Revert "Pass current example to before_each and after_each hooks"
...
This reverts commit b5edb1e9f3
.
2019-01-01 17:48:07 -07:00
Michael Miller
b5edb1e9f3
Pass current example to before_each and after_each hooks
2019-01-01 16:56:23 -07:00
Michael Miller
abf7c8831c
Add getter for wrapped instance
2019-01-01 16:40:04 -07:00
Michael Miller
b53e1b60d8
Add BaseExampleHooks class
...
This is the first part in enabling before_each and after_each hooks to
access the example code's scope.
2019-01-01 16:33:07 -07:00
Michael Miller
e0273d660c
Display cause of errors
2018-12-27 15:47:29 -07:00
Michael Miller
c0be260f98
Ability to limit number of items sampled
2018-12-27 15:11:28 -07:00
Michael Miller
c1b27bb672
Rename "given" to "sample"
...
This falls in line with the `SampleValues` type.
It also frees up the keyword "given" to be used for something else.
2018-12-27 11:15:44 -07:00
Michael Miller
62549aae88
Functionality to retrieve all sample values
2018-12-13 14:30:11 -07:00
Michael Miller
c73af72c7f
Move formatter to config
2018-12-13 14:16:49 -07:00
Michael Miller
23368f6183
Structure for applying configuration
2018-12-13 13:50:59 -07:00
Michael Miller
9527427b45
Move error message output to another method
2018-12-12 15:33:54 -07:00
Michael Miller
38ec35dd29
Have the DSL builder produce a test suite
2018-12-12 15:27:40 -07:00
Michael Miller
6c5da5a703
Shuffle code around for runner
2018-12-12 15:22:56 -07:00
Michael Miller
c29748ede5
Restructuring how the test suite is driven
2018-12-12 11:48:08 -07:00
Michael Miller
6f5b03dc0f
Add top-level namespace docs
2018-12-10 16:08:25 -07:00
Michael Miller
4e0c821b8f
Add FinishedResult intermediary class
2018-12-10 14:07:14 -07:00
Michael Miller
9e004324c9
Remove shared elapsed time
...
Since PendingResult always returns zero, it's not necessary to store it.
2018-12-10 11:16:43 -07:00
Michael Miller
56e8f8978b
Detect errors in around_each
hooks
2018-12-07 23:28:30 -07:00
Michael Miller
4e57f6adca
Don't run after hooks if an error occurs
2018-12-07 23:01:02 -07:00
Michael Miller
4222603fea
Don't need reference to result anymore
2018-12-07 22:57:31 -07:00
Michael Miller
aeebbaa5b6
Raise error instead of failing test
...
If an error occurs in any hooks, raise it instead of failing the test.
2018-12-07 22:43:26 -07:00
Michael Miller
bd4d020d0f
Condense visible hook methods
2018-12-05 19:57:14 -07:00
Michael Miller
bd8df38ecd
Docs for RootExampleGroup
2018-11-23 23:54:54 -07:00
Michael Miller
fad3eba11f
Add docs for NestedExampleGroup
2018-11-20 14:04:14 -07:00
Michael Miller
c7963b70a3
Add docs for ExampleIterator
2018-11-20 11:51:47 -07:00
Michael Miller
f3feabb6e0
Reduce nesting of conditionals
2018-11-19 23:46:14 -07:00
Michael Miller
ee274dbebd
Add docs for ExampleGroup
2018-11-19 21:52:10 -07:00
Michael Miller
e79d8872ac
Cleanup indexer code
2018-11-19 19:41:51 -07:00
Michael Miller
072055d947
Change test wrapper to a struct
2018-11-17 00:14:14 -07:00
Michael Miller
d52be1ec50
Add docs for ExampleHooks
2018-11-16 13:56:43 -07:00
Michael Miller
c045305bd2
Add docs for result types
2018-11-16 09:48:35 -07:00
Michael Miller
f0204a32ea
Fix specs to work with new Expectation type
2018-11-14 02:15:55 -07:00
Michael Miller
35b59854ec
Move #eval to partial
2018-11-13 21:44:56 -07:00
Michael Miller
a3ac50d661
Update harness to match recent changes
2018-11-13 21:44:25 -07:00
Michael Miller
a66262d197
Rename ExpectationResults to ExampleExpectations
...
Update to use new Expectation type.
2018-11-13 15:59:51 -07:00
Michael Miller
b625cb69cf
Adopt partials to use new Expectation type
2018-11-13 14:17:37 -07:00
Michael Miller
718f24aef3
Adopt ValueMatcher to new Expectation type
2018-11-13 14:11:51 -07:00
Michael Miller
06ced9f799
Change Expectation to store the result
...
This removes Expectation::Result and uses Expectation and sub-types
instead.
Having two "Result" types is confusing.
2018-11-13 14:08:27 -07:00
Michael Miller
e38747eafd
Formatting
2018-11-13 10:08:56 -07:00
Michael Miller
6c882f9cae
Remove ExampleGroup#all_examples
...
Implement the same functionality with ExampleIterator.
2018-11-13 10:08:37 -07:00
Michael Miller
b5a18ad324
Implement example iterator
2018-11-13 10:06:43 -07:00
Michael Miller
0e1d87d8d4
Add docs for #it and #pending
2018-11-08 22:40:01 -07:00
Michael Miller
45230f3e67
Add docs for before, after, and around hooks
2018-11-08 13:31:50 -07:00
Michael Miller
cbfd14a88f
Add docs for #subject, #let, and #let!
2018-11-08 11:29:51 -07:00
Michael Miller
e480901cdc
Note about nested #given blocks
...
Remove unused and empty type method.
Crystal syntax doesn't allow methods where a generic type is expected.
2018-11-07 13:03:48 -07:00
Michael Miller
013f799c5e
Remove #include_examples placeholder
...
Will be re-added when it is implemented.
2018-11-07 12:58:47 -07:00
Michael Miller
3abb48fe53
Allow implicit subject to take arbitrary arguments
...
This allows easy construction of the subject when it has an initializer
with parameters.
2018-11-07 12:55:38 -07:00
Michael Miller
4e690e7906
Merge described class and implicit subject macros
...
These macros are only called once.
2018-11-07 12:53:22 -07:00
Michael Miller
665c202848
Removes #it_behaves_like placeholder
...
Will re-add this when it is implemented.
2018-11-07 12:49:10 -07:00
Michael Miller
3571d9463a
Remove #_spectator_given_collection macro
...
It is no longer needed since @type resolution isn't delayed.
2018-11-07 12:47:42 -07:00
Michael Miller
06743a181c
Move collection class out of given module
...
The collection would incorrectly have access to the `given` block's
context,
instead of just the parent context, like it should.
2018-11-07 12:33:49 -07:00
Michael Miller
69905c01f3
Add docs for #given
2018-11-07 12:26:47 -07:00
Michael Miller
bf03cf03ce
Add docs for #describe and #context
2018-11-06 14:05:41 -07:00
Michael Miller
0efaf9fa85
Formatting
2018-11-03 12:14:29 -06:00
Michael Miller
0a218b7e9f
Some initial documentation for StructureDSL
2018-11-03 12:13:53 -06:00
Michael Miller
f6d6c859e6
Add docs for example and matcher DSL
2018-11-02 20:48:36 -06:00
Michael Miller
7c21f1e3eb
Store user-friendly name of given variable
2018-11-02 18:11:46 -06:00
Michael Miller
61fe8e06d9
Change accessibility of children getter to public
2018-11-02 13:35:32 -06:00
Michael Miller
aea324a33b
Add docs for group builders and example factory
2018-10-30 16:49:01 -06:00
Michael Miller
ee4623b471
Remove redundant #add_child method
2018-10-30 16:21:19 -06:00
Michael Miller
eb8ce6ff92
Add docs to DSL and builder
2018-10-28 18:27:54 -06:00
Michael Miller
746a5da107
Dummy example shouldn't be used
2018-10-23 11:15:22 -06:00
Michael Miller
4e9cf44c2c
Add and update docs for internal module
2018-10-22 16:22:35 -06:00
Michael Miller
79392fbeff
Add note about sample value names
2018-10-22 16:22:11 -06:00
Michael Miller
152ad5a5bf
Change Entry to a private struct
2018-10-22 11:10:54 -06:00
Michael Miller
f8fa3e706d
Add #get_value method to automatically cast
2018-10-22 11:08:55 -06:00
Michael Miller
532a314441
Add methods to force failure
2018-10-19 21:09:17 -06:00
Michael Miller
686304f31d
Insert example failed exception
2018-10-19 20:58:14 -06:00
Michael Miller
9cf82928b7
Ensure harness is reset on error
2018-10-19 18:52:00 -06:00
Michael Miller
c48467f783
Slightly better wording and naming
2018-10-19 18:50:21 -06:00
Michael Miller
67e192edc6
Implement ExpectationResults specs and fix typo
2018-10-19 16:27:59 -06:00
Michael Miller
703a791f78
Formatting changes
2018-10-19 14:02:27 -06:00
Michael Miller
0892a073fe
Change Result to a class
...
This is to get around a segfault.
I'm unable to reproduce this in a simpler example at this time.
However, this can be worked around by changing from a struct to a class.
Relevant backtrace:
Invalid memory access (signal 11) at address 0x4
[0x4829f6] *CallStack::print_backtrace:Int32 +118
[0x46de7d] __crystal_sigfault_handler +61
[0x7fe6ec64b390] ???
[0x486df5] *String#==<String>:Bool +37
[0x509ac4] *Spectator::Expectations::ValueExpectationPartial(Int32) +52
[0x50a52e] *Spectator::Expectations::ValueExpectation(Int32, Int32) +94
[0x50acb2] *Spectator::Expectations::Expectation::Result +210
[0x4fcd9b] *Spectator::Expectations::ExpectationResults +635
[0x50c9eb]*Spec::ContainExpectation(Spectator::Expectations::Expectation::Result)+43
[0x4fcaea] *Spectator::Expectations::ExpectationResults +138
...
2018-10-19 13:04:51 -06:00
Michael Miller
7f4690b042
Secondary initializer for missing label
...
Label is set to actual/expected stringified value if omitted.
2018-10-18 21:52:00 -06:00
Michael Miller
9a77f8b7fd
Add specs for value expectation
...
Fix bug in expectation result actual message.
2018-10-18 17:54:43 -06:00
Michael Miller
df36331132
Workaround for Crystal compiler bug
...
See: https://github.com/crystal-lang/crystal/issues/4225
If there are no concrete implementations of a class, an "undefined
method" error is given for abstract methods.
2018-10-15 15:27:05 -06:00
Michael Miller
c77a85c97a
Flag to disable running tests
...
This is needed for testing Spectator.
2018-10-15 00:32:29 -06:00
Michael Miller
cd86687dfb
Handle negative indices
2018-10-14 19:33:38 -06:00
Michael Miller
155e9ec81a
Store example count instead of recalculating
2018-10-14 19:08:07 -06:00
Michael Miller
bcb68a5856
Implement example lookup by index
...
This will be used later for executing tests in random order.
2018-10-14 19:06:02 -06:00
Michael Miller
eade6873e4
Implement ExampleComponent#example_count
2018-10-14 18:37:54 -06:00
Michael Miller
467afd053c
Implement iterator version of ExampleGroup#each
2018-10-14 18:29:01 -06:00
Michael Miller
1a2cba79fc
Parent group can't be nil for nested group
2018-10-14 18:00:55 -06:00
Michael Miller
ab146c88c2
Bit of code cleanup
2018-10-14 17:43:33 -06:00
Michael Miller
bff6d463df
Root group builder should not inherit from nested
2018-10-14 17:40:37 -06:00
Michael Miller
30a45a24d3
Restructure to use a composite design pattern
...
Examples and example groups now have a common ancestor.
2018-10-14 17:10:12 -06:00
Michael Miller
2070d7816b
Root example group specialization
2018-10-14 14:28:05 -06:00
Michael Miller
3facf3af9d
Change "description" to "what" for consistency
2018-10-14 11:50:08 -06:00
Michael Miller
68412daec0
Remove unused code
2018-10-14 01:02:52 -06:00
Michael Miller
77f631205e
Break apart runnable example and document it
2018-10-11 10:16:48 -06:00
Michael Miller
34dce28663
Initial documentation and rework on runnable example
2018-10-10 16:57:43 -06:00
Michael Miller
81dce3df9a
Cleanup and document some example classes
2018-10-10 13:05:17 -06:00
Michael Miller
53831ab36a
Fix hook flags being nullable
2018-10-10 13:03:47 -06:00
Michael Miller
3e78f48d39
Pending examples weren't marked as finished
2018-10-09 14:53:51 -06:00
Michael Miller
d8223297af
Treat harness more like a facade
2018-10-09 14:41:22 -06:00