mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix typos and spelling
This commit is contained in:
parent
bc61e0e64f
commit
59ce312341
44 changed files with 113 additions and 113 deletions
|
@ -48,7 +48,7 @@ module Spectator
|
||||||
|
|
||||||
# Provides a means to configure how Spectator will run and report tests.
|
# Provides a means to configure how Spectator will run and report tests.
|
||||||
# A `ConfigBuilder` is yielded to allow changing the configuration.
|
# A `ConfigBuilder` is yielded to allow changing the configuration.
|
||||||
# NOTE: The configuration set here can be overriden
|
# NOTE: The configuration set here can be overridden
|
||||||
# with a `.spectator` file and command-line arguments.
|
# with a `.spectator` file and command-line arguments.
|
||||||
def configure(& : Config::Builder -> _) : Nil
|
def configure(& : Config::Builder -> _) : Nil
|
||||||
yield @@config_builder
|
yield @@config_builder
|
||||||
|
@ -56,7 +56,7 @@ module Spectator
|
||||||
|
|
||||||
# Random number generator for the test suite.
|
# Random number generator for the test suite.
|
||||||
# All randomly generated values should be pulled from this.
|
# All randomly generated values should be pulled from this.
|
||||||
# This provides reproducable results even though random values are used.
|
# This provides re-producible results even though random values are used.
|
||||||
# The seed for this random generator is controlled by `ConfigBuilder.seed=`.
|
# The seed for this random generator is controlled by `ConfigBuilder.seed=`.
|
||||||
def random
|
def random
|
||||||
config.random
|
config.random
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Spectator
|
||||||
# or nil if one isn't available.
|
# 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.
|
# 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.
|
# 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.
|
# If it were a struct, changes made to the value held by an instance may not be kept when passing it around.
|
||||||
|
|
|
@ -4,7 +4,7 @@ require "./label"
|
||||||
module Spectator
|
module Spectator
|
||||||
# Represents a block from a test.
|
# Represents a block from a test.
|
||||||
# This is typically captured by an `expect` macro.
|
# 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,
|
# The label should be a string recognizable by the user,
|
||||||
# or nil if one isn't available.
|
# or nil if one isn't available.
|
||||||
class Block(T) < Expression(T)
|
class Block(T) < Expression(T)
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "./dsl/*"
|
||||||
module Spectator
|
module Spectator
|
||||||
# Namespace containing methods representing the spec domain specific language.
|
# Namespace containing methods representing the spec domain specific language.
|
||||||
#
|
#
|
||||||
# Note: Documentation inside macros is kept to a minimuum to reduce generated code.
|
# Note: Documentation inside macros is kept to a minimum to reduce generated code.
|
||||||
# This also helps keep error traces small.
|
# This also helps keep error traces small.
|
||||||
# Documentation only useful for debugging is included in generated code.
|
# Documentation only useful for debugging is included in generated code.
|
||||||
module DSL
|
module DSL
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
# Completes a previously defined example group and pops it off the group stack.
|
# 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` symmetrically.
|
||||||
#
|
#
|
||||||
# See `Spec::Builder#end_group` for usage details.
|
# See `Spec::Builder#end_group` for usage details.
|
||||||
def end_group(*args)
|
def end_group(*args)
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Spectator::DSL
|
||||||
module Concise
|
module Concise
|
||||||
# Defines an example and input values in a shorter syntax.
|
# Defines an example and input values in a shorter syntax.
|
||||||
# The only arguments given to this macro are one or more assignments.
|
# 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 assignments will be available in the example code.
|
||||||
#
|
#
|
||||||
# If the code block is omitted, then the example is skipped (marked as not implemented).
|
# If the code block is omitted, then the example is skipped (marked as not implemented).
|
||||||
#
|
#
|
||||||
|
|
|
@ -239,7 +239,7 @@ module Spectator::DSL
|
||||||
# expect("foo").to match(/foo|bar/)
|
# expect("foo").to match(/foo|bar/)
|
||||||
# expect("BAR").to match(/foo|bar/i)
|
# expect("BAR").to match(/foo|bar/i)
|
||||||
# expect(1 + 2).to match(3)
|
# 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 recommended here.
|
||||||
# expect({:foo, 5}).to match({Symbol, Int32})
|
# expect({:foo, 5}).to match({Symbol, Int32})
|
||||||
# ```
|
# ```
|
||||||
macro match(expected)
|
macro match(expected)
|
||||||
|
@ -368,7 +368,7 @@ module Spectator::DSL
|
||||||
# expect(pi).to be_close(3.14159265359, 0.0000001)
|
# expect(pi).to be_close(3.14159265359, 0.0000001)
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
# This is functionly equivalent to:
|
# This is functionally equivalent to:
|
||||||
# ```
|
# ```
|
||||||
# be_within(expected).of(delta)
|
# be_within(expected).of(delta)
|
||||||
# ```
|
# ```
|
||||||
|
@ -400,7 +400,7 @@ module Spectator::DSL
|
||||||
# Indicates that some value or set should start with another value.
|
# Indicates that some value or set should start with another value.
|
||||||
# This is typically used on a `String` or `Array` (any `Enumerable` works).
|
# This is typically used on a `String` or `Array` (any `Enumerable` works).
|
||||||
# The *expected* argument can be a `String`, `Char`, or `Regex`
|
# The *expected* argument can be a `String`, `Char`, or `Regex`
|
||||||
# when the actual type (being comapred against) is a `String`.
|
# when the actual type (being compared against) is a `String`.
|
||||||
# For `Enumerable` types, only the first item is inspected.
|
# For `Enumerable` types, only the first item is inspected.
|
||||||
# It is compared with the === operator,
|
# It is compared with the === operator,
|
||||||
# so that values, types, regular expressions, and others can be tested.
|
# 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.
|
# Indicates that some value or set should end with another value.
|
||||||
# This is typically used on a `String` or `Array` (any `Indexable` works).
|
# This is typically used on a `String` or `Array` (any `Indexable` works).
|
||||||
# The *expected* argument can be a `String`, `Char`, or `Regex`
|
# The *expected* argument can be a `String`, `Char`, or `Regex`
|
||||||
# when the actual type (being comapred against) is a `String`.
|
# when the actual type (being compared against) is a `String`.
|
||||||
# For `Indexable` types, only the last item is inspected.
|
# For `Indexable` types, only the last item is inspected.
|
||||||
# It is compared with the === operator,
|
# It is compared with the === operator,
|
||||||
# so that values, types, regular expressions, and others can be tested.
|
# 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.
|
# Indicates that some value or set should contain another value.
|
||||||
# This is typically used on a `String` or `Array` (any `Enumerable` works).
|
# This is typically used on a `String` or `Array` (any `Enumerable` works).
|
||||||
# The *expected* argument can be a `String` or `Char`
|
# The *expected* argument can be a `String` or `Char`
|
||||||
# when the actual type (being comapred against) is a `String`.
|
# when the actual type (being compared against) is a `String`.
|
||||||
# For `Enumerable` types, items are compared using the underying implementation.
|
# For `Enumerable` types, items are compared using the underlying implementation.
|
||||||
# In both cases, the `includes?` method is used.
|
# In both cases, the `includes?` method is used.
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
|
@ -475,8 +475,8 @@ module Spectator::DSL
|
||||||
# Indicates that some value or set should contain specific items.
|
# Indicates that some value or set should contain specific items.
|
||||||
# This is typically used on a `String` or `Array` (any `Enumerable` works).
|
# This is typically used on a `String` or `Array` (any `Enumerable` works).
|
||||||
# The *expected* argument can be a `String` or `Char`
|
# The *expected* argument can be a `String` or `Char`
|
||||||
# when the actual type (being comapred against) is a `String`.
|
# when the actual type (being compared against) is a `String`.
|
||||||
# For `Enumerable` types, items are compared using the underying implementation.
|
# For `Enumerable` types, items are compared using the underlying implementation.
|
||||||
# In both cases, the `includes?` method is used.
|
# In both cases, the `includes?` method is used.
|
||||||
#
|
#
|
||||||
# This is identical to `#contain`, but accepts an array (or enumerable type) instead of multiple arguments.
|
# 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.
|
# This is similar to `#contain`, but uses a different method for matching.
|
||||||
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
|
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
|
||||||
# The *expected* argument can be a `String` or `Char`
|
# The *expected* argument can be a `String` or `Char`
|
||||||
# when the actual type (being comapred against) is a `String`.
|
# when the actual type (being compared against) is a `String`.
|
||||||
# The `includes?` method is used for this case.
|
# The `includes?` method is used for this case.
|
||||||
# For `Enumerable` types, each item is inspected until one matches.
|
# 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.
|
# 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.
|
# This is similar to `#contain_elements`, but uses a different method for matching.
|
||||||
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
|
# Typically a `String` or `Array` (any `Enumerable` works) is checked against.
|
||||||
# The *expected* argument can be a `String` or `Char`
|
# The *expected* argument can be a `String` or `Char`
|
||||||
# when the actual type (being comapred against) is a `String`.
|
# when the actual type (being compared against) is a `String`.
|
||||||
# The `includes?` method is used for this case.
|
# The `includes?` method is used for this case.
|
||||||
# For `Enumerable` types, each item is inspected until one matches.
|
# 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.
|
# The === operator is used for this case, which allows for equality, type, regex, and other matches.
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Spectator
|
||||||
# such as whether it was successful and a description of the operation.
|
# such as whether it was successful and a description of the operation.
|
||||||
struct Expectation
|
struct Expectation
|
||||||
# Location of the expectation in source code.
|
# Location of the expectation in source code.
|
||||||
# This can be nil if the location isn't capturable,
|
# This can be nil if the location can't be captured,
|
||||||
# for instance using the *should* syntax or dynamically created expectations.
|
# for instance using the *should* syntax or dynamically created expectations.
|
||||||
getter! location : Location
|
getter! location : Location
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting
|
||||||
class DocumentFormatter < Formatter
|
class DocumentFormatter < Formatter
|
||||||
include Summary
|
include Summary
|
||||||
|
|
||||||
# Identation string.
|
# Indentation string.
|
||||||
private INDENT = " "
|
private INDENT = " "
|
||||||
|
|
||||||
# String used for groups and examples that don't have a name.
|
# String used for groups and examples that don't have a name.
|
||||||
|
|
|
@ -66,7 +66,7 @@ module Spectator::Formatting
|
||||||
# The *notification* will be an `ExampleNotification` type of object.
|
# The *notification* will be an `ExampleNotification` type of object.
|
||||||
#
|
#
|
||||||
# NOTE: Errors are normally considered failures,
|
# NOTE: Errors are normally considered failures,
|
||||||
# however `#example_error` is called instead if one occurs in an exmaple.
|
# however `#example_error` is called instead if one occurs in an example.
|
||||||
def example_failed(_notification)
|
def example_failed(_notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Instanciates a new harness and yields it.
|
# Instantiates a new harness and yields it.
|
||||||
# The `.current` harness is set to the new harness for the duration of the block.
|
# 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.
|
# `.current` is reset to the previous value (probably nil) afterwards, even if the block raises.
|
||||||
# The result of the block is returned.
|
# The result of the block is returned.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
# Identifier used in the spec.
|
# Identifier used in the spec.
|
||||||
# Signficant to the user.
|
# Significant to the user.
|
||||||
# When a label is a symbol, then it is referencing a type or method.
|
# 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.
|
# A label is nil when one can't be provided or captured.
|
||||||
alias Label = String | Symbol | Nil
|
alias Label = String | Symbol | Nil
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "./matchers/*"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Evaluates conditions on values and objects
|
# Evaluates conditions on values and objects
|
||||||
# to determine whether they satisify test criteria.
|
# to determine whether they satisfy test criteria.
|
||||||
module Matchers
|
module Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,7 +83,7 @@ module Spectator::Matchers
|
||||||
# The first array is the missing elements (present in expected, missing in actual).
|
# 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).
|
# The second array array is the extra elements (not present in expected, present in actual).
|
||||||
private def compare_arrays(expected_elements, actual_elements)
|
private def compare_arrays(expected_elements, actual_elements)
|
||||||
# Produce hashes where the array elements are the keys, and the values are the number of occurances.
|
# Produce hashes where the array elements are the keys, and the values are the number of occurrences.
|
||||||
expected_hash = expected_elements.group_by(&.itself).map { |k, v| {k, v.size} }.to_h
|
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
|
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.
|
# Expects two hashes, with values as counts for keys.
|
||||||
# Produces an array of differences with elements repeated if needed.
|
# Produces an array of differences with elements repeated if needed.
|
||||||
private def hash_count_difference(first, second)
|
private def hash_count_difference(first, second)
|
||||||
# Subtract the number of occurances from the other array.
|
# Subtract the number of occurrences from the other array.
|
||||||
# A duplicate hash is used here because the original can't be modified,
|
# A duplicate hash is used here because the original can't be modified,
|
||||||
# since it there's a two-way comparison.
|
# since it there's a two-way comparison.
|
||||||
#
|
#
|
||||||
# Then reject elements that have zero (or less) occurances.
|
# Then reject elements that have zero (or less) occurrences.
|
||||||
# Lastly, expand to the correct number of elements.
|
# Lastly, expand to the correct number of elements.
|
||||||
first.map do |element, count|
|
first.map do |element, count|
|
||||||
if second_count = second[element]?
|
if second_count = second[element]?
|
||||||
|
|
|
@ -67,7 +67,7 @@ module Spectator::Matchers
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if all attributes from the snapshot of them are satisified.
|
# Checks if all attributes from the snapshot of them are satisfied.
|
||||||
private def match?(snapshot)
|
private def match?(snapshot)
|
||||||
# Test that every attribute has the expected value.
|
# Test that every attribute has the expected value.
|
||||||
{% for attribute in ExpectedType.keys %}
|
{% for attribute in ExpectedType.keys %}
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"matches #{expected.label}"
|
"matches #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
expected.value === actual.value
|
expected.value === actual.value
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
actual.value === expected.value
|
actual.value === expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -32,7 +32,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not match #{expected.label}"
|
"#{actual.label} does not match #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -12,12 +12,12 @@ module Spectator::Matchers
|
||||||
"is in #{expected.label}"
|
"is in #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
expected.value.includes?(actual.value)
|
expected.value.includes?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -27,7 +27,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not in #{expected.label}"
|
"#{actual.label} is not in #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -12,12 +12,12 @@ module Spectator::Matchers
|
||||||
"compiles as #{Expected}"
|
"compiles as #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
Expected == typeof(actual.value)
|
Expected == typeof(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -27,7 +27,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not compile as #{Expected}"
|
"#{actual.label} does not compile as #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"is empty"
|
"is empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual_value = actual.value
|
actual_value = actual.value
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:empty?)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:empty?)
|
||||||
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
actual_value.empty?
|
actual_value.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -29,7 +29,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not empty"
|
"#{actual.label} is not empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"equals #{expected.label}"
|
"equals #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
expected.value == actual.value
|
expected.value == actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not equal #{expected.label}"
|
"#{actual.label} does not equal #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"greater than or equal to #{expected.label}"
|
"greater than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value >= expected.value
|
actual.value >= expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is less than #{expected.label}"
|
"#{actual.label} is less than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"greater than #{expected.label}"
|
"greater than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value > expected.value
|
actual.value > expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is less than or equal to #{expected.label}"
|
"#{actual.label} is less than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"has key #{expected.label}"
|
"has key #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual_value = actual.value
|
actual_value = actual.value
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:has_key?)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:has_key?)
|
||||||
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
actual_value.has_key?(expected.value)
|
actual_value.has_key?(expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -29,7 +29,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not have key #{expected.label}"
|
"#{actual.label} does not have key #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -35,7 +35,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -45,7 +45,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not have #{expected.label}"
|
"#{actual.label} does not have #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
@ -68,7 +68,7 @@ module Spectator::Matchers
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if all predicate methods from the snapshot of them are satisified.
|
# Checks if all predicate methods from the snapshot of them are satisfied.
|
||||||
private def match?(snapshot) : Bool
|
private def match?(snapshot) : Bool
|
||||||
# Test each predicate and immediately return false if one is false.
|
# Test each predicate and immediately return false if one is false.
|
||||||
{% for attribute in ExpectedType.keys %}
|
{% for attribute in ExpectedType.keys %}
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"has value #{expected.label}"
|
"has value #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual_value = actual.value
|
actual_value = actual.value
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:has_value?)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:has_value?)
|
||||||
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
actual_value.has_value?(expected.value)
|
actual_value.has_value?(expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -29,7 +29,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not have value #{expected.label}"
|
"#{actual.label} does not have value #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"is not equal to #{expected.label}"
|
"is not equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
expected.value != actual.value
|
expected.value != actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is equal to #{expected.label}"
|
"#{actual.label} is equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -10,12 +10,12 @@ module Spectator::Matchers
|
||||||
"is an instance of #{Expected}"
|
"is an instance of #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value.class == Expected
|
actual.value.class == Expected
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -25,7 +25,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not an instance of #{Expected}"
|
"#{actual.label} is not an instance of #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"less than or equal to #{expected.label}"
|
"less than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value <= expected.value
|
actual.value <= expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is greater than #{expected.label}"
|
"#{actual.label} is greater than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"less than #{expected.label}"
|
"less than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value < expected.value
|
actual.value < expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is greater than or equal to #{expected.label}"
|
"#{actual.label} is greater than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"is nil"
|
"is nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value.nil?
|
actual.value.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not nil"
|
"#{actual.label} is not nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -12,12 +12,12 @@ module Spectator::Matchers
|
||||||
"matches #{expected.label}"
|
"matches #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value === expected.value
|
actual.value === expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -27,7 +27,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not match #{expected.label}"
|
"#{actual.label} does not match #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -41,7 +41,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -51,7 +51,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not #{expected.label}"
|
"#{actual.label} is not #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
@ -74,7 +74,7 @@ module Spectator::Matchers
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks if all predicate methods from the snapshot of them are satisified.
|
# Checks if all predicate methods from the snapshot of them are satisfied.
|
||||||
private def match?(snapshot)
|
private def match?(snapshot)
|
||||||
# Test each predicate and immediately return false if one is false.
|
# Test each predicate and immediately return false if one is false.
|
||||||
{% for attribute in ExpectedType.keys %}
|
{% for attribute in ExpectedType.keys %}
|
||||||
|
|
|
@ -27,12 +27,12 @@ module Spectator::Matchers
|
||||||
RangeMatcher.new(expected)
|
RangeMatcher.new(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
expected.value.includes?(actual.value)
|
expected.value.includes?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -42,7 +42,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not in #{expected.label} (#{exclusivity})"
|
"#{actual.label} is not in #{expected.label} (#{exclusivity})"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"is #{expected.label}"
|
"is #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
value = expected.value
|
value = expected.value
|
||||||
if value.nil?
|
if value.nil?
|
||||||
|
@ -24,7 +24,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -34,7 +34,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not #{expected.label}"
|
"#{actual.label} is not #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,12 +11,12 @@ module Spectator::Matchers
|
||||||
"matches #{expected.label}"
|
"matches #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
!!(actual.value =~ expected.value)
|
!!(actual.value =~ expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not match #{expected.label}"
|
"#{actual.label} does not match #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"has size #{expected.label}"
|
"has size #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual_value = actual.value
|
actual_value = actual.value
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:size?)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:size?)
|
||||||
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
expected.value == actual_value.size
|
expected.value == actual_value.size
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -29,7 +29,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} does not have #{expected.label} elements"
|
"#{actual.label} does not have #{expected.label} elements"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
"is the same size as #{expected.label}"
|
"is the same size as #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual_value = actual.value
|
actual_value = actual.value
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:size?)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:size?)
|
||||||
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
expected.value.size == actual_value.size
|
expected.value.size == actual_value.size
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -29,7 +29,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not the same size as #{expected.label}"
|
"#{actual.label} is not the same size as #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -10,11 +10,11 @@ module Spectator::Matchers
|
||||||
# that is suitable for most matchers.
|
# that is suitable for most matchers.
|
||||||
# Matchers based on this class need to define `#match?` and `#failure_message`.
|
# Matchers based on this class need to define `#match?` and `#failure_message`.
|
||||||
# If the matcher can be negated,
|
# If the matcher can be negated,
|
||||||
# the `#failure_message_when_negated` method needs to be overriden.
|
# the `#failure_message_when_negated` method needs to be overridden.
|
||||||
# Additionally, the `#does_not_match?` method can be specified
|
# Additionally, the `#does_not_match?` method can be specified
|
||||||
# if there's custom behavior for negated matches.
|
# if there's custom behavior for negated matches.
|
||||||
# If the matcher operates on or has extra data that is useful for debug,
|
# If the matcher operates on or has extra data that is useful for debug,
|
||||||
# then the `#values` and `#negated_values` methods can be overriden.
|
# then the `#values` and `#negated_values` methods can be overridden.
|
||||||
# Finally, define a `#description` message that can be used for the one-liner "it" syntax.
|
# Finally, define a `#description` message that can be used for the one-liner "it" syntax.
|
||||||
abstract struct StandardMatcher < Matcher
|
abstract struct StandardMatcher < Matcher
|
||||||
# Actually performs the test against the expression (value or block).
|
# Actually performs the test against the expression (value or block).
|
||||||
|
@ -47,7 +47,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -55,7 +55,7 @@ module Spectator::Matchers
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private abstract def failure_message(actual : Expression(T)) : String forall T
|
private abstract def failure_message(actual : Expression(T)) : String forall T
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
@ -70,14 +70,14 @@ module Spectator::Matchers
|
||||||
raise "Negation with #{self.class} is not supported."
|
raise "Negation with #{self.class} is not supported."
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private abstract def match?(actual : Expression(T)) : Bool forall T
|
private abstract def match?(actual : Expression(T)) : Bool forall T
|
||||||
|
|
||||||
# If the expectation is negated, then this method is called instead of `#match?`.
|
# If the expectation is negated, then this method is called instead of `#match?`.
|
||||||
#
|
#
|
||||||
# The default implementation of this method is to invert the result of `#match?`.
|
# The default implementation of this method is to invert the result of `#match?`.
|
||||||
# If the matcher requires custom handling of negated matches,
|
# If the matcher requires custom handling of negated matches,
|
||||||
# then this method should be overriden.
|
# then this method should be overridden.
|
||||||
# Remember to override `#failure_message_when_negated` as well.
|
# Remember to override `#failure_message_when_negated` as well.
|
||||||
private def does_not_match?(actual : Expression(T)) : Bool forall T
|
private def does_not_match?(actual : Expression(T)) : Bool forall T
|
||||||
!match?(actual)
|
!match?(actual)
|
||||||
|
|
|
@ -102,12 +102,12 @@ module Spectator::Matchers
|
||||||
RegexMatcher.new(expected)
|
RegexMatcher.new(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
@truthy == !!actual.value
|
@truthy == !!actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -117,7 +117,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is #{negated_label}"
|
"#{actual.label} is #{negated_label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -16,12 +16,12 @@ module Spectator::Matchers
|
||||||
"is a #{Expected}"
|
"is a #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisfied with the expression given to it.
|
||||||
private def match?(actual : Expression(T)) : Bool forall T
|
private def match?(actual : Expression(T)) : Bool forall T
|
||||||
actual.value.is_a?(Expected)
|
actual.value.is_a?(Expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisfied.
|
||||||
#
|
#
|
||||||
# This is only called when `#match?` returns false.
|
# This is only called when `#match?` returns false.
|
||||||
#
|
#
|
||||||
|
@ -31,7 +31,7 @@ module Spectator::Matchers
|
||||||
"#{actual.label} is not a #{Expected}"
|
"#{actual.label} is not a #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisfied and is negated.
|
||||||
# This is essentially what would satisfy the matcher if it wasn't negated.
|
# This is essentially what would satisfy the matcher if it wasn't negated.
|
||||||
#
|
#
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
|
|
@ -6,11 +6,11 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# Matchers based on this class need to define `#match?` and `#failure_message`.
|
# Matchers based on this class need to define `#match?` and `#failure_message`.
|
||||||
# If the matcher can be negated,
|
# If the matcher can be negated,
|
||||||
# the `#failure_message_when_negated` method needs to be overriden.
|
# the `#failure_message_when_negated` method needs to be overridden.
|
||||||
# Additionally, the `#does_not_match?` method can be specified
|
# Additionally, the `#does_not_match?` method can be specified
|
||||||
# if there's custom behavior for negated matches.
|
# if there's custom behavior for negated matches.
|
||||||
# If the matcher operates on or has extra data that is useful for debug,
|
# If the matcher operates on or has extra data that is useful for debug,
|
||||||
# then the `#values` and `#negated_values` methods can be overriden.
|
# then the `#values` and `#negated_values` methods can be overridden.
|
||||||
# Finally, define a `#description` message that can be used for the one-liner "it" syntax.
|
# Finally, define a `#description` message that can be used for the one-liner "it" syntax.
|
||||||
#
|
#
|
||||||
# The failure messages should typically only contain the test expression labels.
|
# The failure messages should typically only contain the test expression labels.
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "json"
|
||||||
require "./example"
|
require "./example"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Information about the runtimes of examples.
|
# Information about the runtime of examples.
|
||||||
class Profile
|
class Profile
|
||||||
include Indexable(Example)
|
include Indexable(Example)
|
||||||
|
|
||||||
|
|
|
@ -38,13 +38,13 @@ class Object
|
||||||
::Spectator::Harness.current.report(expectation)
|
::Spectator::Harness.current.report(expectation)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Works the same as `#should` except that the condition check is postphoned.
|
# Works the same as `#should` except that the condition check is postponed.
|
||||||
# The expectation is checked after the example finishes and all hooks have run.
|
# The expectation is checked after the example finishes and all hooks have run.
|
||||||
def should_eventually(matcher, message = nil)
|
def should_eventually(matcher, message = nil)
|
||||||
::Spectator::Harness.current.defer { should(matcher, message) }
|
::Spectator::Harness.current.defer { should(matcher, message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Works the same as `#should_not` except that the condition check is postphoned.
|
# Works the same as `#should_not` except that the condition check is postponed.
|
||||||
# The expectation is checked after the example finishes and all hooks have run.
|
# The expectation is checked after the example finishes and all hooks have run.
|
||||||
def should_never(matcher, message = nil)
|
def should_never(matcher, message = nil)
|
||||||
::Spectator::Harness.current.defer { should_not(matcher, message) }
|
::Spectator::Harness.current.defer { should_not(matcher, message) }
|
||||||
|
|
|
@ -100,7 +100,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Completes a previously defined example group and pops it off the group stack.
|
# 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` symmetrically.
|
||||||
def end_group : Nil
|
def end_group : Nil
|
||||||
Log.trace { "End group: #{current}" }
|
Log.trace { "End group: #{current}" }
|
||||||
raise "Can't pop root group" if root?
|
raise "Can't pop root group" if root?
|
||||||
|
@ -164,14 +164,14 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Registers a new "after_suite" hook.
|
# Registers a new "after_suite" hook.
|
||||||
# The hook will be prepended to the list.
|
# The hook will be pre-pended to the list.
|
||||||
# A new hook will be created by passing args to `ExampleGroupHook.new`.
|
# A new hook will be created by passing args to `ExampleGroupHook.new`.
|
||||||
def after_suite(*args, **kwargs) : Nil
|
def after_suite(*args, **kwargs) : Nil
|
||||||
root.before_all(*args, **kwargs)
|
root.before_all(*args, **kwargs)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Registers a new "after_suite" hook.
|
# Registers a new "after_suite" hook.
|
||||||
# The hook will be prepended to the list.
|
# The hook will be pre-pended to the list.
|
||||||
# A new hook will be created by passing args to `ExampleGroupHook.new`.
|
# A new hook will be created by passing args to `ExampleGroupHook.new`.
|
||||||
def after_suite(*args, **kwargs, &block) : Nil
|
def after_suite(*args, **kwargs, &block) : Nil
|
||||||
root.after_all(*args, **kwargs, &block)
|
root.after_all(*args, **kwargs, &block)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue