Commit graph

872 commits

Author SHA1 Message Date
Michael Miller
4abf97139b Experimenting with auto-mocking methods 2019-08-26 21:06:06 -06:00
Michael Miller
a75ab04dd5 Update version to 0.8.2 2019-08-21 19:28:17 -06:00
Michael Miller
325af1f24e Workaround for Crystal issue
Fix for GitHub issue 1 - 
https://github.com/icy-arctic-fox/spectator/issues/1
Works around Crystal issue 7060 (6920) - 
https://github.com/crystal-lang/crystal/issues/7060

This should be reverted after it is fixed in the Crystal compiler.
2019-08-21 19:26:40 -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
b026668de2 Formatting 2019-08-12 14:17:23 -06:00
Michael Miller
46c775932a Negated all match is not supported 2019-08-12 14:17:04 -06:00
Michael Miller
0cb77b3355 Add all-matcher to DSL 2019-08-12 14:07:13 -06:00
Michael Miller
8520697efa Initial code for all-matcher 2019-08-12 14:05:14 -06:00
Michael Miller
4e15487a0f Add relative change matcher 2019-08-11 23:08:45 -06:00
Michael Miller
c19f442e6c Add #by modifier methods 2019-08-11 13:52:22 -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
5dfcad3cb4 Flip operands of != in case expected has custom logic 2019-08-11 12:40:27 -06:00
Michael Miller
e1a119639f Add change exact matcher 2019-08-11 12:39:33 -06:00
Michael Miller
3c539b3517 Fix require statements 2019-08-10 12:54:46 -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
a56d6762c0 Formatting 2019-08-10 11:38:13 -06:00
Michael Miller
535dc6e923 Add change.to variant 2019-08-10 11:37:19 -06:00
Michael Miller
59cf939536 Don't store initial value in matcher 2019-08-10 11:37:19 -06:00
Michael Miller
770100891c Add change.from variant 2019-08-10 11:36:38 -06:00
Michael Miller
946604b737 Add tests for override cases
Fix negated? method.
2019-08-10 11:34:16 -06:00
Michael Miller
24066c46a0 Allow MatchData to control whether they can be negated
Values are still negated, but message and matching status are not.
2019-08-10 11:27:15 -06:00
Michael Miller
3e1ee7eb6d Initial code for basic change matcher 2019-08-10 11:21:14 -06:00
Michael Miller
ede691dd6a Reorder methods to be in a more standard layout 2019-08-10 11:10:48 -06:00
Michael Miller
898ddcb616 Type annotations for #match? 2019-08-10 10:55:22 -06:00
Michael Miller
c4b886cad2 Add match data docs 2019-08-10 10:53:00 -06:00
Michael Miller
d5fd21702a Add matcher docs 2019-08-10 10:50:48 -06:00
Michael Miller
37c8dd0865 Stringify respond_to bools 2019-08-10 09:55:26 -06:00
Michael Miller
39f253952d Add docs and some more type annotations 2019-08-09 17:26:53 -06:00
Michael Miller
db4eaca291 Just assert the return value isn't nil 2019-08-09 17:21:12 -06:00
Michael Miller
efd0ab089d Define type annotations for match methods
Hopefully this speeds up some compilation.
2019-08-09 16:58:35 -06:00
Michael Miller
85b7412436 Fix some more matcher errors 2019-08-09 15:14:00 -06:00
Michael Miller
8fc3af075c Workaround for NoReturn type for block
Not sure if this will work for everything.
It seems that NoReturn shows up as ReturnType (generic) when the
compiler detects the block will raise.
2019-08-09 15:06:22 -06:00
Michael Miller
c47b47ade9 Fix most problems (hopefully) with ExceptionMatcher 2019-08-09 14:18:59 -06:00
Michael Miller
2251168631 Get inspection string of attribute values 2019-08-09 14:01:10 -06:00
Michael Miller
751c15434b Help infer the block's return type 2019-08-09 11:29:53 -06:00
Michael Miller
e763296c26 Remove inspection quotes from around output values 2019-08-09 11:23:10 -06:00
Michael Miller
0dfde61807 Fix method name matches? -> match? 2019-08-09 11:20:41 -06:00
Michael Miller
5a1dea8f72 Convert bools to strings for output 2019-08-09 11:20:29 -06:00
Michael Miller
3d86893f44 Resolve various duck-typing issues 2019-08-09 11:13:13 -06:00
Michael Miller
114bfa47c2 Genericize TestExpression and make value abstract
This seems to resolve issues with the compiler making unions of
unrelated test case types.
2019-08-09 11:12:15 -06:00
Michael Miller
569faa0a2b Various other fixes 2019-08-09 00:42:39 -06:00
Michael Miller
8b718f0bd0 Handle union case for expected value
When using both forms of the HaveMatcher - expected can be a Char,
String, or Regex. Regex is invalid for String#includes?.
I believe this might be a generics issue that was fixed recently in
Crystal.
2019-08-09 00:32:45 -06:00
Michael Miller
353e5f6886 Update formatting to use Tuple 2019-08-08 21:57:02 -06:00
Michael Miller
9dc5a999d1 Fix method name (copy/paste fail) 2019-08-08 21:52:33 -06:00
Michael Miller
3b1a5a1121 Fix various expectation type code 2019-08-08 21:52:05 -06:00
Michael Miller
21e10c1ef2 Fix expected value snapshot 2019-08-08 21:39:30 -06:00
Michael Miller
955311bb95 Don't force Enumerable expected type
Should duck type anyway.
2019-08-08 21:38:49 -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
2eb51b9c41 Fix type inference in TestValue 2019-08-08 17:05:44 -06:00
Michael Miller
1222e24836 Add missing methods to matchers
Fix matcher inheritance.
2019-08-08 17:03:47 -06:00
Michael Miller
9bffb30041 Refactor UnorderedArrayMatcher 2019-08-08 16:59:29 -06:00
Michael Miller
3ae16c6ec1 Refactor predicate and respond matchers
Add missing match? method to AttributesMatcher.
2019-08-08 16:47:27 -06:00
Michael Miller
520c738f6a Refactor RangeMatcher 2019-08-08 16:47:17 -06:00
Michael Miller
cbaa9a4c43 Refactor StartWithMatcher 2019-08-08 16:04:09 -06:00
Michael Miller
a3fa522bd4 Refactor TruthyMatcher 2019-08-08 15:59:31 -06:00
Michael Miller
badccad2fa Some more easy target refactors
EmptyMatcher should extend StandardMatcher.
2019-08-08 15:45:34 -06:00
Michael Miller
17aa472d92 Refactor HaveMatcher 2019-08-08 15:26:30 -06:00
Michael Miller
f1ebce7739 Refactor HaveKeyMatcher and HaveValueMatcher 2019-08-08 15:25:32 -06:00
Michael Miller
7cca43029e Refactor ExceptionMatcher 2019-08-08 14:20:21 -06:00
Michael Miller
72e5735106 Refactor EndWithMatcher 2019-08-07 00:08:32 -06:00
Michael Miller
f2f46418a3 Refactor collection matcher 2019-08-07 00:07:39 -06:00
Michael Miller
ec96bf2de2 Refactor AttributesMatcher to use new style 2019-08-06 23:35:36 -06:00
Michael Miller
6a317b7a21 Re-add ordering methods 2019-08-06 23:22:50 -06:00
Michael Miller
3314ce8579 Remove ExpectedActual utility class
Don't think this is needed anymore.
2019-08-06 23:21:08 -06:00
Michael Miller
98b2cbc9cb Fix type inference 2019-08-06 23:20:23 -06:00
Michael Miller
436c10cad6 Simplify match data values by using named tuples 2019-08-06 23:13:33 -06:00
Michael Miller
e7b19ee591 Insert StandardMatcher into Matcher hierarchy
This is to remove all the unused abstract methods.
2019-08-06 22:33:13 -06:00
Michael Miller
ab147d00fb Cleanup match methods 2019-08-06 22:18:05 -06:00
Michael Miller
13fad5081b Initial refactor of ArrayMatcher 2019-08-06 21:56:33 -06:00
Michael Miller
044202e606 Use inspect instead of to_s for value reporting 2019-08-06 21:55:22 -06:00
Michael Miller
5cc735368c Update comparison matchers 2019-08-01 21:17:24 -06:00
Michael Miller
42b8fe471f Fix some includes and a dangling old file 2019-08-01 16:37:19 -06:00
Michael Miller
11600a2f8d Simplify more matchers that are easy targets 2019-08-01 16:35:02 -06:00
Michael Miller
16a2204a2d Simplify CaseMatcher by using new matcher refactoring 2019-08-01 16:17:39 -06:00
Michael Miller
c75fba8076 Change visibility to private 2019-08-01 16:17:12 -06:00
Michael Miller
4b59dcf142 Pass actual value to failure message methods and values 2019-08-01 16:02:28 -06:00
Michael Miller
f63697b019 Update ValueMatcher to use Matcher's methods 2019-08-01 15:59:29 -06:00
Michael Miller
114a4077f3 Fix parameters on LabeledValue 2019-08-01 15:58:48 -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
99d8f2a845 Use TestValue instead of custom LabeledValue 2019-08-01 15:40:46 -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
96c271cf33 No need to shout 2019-08-01 14:46:47 -06:00
Michael Miller
ba1c37b142 Fix macro 2019-08-01 14:46:13 -06:00
Michael Miller
10cf7bbb77 Update Expectation to use new MatchData 2019-08-01 14:05:27 -06:00
Michael Miller
96f2888b88 Fully implement match methods
Add placeholders for matcher values.
2019-08-01 14:05:05 -06:00
Michael Miller
acd01a23e6 Re-add MatchData and variants 2019-08-01 14:04:00 -06:00
Michael Miller
ae43c930bf Replace MatchDataValue types with a single LabeledValue 2019-08-01 13:49:08 -06:00
Michael Miller
43ba4de202 Merge branch 'matcher-refactor-split' into matcher-refactor 2019-07-31 21:04:28 -06:00
Michael Miller
3a7dc7299a Rewrite ExpectationPartial and remove sub-types
The partial now contains the actual and source.
It also calls the correct match method on the matcher and constructs an 
expectation (which needs to be updated).
2019-07-31 20:11:30 -06:00
Michael Miller
42b916bdf7 New "actual" types 2019-07-31 20:01:39 -06:00
Michael Miller
e95c81f46e Pass negation flag to matcher
Some matchers need to know if they're negated to work properly and can't
be simply negated afterwards.
2019-07-30 16:19:27 -06:00
Michael Miller
ab1c0269e0 Remove DummyMatchData
No longer needed since MatchData was changed to non-abstract.
2019-07-30 16:13:48 -06:00
Michael Miller
a06247bb1e Change MatchData to Expectation
After including negation into matcher logic, these types are equivalent.
2019-07-30 16:11:55 -06:00
Michael Miller
27f844ce25 Remove abstract base match data
Switching to a single type that holds the data.Trying to reduce the
number of types and generic types generated.
2019-07-30 16:08:06 -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
3c7bbe4e42 Allow actual collection to be enumerable, not just array
Force expected collection to an array.
2019-06-12 15:36:09 -06:00
Michael Miller
19d52ff02b Add unordered array matcher 2019-06-12 15:35:33 -06:00
Michael Miller
3ff5b2ac5e Capture element type 2019-06-12 13:58:11 -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
36f53d82db Use label from matcher macro 2019-06-01 22:53:12 -06:00
Michael Miller
7e73ec2fe1 Allow passing arguments to predicate matcher 2019-06-01 22:46:06 -06:00
Michael Miller
cc4ab9756a Fix the actual type reported by the type matcher
If an object has a difference between compiler and runtime type, then 
the type matcher would report the actual as the compiler type.
The match would be successful, because it uses the runtime check 
(is_a?).
2019-06-01 20:48:24 -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
f53bc26c28 Add ReferenceMatcher type 2019-05-08 16:59:36 -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
8480349ff0 Force after_all hooks to run on fail-fast
Resolves issues #2.
2019-04-22 20:29:02 -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
53bfcc25ef Add Ameba and address code linting issues 2019-04-06 17:19:02 -06:00
Michael Miller
99926c775e Fix symbolic not working for short-hand it syntax 2019-04-06 15:21:37 -06:00
Michael Miller
365bd1ec2f Fix failing tests 2019-04-06 12:48:41 -06:00
Michael Miller
dd943c9046 Fix botched copy-paste 2019-04-06 12:42:08 -06:00
Michael Miller
659174c66a Add placeholder negate method 2019-04-06 12:41:38 -06:00
Michael Miller
12c71a25cd Merge branch 'master' of gitlab.com:arctic-fox/spectator 2019-04-05 23:53:55 -06:00
Michael Miller
9650d7f9c1 Use inspect on values in to_s
The to_json method calls to_s, which results in incorrect output.
2019-04-05 23:13:23 -06:00
Michael Miller
53de72805b Add skip macro as alternative to pending 2019-04-05 20:07:04 -06:00
Michael Miller
c18d9c4ffd Allow top-level context macro 2019-04-05 18:38:57 -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
675ef60f9d Consistent version 2019-04-02 22:05:27 -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
785f2ef2dd Missing doc 2019-03-30 18:38:06 -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
44e681ae79 Change JSON timing values to seconds as a float 2019-03-25 16:56:38 -06:00
Michael Miller
4eb8eadd9e Add profile info to JSON output 2019-03-25 16:54:27 -06:00
Michael Miller
df6431f2d7 Add profile summary to TAP output 2019-03-25 16:49:57 -06:00
Michael Miller
291a927f1e Add profile information to suite summary 2019-03-25 16:44:20 -06:00
Michael Miller
34b0399654 Use example_runtime instead of total runtime
This fixes the issue where < 10 examples in profile showed less than 
100% total time.
2019-03-25 16:31:01 -06:00
Michael Miller
72aa72781a Move human time to its own type to share it 2019-03-25 16:15:00 -06:00
Michael Miller
aabc25ad4f Change formatters to take nillable profile 2019-03-25 16:05:38 -06:00
Michael Miller
6dd4c4bc2f Add Profile class 2019-03-25 15:54:51 -06:00
Michael Miller
a02e2ff701 Add profile config option 2019-03-25 12:26:45 -06:00
Michael Miller
35b887f8f0 Add placeholders for profile functionality 2019-03-25 12:13:11 -06:00
Michael Miller
2d88097c04 Re-implement filters in command-line arguments 2019-03-25 11:39:27 -06:00
Michael Miller
2ff9505766 Add filter to TestSuite 2019-03-25 11:35:39 -06:00
Michael Miller
49c396714e Revert 29279e1
Update Runner to not use Iterable#each
2019-03-25 11:29:20 -06:00
Michael Miller
3654b2473b Add example filter to config 2019-03-25 11:17:53 -06:00
Michael Miller
d1767ebb7a Add CompositeExampleFilter 2019-03-25 11:10:27 -06:00
Michael Miller
481319c097 Add NullExampleFilter 2019-03-25 10:58:49 -06:00
Michael Miller
a3c1892465 Move example filters from === to their own types 2019-03-25 10:51:50 -06:00
Michael Miller
b2ab579d8a Remove --pattern option
This can be handled by calling `crystal spec`.
2019-03-25 10:51:20 -06:00
Michael Miller
3787d4fc28 Cleanup cli arguments by breaking apart parser.on calls 2019-03-25 09:41:36 -06:00
Michael Miller
bf2c62b7e8 Initial work on filter criteria 2019-03-23 22:38:44 -06:00
Michael Miller
8c66f8df34 Add ExampleFilter class 2019-03-23 22:03:49 -06:00
Michael Miller
2f8b4761de Make Example comparable against names and sources
This will be needed for filtering examples.
2019-03-23 21:40:13 -06:00
Michael Miller
4f3ca20741 Parse source strings 2019-03-23 20:47:41 -06:00
Michael Miller
268db53bf8 Use more sensible label for non-labeled procs 2019-03-23 20:23:31 -06:00
Michael Miller
ac85fac968 Unprotect build method 2019-03-23 20:22:09 -06:00
Michael Miller
d04db7bf68 Add specialized should/should_not methods for procs 2019-03-23 20:20:15 -06:00
Michael Miller
102105911c Fix "should" syntax 2019-03-23 20:15:35 -06:00
Michael Miller
ebfec8058e Hide getters from external types 2019-03-23 20:01:42 -06:00
Michael Miller
bc8b608789 Perform in-place shuffle 2019-03-23 19:58:45 -06:00
Michael Miller
7b1b65f553 Implement --order flag to match RSpec 2019-03-23 19:56:00 -06:00
Michael Miller
b6453d135a Implement random test order execution 2019-03-23 19:43:41 -06:00
Michael Miller
29279e1812 Implement Iterable 2019-03-23 19:42:32 -06:00
Michael Miller
d0ba2c5400 Config stores the RNG instead of a seed 2019-03-23 19:42:19 -06:00
Michael Miller
21a0f78219 Implement random generator and seed 2019-03-23 19:18:29 -06:00
Michael Miller
5d95e1b5dd Save built-up config 2019-03-23 18:35:15 -06:00
Michael Miller
57271d5f4b Implement --no-color option 2019-03-23 18:24:11 -06:00
Michael Miller
a7d8d35a06 Implement option for JUnit test output 2019-03-23 17:01:03 -06:00
Michael Miller
ef8b773787 Support multiple formatters at once 2019-03-23 17:00:21 -06:00
Michael Miller
f1873238cd Add expectation values to failure 2019-03-23 16:42:53 -06:00
Michael Miller
50929c6666 Use standard status text 2019-03-23 16:34:54 -06:00
Michael Miller
ff20fbe232 Cleanup top-level formatting code 2019-03-23 16:28:36 -06:00
Michael Miller
3fbe6a2760 Implement Java naming 2019-03-23 16:27:51 -06:00
Michael Miller
93368503e6 Cleanup JUnit test case hierarchy 2019-03-23 16:07:40 -06:00
Michael Miller
3776cd917e Initial code for JUnit output 2019-03-23 15:31:53 -06:00
Michael Miller
4890cafefa Ability to enumerate each result in report 2019-03-23 14:44:00 -06:00
Michael Miller
4d38bf3ab2 Add secondary initializer 2019-03-23 14:38:51 -06:00