Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
What's new
2
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mike Miller
Spectator
Commits
59ce3123
Verified
Commit
59ce3123
authored
Nov 28, 2021
by
Mike Miller
Browse files
Fix typos and spelling
parent
bc61e0e6
Pipeline
#417962216
passed with stages
in 2 minutes and 51 seconds
Changes
44
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/spectator.cr
View file @
59ce3123
...
...
@@ -48,7 +48,7 @@ module Spectator
# Provides a means to configure how Spectator will run and report tests.
# A `ConfigBuilder` is yielded to allow changing the configuration.
# NOTE: The configuration set here can be overriden
# NOTE: The configuration set here can be overrid
d
en
# with a `.spectator` file and command-line arguments.
def
configure
(
&
:
Config
::
Builder
->
_
)
:
Nil
yield
@@config_builder
...
...
@@ -56,7 +56,7 @@ module Spectator
# Random number generator for the test suite.
# All randomly generated values should be pulled from this.
# This provides reproduc
a
ble results even though random values are used.
# This provides re
-
produc
i
ble results even though random values are used.
# The seed for this random generator is controlled by `ConfigBuilder.seed=`.
def
random
config
.
random
...
...
src/spectator/abstract_expression.cr
View file @
59ce3123
...
...
@@ -8,7 +8,7 @@ module Spectator
# or nil if one isn't available.
#
# This base class is provided so that all generic sub-classes can be stored as this one type.
# The value of the expression can be retrieved by downcasting to the expected type with `#cast`.
# The value of the expression can be retrieved by down
-
casting to the expected type with `#cast`.
#
# NOTE: This is intentionally a class and not a struct.
# If it were a struct, changes made to the value held by an instance may not be kept when passing it around.
...
...
src/spectator/block.cr
View file @
59ce3123
...
...
@@ -4,7 +4,7 @@ require "./label"
module
Spectator
# Represents a block from a test.
# This is typically captured by an `expect` macro.
# It consists of a label and parameterless block.
# It consists of a label and parameter
-
less block.
# The label should be a string recognizable by the user,
# or nil if one isn't available.
class
Block
(
T
)
<
Expression
(
T
)
...
...
src/spectator/dsl.cr
View file @
59ce3123
...
...
@@ -3,7 +3,7 @@ require "./dsl/*"
module
Spectator
# Namespace containing methods representing the spec domain specific language.
#
# Note: Documentation inside macros is kept to a minimu
u
m to reduce generated code.
# Note: Documentation inside macros is kept to a minimum to reduce generated code.
# This also helps keep error traces small.
# Documentation only useful for debugging is included in generated code.
module
DSL
...
...
src/spectator/dsl/builder.cr
View file @
59ce3123
...
...
@@ -31,7 +31,7 @@ module Spectator::DSL
end
# Completes a previously defined example group and pops it off the group stack.
# Be sure to call `#start_group` and `#end_group` symmetically.
# Be sure to call `#start_group` and `#end_group` symmet
r
ically.
#
# See `Spec::Builder#end_group` for usage details.
def
end_group
(
*
args
)
...
...
src/spectator/dsl/concise.cr
View file @
59ce3123
...
...
@@ -7,7 +7,7 @@ module Spectator::DSL
module
Concise
# Defines an example and input values in a shorter syntax.
# The only arguments given to this macro are one or more assignments.
# The names in the assigments will be available in the example code.
# The names in the assig
n
ments will be available in the example code.
#
# If the code block is omitted, then the example is skipped (marked as not implemented).
#
...
...
src/spectator/dsl/matchers.cr
View file @
59ce3123
...
...
@@ -239,7 +239,7 @@ module Spectator::DSL
# expect("foo").to match(/foo|bar/)
# expect("BAR").to match(/foo|bar/i)
# expect(1 + 2).to match(3)
# expect(5).to match(Int32) # Using `#be_a` instead is recommened here.
# expect(5).to match(Int32) # Using `#be_a` instead is recommen
d
ed here.
# expect({:foo, 5}).to match({Symbol, Int32})
# ```
macro
match
(
expected
)
...
...
@@ -368,7 +368,7 @@ module Spectator::DSL
# expect(pi).to be_close(3.14159265359, 0.0000001)
# ```
#
# This is functionly equivalent to:
# This is function
al
ly equivalent to:
# ```
# be_within(expected).of(delta)
# ```
...
...
@@ -400,7 +400,7 @@ module Spectator::DSL
# Indicates that some value or set should start with another value.
# This is typically used on a `String` or `Array` (any `Enumerable` works).
# The *expected* argument can be a `String`, `Char`, or `Regex`
# when the actual type (being com
a
pred against) is a `String`.
# when the actual type (being comp
a
red against) is a `String`.
# For `Enumerable` types, only the first item is inspected.
# It is compared with the === operator,
# so that values, types, regular expressions, and others can be tested.
...
...
@@ -423,7 +423,7 @@ module Spectator::DSL
# Indicates that some value or set should end with another value.
# This is typically used on a `String` or `Array` (any `Indexable` works).
# The *expected* argument can be a `String`, `Char`, or `Regex`
# when the actual type (being com
a
pred against) is a `String`.
# when the actual type (being comp
a
red against) is a `String`.
# For `Indexable` types, only the last item is inspected.
# It is compared with the === operator,
# so that values, types, regular expressions, and others can be tested.
...
...
@@ -446,8 +446,8 @@ module Spectator::DSL
# Indicates that some value or set should contain another value.
# This is typically used on a `String` or `Array` (any `Enumerable` works).
# The *expected* argument can be a `String` or `Char`
# when the actual type (being com
a
pred against) is a `String`.
# For `Enumerable` types, items are compared using the underying implementation.
# when the actual type (being comp
a
red against) is a `String`.
# For `Enumerable` types, items are compared using the under
l
ying implementation.
# In both cases, the `includes?` method is used.
#
# Examples:
...
...
@@ -475,8 +475,8 @@ module Spectator::DSL
# Indicates that some value or set should contain specific items.
# This is typically used on a `String` or `Array` (any `Enumerable` works).
# The *expected* argument can be a `String` or `Char`
# when the actual type (being com
a
pred against) is a `String`.
# For `Enumerable` types, items are compared using the underying implementation.
# when the actual type (being comp
a
red against) is a `String`.
# For `Enumerable` types, items are compared using the under
l
ying implementation.
# In both cases, the `includes?` method is used.
#
# This is identical to `#contain`, but accepts an array (or enumerable type) instead of multiple arguments.
...
...
@@ -522,7 +522,7 @@ module Spectator::DSL
# This is similar to `#contain`, but uses a different method for matching.
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
# The *expected* argument can be a `String` or `Char`
# when the actual type (being com
a
pred against) is a `String`.
# when the actual type (being comp
a
red against) is a `String`.
# The `includes?` method is used for this case.
# For `Enumerable` types, each item is inspected until one matches.
# The === operator is used for this case, which allows for equality, type, regex, and other matches.
...
...
@@ -557,7 +557,7 @@ module Spectator::DSL
# This is similar to `#contain_elements`, but uses a different method for matching.
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
# The *expected* argument can be a `String` or `Char`
# when the actual type (being com
a
pred against) is a `String`.
# when the actual type (being comp
a
red against) is a `String`.
# The `includes?` method is used for this case.
# For `Enumerable` types, each item is inspected until one matches.
# The === operator is used for this case, which allows for equality, type, regex, and other matches.
...
...
src/spectator/expectation.cr
View file @
59ce3123
...
...
@@ -8,7 +8,7 @@ module Spectator
# such as whether it was successful and a description of the operation.
struct
Expectation
# Location of the expectation in source code.
# This can be nil if the location
is
n't captur
abl
e,
# This can be nil if the location
ca
n't
be
capture
d
,
# for instance using the *should* syntax or dynamically created expectations.
getter
!
location
:
Location
...
...
src/spectator/formatting/document_formatter.cr
View file @
59ce3123
...
...
@@ -9,7 +9,7 @@ module Spectator::Formatting
class
DocumentFormatter
<
Formatter
include
Summary
# Identation string.
# I
n
dentation string.
private
INDENT
=
" "
# String used for groups and examples that don't have a name.
...
...
src/spectator/formatting/formatter.cr
View file @
59ce3123
...
...
@@ -66,7 +66,7 @@ module Spectator::Formatting
# The *notification* will be an `ExampleNotification` type of object.
#
# NOTE: Errors are normally considered failures,
# however `#example_error` is called instead if one occurs in an ex
m
aple.
# however `#example_error` is called instead if one occurs in an exa
m
ple.
def
example_failed
(
_notification
)
end
...
...
src/spectator/harness.cr
View file @
59ce3123
...
...
@@ -52,7 +52,7 @@ module Spectator
end
end
# Instan
c
iates a new harness and yields it.
# Instan
t
iates a new harness and yields it.
# The `.current` harness is set to the new harness for the duration of the block.
# `.current` is reset to the previous value (probably nil) afterwards, even if the block raises.
# The result of the block is returned.
...
...
src/spectator/label.cr
View file @
59ce3123
module
Spectator
# Identifier used in the spec.
# Signficant to the user.
# Sign
i
ficant to the user.
# When a label is a symbol, then it is referencing a type or method.
# A label is nil when one can't be provided or captured.
alias
Label
=
String
|
Symbol
|
Nil
...
...
src/spectator/matchers.cr
View file @
59ce3123
...
...
@@ -2,7 +2,7 @@ require "./matchers/*"
module
Spectator
# Evaluates conditions on values and objects
# to determine whether they satis
i
fy test criteria.
# to determine whether they satisfy test criteria.
module
Matchers
end
end
src/spectator/matchers/array_matcher.cr
View file @
59ce3123
...
...
@@ -83,7 +83,7 @@ module Spectator::Matchers
# The first array is the missing elements (present in expected, missing in actual).
# The second array array is the extra elements (not present in expected, present in actual).
private
def
compare_arrays
(
expected_elements
,
actual_elements
)
# Produce hashes where the array elements are the keys, and the values are the number of occur
a
nces.
# Produce hashes where the array elements are the keys, and the values are the number of occur
re
nces.
expected_hash
=
expected_elements
.
group_by
(
&
.
itself
).
map
{
|
k
,
v
|
{
k
,
v
.
size
}
}.
to_h
actual_hash
=
actual_elements
.
group_by
(
&
.
itself
).
map
{
|
k
,
v
|
{
k
,
v
.
size
}
}.
to_h
...
...
@@ -96,11 +96,11 @@ module Spectator::Matchers
# Expects two hashes, with values as counts for keys.
# Produces an array of differences with elements repeated if needed.
private
def
hash_count_difference
(
first
,
second
)
# Subtract the number of occur
a
nces from the other array.
# Subtract the number of occur
re
nces from the other array.
# A duplicate hash is used here because the original can't be modified,
# since it there's a two-way comparison.
#
# Then reject elements that have zero (or less) occur
a
nces.
# Then reject elements that have zero (or less) occur
re
nces.
# Lastly, expand to the correct number of elements.
first
.
map
do
|
element
,
count
|
if
second_count
=
second
[
element
]?
...
...
src/spectator/matchers/attributes_matcher.cr
View file @
59ce3123
...
...
@@ -67,7 +67,7 @@ module Spectator::Matchers
{%
end
%}
end
# Checks if all attributes from the snapshot of them are satis
i
fied.
# Checks if all attributes from the snapshot of them are satisfied.
private
def
match?
(
snapshot
)
# Test that every attribute has the expected value.
{%
for
attribute
in
ExpectedType
.
keys
%}
...
...
src/spectator/matchers/case_matcher.cr
View file @
59ce3123
...
...
@@ -11,7 +11,7 @@ module Spectator::Matchers
"matches
#{
expected
.
label
}
"
end
# Checks whether the matcher is satis
i
fed with the expression given to it.
# Checks whether the matcher is satisf
i
ed with the expression given to it.
private
def
match?
(
actual
:
Expression
(
T
))
:
Bool
forall
T
expected
.
value
===
actual
.
value
end
...
...
@@ -22,7 +22,7 @@ module Spectator::Matchers
actual
.
value
===
expected
.
value
end
# Message displayed when the matcher isn't satis
i
fed.
# Message displayed when the matcher isn't satisf
i
ed.
#
# This is only called when `#match?` returns false.
#
...
...
@@ -32,7 +32,7 @@ module Spectator::Matchers
"
#{
actual
.
label
}
does not match
#{
expected
.
label
}
"
end
# Message displayed when the matcher isn't satis
i
fed and is negated.
# Message displayed when the matcher isn't satisf
i
ed and is negated.
# This is essentially what would satisfy the matcher if it wasn't negated.
#
# This is only called when `#does_not_match?` returns false.
...
...
src/spectator/matchers/collection_matcher.cr
View file @
59ce3123
...
...
@@ -12,12 +12,12 @@ module Spectator::Matchers
"is in
#{
expected
.
label
}
"
end
# Checks whether the matcher is satis
i
fed with the expression given to it.
# Checks whether the matcher is satisf
i
ed with the expression given to it.
private
def
match?
(
actual
:
Expression
(
T
))
:
Bool
forall
T
expected
.
value
.
includes?
(
actual
.
value
)
end
# Message displayed when the matcher isn't satis
i
fed.
# Message displayed when the matcher isn't satisf
i
ed.
#
# This is only called when `#match?` returns false.
#
...
...
@@ -27,7 +27,7 @@ module Spectator::Matchers
"
#{
actual
.
label
}
is not in
#{
expected
.
label
}
"
end
# Message displayed when the matcher isn't satis
i
fed and is negated.
# Message displayed when the matcher isn't satisf
i
ed and is negated.
# This is essentially what would satisfy the matcher if it wasn't negated.
#
# This is only called when `#does_not_match?` returns false.
...
...
src/spectator/matchers/compiled_type_matcher.cr
View file @
59ce3123
...
...
@@ -12,12 +12,12 @@ module Spectator::Matchers
"compiles as
#{
Expected
}
"
end
# Checks whether the matcher is satis
i
fed with the expression given to it.
# Checks whether the matcher is satisf
i
ed with the expression given to it.
private
def
match?
(
actual
:
Expression
(
T
))
:
Bool
forall
T
Expected
==
typeof
(
actual
.
value
)
end
# Message displayed when the matcher isn't satis
i
fed.
# Message displayed when the matcher isn't satisf
i
ed.
#
# This is only called when `#match?` returns false.
#
...
...
@@ -27,7 +27,7 @@ module Spectator::Matchers
"
#{
actual
.
label
}
does not compile as
#{
Expected
}
"
end
# Message displayed when the matcher isn't satis
i
fed and is negated.
# Message displayed when the matcher isn't satisf
i
ed and is negated.
# This is essentially what would satisfy the matcher if it wasn't negated.
#
# This is only called when `#does_not_match?` returns false.
...
...
src/spectator/matchers/empty_matcher.cr
View file @
59ce3123
...
...
@@ -11,7 +11,7 @@ module Spectator::Matchers
"is empty"
end
# Checks whether the matcher is satis
i
fed with the expression given to it.
# Checks whether the matcher is satisf
i
ed with the expression given to it.
private
def
match?
(
actual
:
Expression
(
T
))
:
Bool
forall
T
actual_value
=
actual
.
value
return
unexpected
(
actual_value
,
actual
.
label
)
unless
actual_value
.
responds_to?
(
:empty?
)
...
...
@@ -19,7 +19,7 @@ module Spectator::Matchers
actual_value
.
empty?
end
# Message displayed when the matcher isn't satis
i
fed.
# Message displayed when the matcher isn't satisf
i
ed.
#
# This is only called when `#match?` returns false.
#
...
...
@@ -29,7 +29,7 @@ module Spectator::Matchers
"
#{
actual
.
label
}
is not empty"
end
# Message displayed when the matcher isn't satis
i
fed and is negated.
# Message displayed when the matcher isn't satisf
i
ed and is negated.
# This is essentially what would satisfy the matcher if it wasn't negated.
#
# This is only called when `#does_not_match?` returns false.
...
...
src/spectator/matchers/equality_matcher.cr
View file @
59ce3123
...
...
@@ -11,12 +11,12 @@ module Spectator::Matchers
"equals
#{
expected
.
label
}
"
end
# Checks whether the matcher is satis
i
fed with the expression given to it.
# Checks whether the matcher is satisf
i
ed with the expression given to it.
private
def
match?
(
actual
:
Expression
(
T
))
:
Bool
forall
T
expected
.
value
==
actual
.
value
end
# Message displayed when the matcher isn't satis
i
fed.
# Message displayed when the matcher isn't satisf
i
ed.
#
# This is only called when `#match?` returns false.
#
...
...
@@ -26,7 +26,7 @@ module Spectator::Matchers
"
#{
actual
.
label
}
does not equal
#{
expected
.
label
}
"
end
# Message displayed when the matcher isn't satis
i
fed and is negated.
# Message displayed when the matcher isn't satisf
i
ed and is negated.
# This is essentially what would satisfy the matcher if it wasn't negated.
#
# This is only called when `#does_not_match?` returns false.
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment