Commit Graph

493 Commits

Author SHA1 Message Date
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
Michael Miller 7f58c52e43 Cleanup 2019-08-17 08:05:05 -06:00
Michael Miller 498635d288 Pass along a proc to generate the array
The "to_a" method is actually dynamically generated.
2019-08-17 08:00:16 -06:00
Michael Miller 43440d37b0 Explicit initializer with sample values
Not sure why it isn't getting the one from the module.
2019-08-17 07:59:32 -06:00
Michael Miller a59e38155e Defer collection evaluation until build 2019-08-17 07:51:29 -06:00
Michael Miller 34b5487e6f Pass along class type instead of collection 2019-08-15 17:38:54 -06:00
Michael Miller 01c4b78716 Move placeholder initializer up a level 2019-08-15 16:43:25 -06:00
Michael Miller 0cb77b3355 Add all-matcher to DSL 2019-08-12 14:07:13 -06:00
Michael Miller 848f80ddf8 Add block short-hand syntax support to change matcher 2019-08-11 13:16:40 -06:00
Michael Miller 2666f80653 Hackish fix for block short-hand syntax
Dunno when this broke or how it ever worked. 😐
2019-08-11 13:16:18 -06:00
Michael Miller 27436b4e09 Need to use fresh variables in this macro 2019-08-11 12:55:38 -06:00
Michael Miller 1d205b6ee9 Put test expression on its own line 2019-08-10 12:49:54 -06:00
Michael Miller 214b2e171e Refactor existing change matchers to use new format 2019-08-10 12:42:57 -06:00
Michael Miller 3e1ee7eb6d Initial code for basic change matcher 2019-08-10 11:21:14 -06:00
Michael Miller 85b7412436 Fix some more matcher errors 2019-08-09 15:14:00 -06:00
Michael Miller 751c15434b Help infer the block's return type 2019-08-09 11:29:53 -06:00
Michael Miller eef7e9ce3c Wrap expression and label in TestValue 2019-08-08 17:15:13 -06:00
Michael Miller 4665d5f68d Fix inconsistent naming for test expressions 2019-08-08 17:08:38 -06:00
Michael Miller f004912fc1 Value first, then label 2019-08-01 15:48:39 -06:00
Michael Miller 7e3b3cd999 Fix namespaces 2019-08-01 15:44:04 -06:00
Michael Miller 763a65beac Rename again
This naming is more appropriate since these types can be used for
expected and actual values.
2019-08-01 15:38:20 -06:00
Michael Miller dd69cec536 Should capture a block instead of a value 2019-08-01 15:22:45 -06:00
Michael Miller 28680fa849 Rename Actual types to be more "human" sounding 2019-08-01 15:22:18 -06:00
Michael Miller 79a095bb31 Use new style expectations and actuals in DSL 2019-08-01 15:00:56 -06:00
Michael Miller c7e6b82a9a Change wording around let variant
The value is set when the expression is run at program startup, not when
the test starts.
2019-07-19 23:10:22 +00:00
Michael Miller 98476057f5 Implement assignment variant of let keyword
Resolves #18
2019-07-19 16:44:00 -06:00
Michael Miller efde29c90e Add have_size_of matcher 2019-06-09 12:45:49 -06:00
Michael Miller bb2b834662 Add have_size matcher 2019-06-09 12:44:46 -06:00
Michael Miller 091cbaa81a Cleanup have_ variant by using a new matcher 2019-06-01 23:27:16 -06:00
Michael Miller 16bcce59ae Handle `have_` prefix for matcher 2019-06-01 23:14:58 -06:00
Michael Miller 45f0f7f6d1 Include predicate arguments in label 2019-06-01 23:06:39 -06:00
Michael Miller 7e73ec2fe1 Allow passing arguments to predicate matcher 2019-06-01 22:46:06 -06:00
Michael Miller ca564619ad Change example wrapper type to a class
Fixes issue #11.
Variables (defined with let) were getting re-created between the hooks 
and the example code.
This was due to a separate struct value being returned for each fetch to 
the wrapped example instance.
In turn, the wrappers for variables were reset for each fetch.
2019-06-01 20:10:08 -06:00
Michael Miller 01b5d71ad0 Fixed an issue where named subjects could crash the compiler
Received:

Nil assertion failed (NilAssertionError)
  from ???
  ...
Error: you've found a bug in the Crystal compiler. ...

for this code:

subject(point) { Point.new }
describe "#x" do
  subject { point.x }
end

Redefining subjects with a named subject broke.
This commit fixes that with a simply flip in the definitions.
2019-05-21 13:44:19 -06:00
Michael Miller 77307f6eb1 Split part of RangeMatcher off as CollectionMatcher
Use CollectionMatcher for `be_within`.
The `#of` method creates a RangeMatcher.
2019-05-16 18:20:08 -06:00
Michael Miller fa5c13df0e Remove min-max variation of be_within
Use `be_between(min, max)` instead.
This matches RSpec.
2019-05-16 18:09:21 -06:00
Michael Miller 0fc28241dd Add be_between matcher which is an alias of be_within 2019-05-14 21:50:09 -06:00
Michael Miller 2378594c5d Use reference matching for be() 2019-05-08 16:59:59 -06:00
Michael Miller 7168b26218 Remove regex matcher - use case matcher 2019-05-08 16:39:00 -06:00
Michael Miller 6d81e26298 Fix for issue #4 2019-05-08 15:22:32 -06:00
Michael Miller 29df8716de Fixes and tweaks for Crystal 0.28
Bump version to 0.5.1
2019-04-18 19:32:24 -06:00
Michael Miller 99926c775e Fix symbolic not working for short-hand it syntax 2019-04-06 15:21:37 -06:00
Michael Miller 12c71a25cd Merge branch 'master' of gitlab.com:arctic-fox/spectator 2019-04-05 23:53:55 -06:00
Michael Miller 53de72805b Add skip macro as alternative to pending 2019-04-05 20:07:04 -06:00
Michael Miller 7a0e28945a Merge branch 'master' of gitlab.com:arctic-fox/spectator 2019-04-03 18:20:24 -06:00
Michael Miller 31a2bbcebb random_sample should use Spectator's global random 2019-04-02 22:22:40 -06:00
Michael Miller 157fdb813c Fix doc regarding hook execution order 2019-04-02 19:46:32 -06:00
Michael Miller fef8715ce1 Allow it, pending, and xit to omit what 2019-03-31 20:56:08 -06:00
Michael Miller 58031e01c6 Missed a usage of yield that should be block 2019-03-31 18:53:40 -06:00
Michael Miller 60f50b6378 Add ability to name subjects 2019-03-31 12:53:00 -06:00
Michael Miller 27ec27a3f3 Add array matcher 2019-03-30 18:38:06 -06:00
Michael Miller cd60fae157 Add respond_to matcher 2019-03-28 23:20:32 -06:00
Michael Miller e87314be58 Use block instead of yield to insert block
The "yield" method produces `begin...end`.
The "block" method produces `do...end`, which is needed for this syntax.
2019-03-26 21:45:31 -06:00
Michael Miller 2da1f9dbbf Missed one 2019-03-26 18:05:08 -06:00
Michael Miller 007c0c7950 Fix "missing" variables caused by wrong macro syntax 2019-03-26 17:59:15 -06:00
Michael Miller 2ff9505766 Add filter to TestSuite 2019-03-25 11:35:39 -06:00
Michael Miller 244947a81d Wrap stringified block with back-ticks 2019-03-21 21:21:05 -06:00
Michael Miller 4a887bb906 Add DSL for expect_raises 2019-03-21 21:18:36 -06:00
Michael Miller f3ef2e561e Initial implementation of raise_error matcher 2019-03-21 21:10:16 -06:00
Michael Miller 72ccafb8b7 Pass subject to proc via partial 2019-03-21 21:09:46 -06:00
Michael Miller e552cbffd2 Fix DSL usage of BlockExpectationPartial 2019-03-19 21:20:23 -06:00
Michael Miller 33e3b5a811 Use {{yield}} only in methods
The {{yield}} expression wraps the block with "begin ... end".
For some reason classes and modules can be defined in a "begin ... end"
block, but that might change.
2019-03-10 06:42:51 -06:00
Michael Miller cdef7f9fa3 Use macro yield and remove &block when not needed 2019-03-03 19:24:56 -07:00
Michael Miller 1219b19d89 Support shorthand &.foo(ARGS) syntax 2019-02-28 15:40:04 -07:00
Michael Miller 619927b3e6 Forgot to swap label and expected in DSL 2019-02-28 15:22:14 -07:00
Michael Miller 847cc662bd Update docs
Mostly fixes around symbols for syntax.
Added some missing docs and updated incorrect or vague ones.
2019-02-17 23:01:43 -07:00
Michael Miller 8339784492 Add symbolic attribute to example components
This is used to determine whether a type or method is referenced.
2019-02-17 16:27:41 -07:00
Michael Miller ed01a95e67 Replace source file and line with source struct 2019-02-17 12:40:16 -07:00
Michael Miller ac5c2bbe47 Reorder source arguments and simplify 2019-02-14 16:19:49 -07:00
Michael Miller 61e92951ae Add source file and line number to expectations 2019-02-14 16:04:09 -07:00
Michael Miller 5913a4c18f Add source file and line number
The issue with nested macros losing their source location has been
fixed!
2019-02-14 15:41:26 -07:00
Michael Miller 55b655e90a Update naming and fresh variables 2019-02-10 01:20:30 -07:00
Michael Miller fc3a7285a0 Rename "wrapper" to test code/instance 2019-02-10 01:03:32 -07:00
Michael Miller e14e86a5f3 Add `have_value` matcher 2019-02-05 19:37:25 -07:00
Michael Miller 7698724241 Update old naming to new matcher name 2019-02-05 19:30:44 -07:00
Michael Miller c6b4e22666 Add `have_key` matcher 2019-02-05 12:47:50 -07:00
Michael Miller 6bfd15b7f9 Parameterless initializer that generates the label 2019-02-05 10:36:37 -07:00
Michael Miller 0e0b8f4ae2 Base PredicateMatcher off of Matcher
No need to store an expected value.
Matcher's initializer must be public.
2019-02-05 10:14:33 -07:00
Michael Miller 89208b8ed1 Implement predicate matcher
Took a trick I learned from `have_attributes` and applied it here.
2019-02-04 22:52:09 -07:00
Michael Miller 1c9cb41fa2 Add `have_attributes` matcher
This one is kind of magical.
2019-02-01 22:24:06 -07:00
Michael Miller 0c4ffdf587 Allow `have` matcher to take multiple values 2019-02-01 20:27:51 -07:00
Michael Miller 85b4e6894b Allow `contain` matcher to take multiple values 2019-02-01 19:43:42 -07:00
Michael Miller 5389a39231 Add DSL for `be_close` matcher 2019-02-01 19:10:28 -07:00
Michael Miller 4ea439622d Implement `have` matcher
This is very similar to the `contain` matcher.
I would have used `include` for the matcher name, but it is a keyword
that can't be used in this syntax.
2019-02-01 16:25:45 -07:00
Michael Miller f4ac7a3405 Add `contain` matcher 2019-01-31 23:06:00 -07:00
Michael Miller d0711f940d Add `end_with` matcher 2019-01-31 22:05:27 -07:00
Michael Miller 0a310cb243 Add `start_with` matcher 2019-01-31 16:43:43 -07:00
Michael Miller 46a6a4e51e Remove reference to short-hand for non-block macro 2019-01-28 16:58:36 -07:00
Michael Miller 30582f9a89 Add empty matcher to DSL 2019-01-26 17:04:46 -07:00
Michael Miller 028065ad26 Add #be_nil to DSL 2019-01-26 16:42:58 -07:00
Michael Miller abc321130a Add DSL for range matching 2019-01-25 13:20:38 -07:00
Michael Miller 154832e5c4 Add `be_an` variation of `be_a` 2019-01-25 11:21:41 -07:00
Michael Miller c31557e8ff Move everything in BeComparison to TruthyMatcher
This is to match RSpec's ability to use "be" by itself.
For instance: `expect(foo).to be`
2019-01-23 22:10:03 -07:00
Michael Miller 28c13cd175 Add `xit` to DSL 2019-01-23 21:57:16 -07:00
Michael Miller e746ede287 Add `specify` to DSL 2019-01-23 21:56:02 -07:00
Michael Miller 0c284b6713 Add other comparison matchers to DSL 2019-01-23 21:45:16 -07:00
Michael Miller b93ef1fd2d Initial structure for "be OP value" syntax 2019-01-23 17:17:45 -07:00
Michael Miller 57c15b9088 Split #expects macro 2019-01-23 16:48:12 -07:00
Michael Miller 78698d2de9 Can't support multiple arguments (expected values)
The macro would only "attach" `.to` to the last partial.
2019-01-23 16:43:59 -07:00
Michael Miller 17c66dd732 Split #expect macro
TIL Crystal supports macro overloading, the argument count must be
different.
2019-01-23 16:42:17 -07:00
Michael Miller 046d946669 Handle case of missing block body for #given better 2019-01-23 16:31:54 -07:00
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