Michael Miller
8c6552a995
Add DSL for be_truthy
and be_falsey
2019-01-23 15:51:52 -07:00
Michael Miller
429c2d7302
Add #be_true and #be_false to DSL
2019-01-23 15:35:32 -07:00
Michael Miller
ed8fad2c97
Add documentation for pre- and post-conditions
2019-01-23 14:37:43 -07:00
Michael Miller
260e1884ab
Implement match
(regex) matcher
2019-01-19 14:40:14 -07:00
Michael Miller
419b1322bf
Create parameterless initializer for TypeMatcher
2019-01-19 14:28:52 -07:00
Michael Miller
e66c0abcfb
Change described_class
to a macro
2019-01-19 14:17:28 -07:00
Michael Miller
46875d7770
Implement be_a
matcher
2019-01-19 14:08:50 -07:00
Michael Miller
4a7167597b
Remove documentation for unsupported cases
...
Turns out the `case` keyword does some extra magic that isn't trivially
implemented.
2019-01-19 13:44:38 -07:00
Michael Miller
a3ee53ed33
Implement be
matcher
2019-01-19 13:29:10 -07:00
Michael Miller
6c8ec7953a
Add note about using pre- and post-conditions
2019-01-17 16:02:29 -07:00
Michael Miller
38202ff605
Initial addition of pre- and post-conditions
2019-01-09 16:17:33 -07:00
Michael Miller
ab90f946d9
Allow "it" syntax in #given block
2019-01-09 15:08:01 -07:00
Michael Miller
17039d44f0
Initial implementation of #given macro
2019-01-09 14:58:10 -07:00
Michael Miller
950fcd250c
Add other syntaxes for #expect method
...
Can now check multiple values in the same #expect call.
Can use method short-hand syntax (&.foo) in #expect call.
2019-01-09 13:59:42 -07:00
Michael Miller
d3bf5eb4b1
Add short-hand #is and #is_not macros
...
These can be used for the one-liner "it" syntax.
2019-01-09 11:28:31 -07:00
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
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
38ec35dd29
Have the DSL builder produce a test suite
2018-12-12 15:27:40 -07:00
Michael Miller
072055d947
Change test wrapper to a struct
2018-11-17 00:14:14 -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
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
79392fbeff
Add note about sample value names
2018-10-22 16:22:11 -06:00
Michael Miller
532a314441
Add methods to force failure
2018-10-19 21:09:17 -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
3035273e9a
Rework how expectations and matchers work together
2018-09-28 11:47:42 -06:00
Michael Miller
d670d96045
Remove extra assignment operations
2018-09-27 18:47:54 -06:00
Michael Miller
7484b92db9
Formatting
2018-09-27 17:50:50 -06:00
Michael Miller
77b4c71c2a
Reduce nesting by collapsing modules with ::
2018-09-27 16:20:55 -06:00
Michael Miller
562b544223
Capture expression string from expectations
...
This allows a string that the user had in source code instead of a resolved value.
This change requires storing a 'label' and changing expectation and matcher constructor methods to macros.
2018-09-24 22:51:26 -06:00
Michael Miller
ef7e0462cb
GivenExampleGroupBuilder produces group of groups
...
Now a group is created for each element in the collection.
A group to contain the sub-groups is returned.
2018-09-24 00:25:15 -06:00
Michael Miller
dcbca302dc
Fix values being wrapped twice
...
This simplifies some code.
2018-09-23 17:13:30 -06:00
Michael Miller
cf0c438a5d
Abstract away locals to SampleValues
2018-09-23 17:04:06 -06:00
Michael Miller
cddfe5591d
Move ValueWrapper and TypedValueWrapper to Internals
...
Trying to hide from top-level some inner-workings.
2018-09-23 16:23:26 -06:00
Michael Miller
7a6045a1f3
Change #it_behaves_like to a macro
2018-09-23 16:10:07 -06:00
Michael Miller
b3b8efdd59
Mark helper macros private
2018-09-23 16:07:58 -06:00
Michael Miller
70e37eeccf
DRY up DSL
2018-09-23 16:07:03 -06:00
Michael Miller
0f323666a0
Fix methods for adding hooks
2018-09-23 15:41:58 -06:00
Michael Miller
855a5f2239
Move hook storage to their own class
2018-09-23 15:26:19 -06:00
Michael Miller
57c9f2c58e
Copy/paste to reimplement pending examples
2018-09-23 14:53:32 -06:00
Michael Miller
56ae92a25d
Add symbol for getting local from #given
2018-09-23 14:45:36 -06:00
Michael Miller
3c31783fd7
Pass arguments directly onto initializer with splat
2018-09-23 14:45:14 -06:00
Michael Miller
03a8efd7f8
Create test instance when example is created
...
This exposes errors in the framework
instead of delaying them until the test runs.
2018-09-23 14:39:05 -06:00
Michael Miller
94e2f54713
Implement building groups and examples
2018-09-23 14:34:42 -06:00
Michael Miller
037fe604ea
Example group builder classes should build groups
...
It's implied in their name.
2018-09-23 13:40:16 -06:00
Michael Miller
d551cf6e1b
Add missing GivenExampleGroupBuilder class
2018-09-23 12:27:21 -06:00
Michael Miller
6bf07e3967
Collection for #given is now an array of ValueWrapper
2018-09-23 12:27:08 -06:00
Michael Miller
faf3bef05c
Fix typo
2018-09-23 12:21:10 -06:00
Michael Miller
fc1c0351cd
Must use class variables
2018-09-23 12:19:29 -06:00
Michael Miller
ab7087649d
Example wrappers need a top-level initializer
...
The default initializer made by the compiler takes no arguments.
Use this one to not create a default initializer.
2018-09-23 12:19:07 -06:00
Michael Miller
ecba0d00ec
Pass group to example initializer
2018-09-23 12:16:38 -06:00
Michael Miller
09184f4a2a
Group builder needs "what" as first arg
2018-09-23 12:15:53 -06:00
Michael Miller
0999cb2dbc
Use fully-qualified names
2018-09-23 12:05:19 -06:00
Michael Miller
9109fc30fd
Can pass types around (somewhat) at runtime
...
No need for extra factory classes.
2018-09-23 12:03:52 -06:00
Michael Miller
9ba3fc898b
More refatoring
2018-09-22 19:41:56 -06:00
Michael Miller
a1b5533504
Some initial work to cleanup the DSL builder
2018-09-22 15:15:29 -06:00
Michael Miller
a82076e2b7
Remove type from group macros
...
This value is never directly seen,
so it isn't necessary to support it.
2018-09-22 11:38:00 -06:00
Michael Miller
66ca06337d
Fix locals not being passed to child groups
2018-09-21 14:26:09 -06:00
Michael Miller
a9d4acda36
Pass locals to example and test wrapper initializer
...
The #initialize method is defined in each context/given/module
that needs to add a local.
This is an elegant (although possibly confusing) solution.
2018-09-21 14:03:09 -06:00
Michael Miller
39be62c511
Temp disable until I figure out how to reference wrapped example
2018-09-20 18:41:21 -06:00
Michael Miller
8b8981494d
Trying to get exaples to map to their given values
2018-09-19 23:00:17 -06:00
Michael Miller
4d601281f6
Delay example creation by using factories
...
The #given block functionality specifically needs this to create
multiple examples.
2018-09-19 21:58:32 -06:00
Michael Miller
bb7f036a82
Make Example#group abstract
...
Instead of passing parent group as an argument, define the group method
in the exapmle class created by the #it macro.
2018-09-19 21:50:51 -06:00
Michael Miller
0f7640411f
Use symbols instead of strings for hash lookups
2018-09-19 21:06:10 -06:00
Michael Miller
a28f512ae4
Some code for repeating examples in given blocks
2018-09-19 20:49:01 -06:00
Michael Miller
830aa7b43a
Structural code for enumerating given value sets
2018-09-19 20:00:26 -06:00
Michael Miller
2be9d65997
Add examples to group children
2018-09-19 19:32:59 -06:00
Michael Miller
d679c356fd
Move conditional into context macro
2018-09-19 19:29:33 -06:00
Michael Miller
fe81341e1a
Rename MAPPING to GROUPS - better name
2018-09-19 18:58:44 -06:00
Michael Miller
41c0d9abc7
Initial changes for DSL refactor
...
No examples are picked up right now.
2018-09-19 18:53:09 -06:00
Michael Miller
fa73bf3a60
Hide method to infer type of first in collection in given macro
...
This was a bit of a hack.
2018-09-15 23:38:07 -06:00
Michael Miller
80fbe89b4c
Track children in DSL
2018-09-15 16:58:59 -06:00
Michael Miller
a06ea6088c
Shorten GroupDefinitions to Definitions
2018-09-15 16:53:28 -06:00
Michael Miller
6ca4d8d2a6
Move matchers DSL into their own module
...
Moves the #eq method out of the global namespace.
2018-09-15 11:58:43 -06:00
Michael Miller
1ea06998e7
Move #expect from global namespace to example DSL
2018-09-15 11:30:45 -06:00
Michael Miller
967797428c
Move DSL to its own directory
2018-09-15 11:21:23 -06:00