mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Merge branch 'crystal-0.31.0' into 'master'
Crystal 0.31.0 See merge request arctic-fox/spectator!19
This commit is contained in:
commit
35928133a9
63 changed files with 177 additions and 151 deletions
|
@ -14,10 +14,17 @@ before_script:
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
script:
|
script:
|
||||||
- crystal spec
|
- crystal spec --error-on-warnings
|
||||||
- bin/ameba
|
- bin/ameba
|
||||||
- crystal tool format --check
|
- crystal tool format --check
|
||||||
|
|
||||||
|
nightly:
|
||||||
|
image: "crystallang/crystal:nightly"
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- crystal spec --error-on-warnings
|
||||||
|
- crystal tool format --check
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
name: spectator
|
name: spectator
|
||||||
version: 0.8.2
|
version: 0.8.3
|
||||||
description: |
|
description: |
|
||||||
A feature-rich spec testing framework for Crystal with similarities to RSpec.
|
A feature-rich spec testing framework for Crystal with similarities to RSpec.
|
||||||
|
|
||||||
authors:
|
authors:
|
||||||
- Michael Miller <icy.arctic.fox@gmail.com>
|
- Michael Miller <icy.arctic.fox@gmail.com>
|
||||||
|
|
||||||
crystal: 0.30.1
|
crystal: 0.31.0
|
||||||
|
|
||||||
license: MIT
|
license: MIT
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ describe Spectator::DSL::SampleExampleGroupBuilder do
|
||||||
factory = Spectator::DSL::ExampleFactory.new(SpyExample)
|
factory = Spectator::DSL::ExampleFactory.new(SpyExample)
|
||||||
symbol = :test
|
symbol = :test
|
||||||
count = 3
|
count = 3
|
||||||
expected = Array.new(SAMPLE_VALUES_COLLECTION.size * count) { |i| SAMPLE_VALUES_COLLECTION[i / count] }
|
expected = Array.new(SAMPLE_VALUES_COLLECTION.size * count) { |i| SAMPLE_VALUES_COLLECTION[i // count] }
|
||||||
create_proc = ->(s : SampleValueCollection) { s.create }
|
create_proc = ->(s : SampleValueCollection) { s.create }
|
||||||
builder = Spectator::DSL::SampleExampleGroupBuilder.new("foobar", SampleValueCollection, create_proc, "value", symbol)
|
builder = Spectator::DSL::SampleExampleGroupBuilder.new("foobar", SampleValueCollection, create_proc, "value", symbol)
|
||||||
count.times { builder.add_child(factory) }
|
count.times { builder.add_child(factory) }
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
# Example that always raises an exception.
|
# Example that always raises an exception.
|
||||||
class ErroredExample < Spectator::RunnableExample
|
class ErroredExample < Spectator::RunnableExample
|
||||||
# Dummy description.
|
# Dummy description.
|
||||||
def what
|
def what : Symbol | String
|
||||||
"ERROR"
|
"ERROR"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source.
|
# Dummy source.
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new(__FILE__, __LINE__)
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy symbolic flag.
|
# Dummy symbolic flag.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
# Example that always fails.
|
# Example that always fails.
|
||||||
class FailingExample < Spectator::RunnableExample
|
class FailingExample < Spectator::RunnableExample
|
||||||
# Dummy description.
|
# Dummy description.
|
||||||
def what
|
def what : Symbol | String
|
||||||
"FAIL"
|
"FAIL"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source.
|
# Dummy source.
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new(__FILE__, __LINE__)
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy symbolic flag.
|
# Dummy symbolic flag.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,17 @@ class PassingExample < Spectator::RunnableExample
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy description.
|
# Dummy description.
|
||||||
def what
|
def what : Symbol | String
|
||||||
"PASS"
|
"PASS"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source.
|
# Dummy source.
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new(__FILE__, __LINE__)
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy symbolic flag.
|
# Dummy symbolic flag.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
@symbolic
|
@symbolic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
# This is useful for capturing what's going on when an event is running.
|
# This is useful for capturing what's going on when an event is running.
|
||||||
class SpyExample < Spectator::RunnableExample
|
class SpyExample < Spectator::RunnableExample
|
||||||
# Dummy description.
|
# Dummy description.
|
||||||
def what
|
def what : Symbol | String
|
||||||
"SPY"
|
"SPY"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source.
|
# Dummy source.
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new(__FILE__, __LINE__)
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy symbolic flag.
|
# Dummy symbolic flag.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
require "./spec_helper"
|
require "./spec_helper"
|
||||||
|
|
||||||
class ConcretePendingExample < Spectator::PendingExample
|
class ConcretePendingExample < Spectator::PendingExample
|
||||||
def what
|
def what : Symbol | String
|
||||||
"PENDING_TEST_EXAMPLE"
|
"PENDING_TEST_EXAMPLE"
|
||||||
end
|
end
|
||||||
|
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new(__FILE__, __LINE__)
|
::Spectator::Source.new(__FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the example satisfies the filter.
|
# Checks whether the example satisfies the filter.
|
||||||
def includes?(example)
|
def includes?(example) : Bool
|
||||||
@filters.any?(&.includes?(example))
|
@filters.any?(&.includes?(example))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1457,7 +1457,7 @@ module Spectator::DSL
|
||||||
# Create a class derived from `RunnableExample` to run the test code.
|
# Create a class derived from `RunnableExample` to run the test code.
|
||||||
_spectator_example(Example%example, Test%example, ::Spectator::RunnableExample, {{what}}) do
|
_spectator_example(Example%example, Test%example, ::Spectator::RunnableExample, {{what}}) do
|
||||||
# Source where the example originated from.
|
# Source where the example originated from.
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1534,7 +1534,7 @@ module Spectator::DSL
|
||||||
# Create a class derived from `PendingExample` to skip the test code.
|
# Create a class derived from `PendingExample` to skip the test code.
|
||||||
_spectator_example(Example%example, Test%example, ::Spectator::PendingExample, {{what}}) do
|
_spectator_example(Example%example, Test%example, ::Spectator::PendingExample, {{what}}) do
|
||||||
# Source where the example originated from.
|
# Source where the example originated from.
|
||||||
def source
|
def source : ::Spectator::Source
|
||||||
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1650,7 +1650,7 @@ module Spectator::DSL
|
||||||
getter instance
|
getter instance
|
||||||
|
|
||||||
# Indicates whether the example references a method.
|
# Indicates whether the example references a method.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
{{what.is_a?(StringLiteral) && what.starts_with?('#') ? true : false}}
|
{{what.is_a?(StringLiteral) && what.starts_with?('#') ? true : false}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1658,7 +1658,7 @@ module Spectator::DSL
|
||||||
{{block.body}}
|
{{block.body}}
|
||||||
|
|
||||||
# Description for the test.
|
# Description for the test.
|
||||||
def what
|
def what : String | Symbol
|
||||||
{{what.is_a?(StringLiteral) ? what : what.stringify}}
|
{{what.is_a?(StringLiteral) ? what : what.stringify}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,17 +10,17 @@ module Spectator
|
||||||
# This class shouldn't be used, it's just to trick the compiler.
|
# This class shouldn't be used, it's just to trick the compiler.
|
||||||
private class DummyExample < RunnableExample
|
private class DummyExample < RunnableExample
|
||||||
# Dummy description.
|
# Dummy description.
|
||||||
def what
|
def what : Symbol | String
|
||||||
"DUMMY"
|
"DUMMY"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy symbolic flag.
|
# Dummy symbolic flag.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dummy source.
|
# Dummy source.
|
||||||
def source
|
def source : Source
|
||||||
Source.new(__FILE__, __LINE__)
|
Source.new(__FILE__, __LINE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,12 @@ module Spectator
|
||||||
# Base class for all types of examples.
|
# Base class for all types of examples.
|
||||||
# Concrete types must implement the `#run_impl, `#what`, `#instance`, and `#source` methods.
|
# Concrete types must implement the `#run_impl, `#what`, `#instance`, and `#source` methods.
|
||||||
abstract class Example < ExampleComponent
|
abstract class Example < ExampleComponent
|
||||||
|
@finished = false
|
||||||
|
|
||||||
# Indicates whether the example has already been run.
|
# Indicates whether the example has already been run.
|
||||||
getter? finished = false
|
def finished? : Bool
|
||||||
|
@finished
|
||||||
|
end
|
||||||
|
|
||||||
# Group that the example belongs to.
|
# Group that the example belongs to.
|
||||||
getter group : ExampleGroup
|
getter group : ExampleGroup
|
||||||
|
@ -36,12 +40,12 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates there is only one example to run.
|
# Indicates there is only one example to run.
|
||||||
def example_count
|
def example_count : Int
|
||||||
1
|
1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Retrieve the current example.
|
# Retrieve the current example.
|
||||||
def [](index : Int)
|
def [](index : Int) : Example
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Spectator
|
||||||
# This is used as the base node type for the composite design pattern.
|
# This is used as the base node type for the composite design pattern.
|
||||||
abstract class ExampleComponent
|
abstract class ExampleComponent
|
||||||
# Text that describes the context or test.
|
# Text that describes the context or test.
|
||||||
abstract def what : String
|
abstract def what : Symbol | String
|
||||||
|
|
||||||
# Indicates whether the example (or group) has been completely run.
|
# Indicates whether the example (or group) has been completely run.
|
||||||
abstract def finished? : Bool
|
abstract def finished? : Bool
|
||||||
|
|
|
@ -18,6 +18,7 @@ module Spectator
|
||||||
# Creates the example group.
|
# Creates the example group.
|
||||||
# The hooks are stored to be triggered later.
|
# The hooks are stored to be triggered later.
|
||||||
def initialize(@hooks : ExampleHooks, @conditions : ExampleConditions)
|
def initialize(@hooks : ExampleHooks, @conditions : ExampleConditions)
|
||||||
|
@example_count = 0
|
||||||
@before_all_hooks_run = false
|
@before_all_hooks_run = false
|
||||||
@after_all_hooks_run = false
|
@after_all_hooks_run = false
|
||||||
end
|
end
|
||||||
|
@ -53,7 +54,9 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Number of examples in this group and all sub-groups.
|
# Number of examples in this group and all sub-groups.
|
||||||
getter example_count = 0
|
def example_count : Int
|
||||||
|
@example_count
|
||||||
|
end
|
||||||
|
|
||||||
# Retrieves an example by its index.
|
# Retrieves an example by its index.
|
||||||
# This recursively searches for an example.
|
# This recursively searches for an example.
|
||||||
|
@ -118,7 +121,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether all examples in the group have been run.
|
# Checks whether all examples in the group have been run.
|
||||||
def finished?
|
def finished? : Bool
|
||||||
children.all?(&.finished?)
|
children.all?(&.finished?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
|
|
||||||
# Status string specific to the result type.
|
# Status string specific to the result type.
|
||||||
private def status
|
private def status : String
|
||||||
"FAIL"
|
"FAIL"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,15 @@ module Spectator::Formatting
|
||||||
return "#{seconds.round(2)} seconds" if seconds < 60
|
return "#{seconds.round(2)} seconds" if seconds < 60
|
||||||
|
|
||||||
int_seconds = seconds.to_i
|
int_seconds = seconds.to_i
|
||||||
minutes = int_seconds / 60
|
minutes = int_seconds // 60
|
||||||
int_seconds %= 60
|
int_seconds %= 60
|
||||||
return sprintf("%i:%02i", minutes, int_seconds) if minutes < 60
|
return sprintf("%i:%02i", minutes, int_seconds) if minutes < 60
|
||||||
|
|
||||||
hours = minutes / 60
|
hours = minutes // 60
|
||||||
minutes %= 60
|
minutes %= 60
|
||||||
return sprintf("%i:%02i:%02i", hours, minutes, int_seconds) if hours < 24
|
return sprintf("%i:%02i:%02i", hours, minutes, int_seconds) if hours < 24
|
||||||
|
|
||||||
days = hours / 24
|
days = hours // 24
|
||||||
hours %= 24
|
hours %= 24
|
||||||
sprintf("%i days %i:%02i:%02i", days, hours, minutes, int_seconds)
|
sprintf("%i days %i:%02i:%02i", days, hours, minutes, int_seconds)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
|
|
||||||
# Status string specific to the result type.
|
# Status string specific to the result type.
|
||||||
private def status
|
private def status : String
|
||||||
"TODO"
|
"TODO"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting
|
||||||
end
|
end
|
||||||
|
|
||||||
# Status string specific to the result type.
|
# Status string specific to the result type.
|
||||||
private def status
|
private def status : String
|
||||||
"PASS"
|
"PASS"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the example satisfies the filter.
|
# Checks whether the example satisfies the filter.
|
||||||
def includes?(example)
|
def includes?(example) : Bool
|
||||||
@line == example.source.line
|
@line == example.source.line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"all #{matcher.description}"
|
"all #{matcher.description}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"contains exactly #{expected.label}"
|
"contains exactly #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"has attributes #{expected.label}"
|
"has attributes #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ module Spectator::Matchers
|
||||||
def negated_match(actual : TestExpression(T)) : MatchData forall T
|
def negated_match(actual : TestExpression(T)) : MatchData forall T
|
||||||
snapshot = snapshot_values(actual.value)
|
snapshot = snapshot_values(actual.value)
|
||||||
if match?(snapshot)
|
if match?(snapshot)
|
||||||
FailedMatchData.new("#{actual.label} has attributes #{expected.label}", **values(snapshot))
|
FailedMatchData.new("#{actual.label} has attributes #{expected.label}", **negated_values(snapshot))
|
||||||
else
|
else
|
||||||
SuccessfulMatchData.new
|
SuccessfulMatchData.new
|
||||||
end
|
end
|
||||||
|
@ -79,5 +79,17 @@ module Spectator::Matchers
|
||||||
}
|
}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Produces the tuple for the failed negated match data from a snapshot of the attributes.
|
||||||
|
private def negated_values(snapshot)
|
||||||
|
{% begin %}
|
||||||
|
{
|
||||||
|
{% for attribute in ExpectedType.keys %}
|
||||||
|
{{"expected " + attribute.stringify}}: "Not #{expected.value[{{attribute.symbolize}}].inspect}",
|
||||||
|
{{"actual " + attribute.stringify}}: snapshot[{{attribute.symbolize}}].inspect,
|
||||||
|
{% end %}
|
||||||
|
}
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value === actual.value
|
expected.value === actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not match #{expected.label}"
|
"#{actual.label} does not match #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} matched #{expected.label}"
|
"#{actual.label} matched #{expected.label}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"changes #{expression.label} from #{expected_before.inspect} to #{expected_after.inspect}"
|
"changes #{expression.label} from #{expected_before.inspect} to #{expected_after.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"changes #{expression.label} from #{expected}"
|
"changes #{expression.label} from #{expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"changes #{expression.label}"
|
"changes #{expression.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"changes #{expression.label} #{@relativity}"
|
"changes #{expression.label} #{@relativity}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"changes #{expression.label} to #{expected}"
|
"changes #{expression.label} to #{expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value.includes?(actual.value)
|
expected.value.includes?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not in #{expected.label}"
|
"#{actual.label} is not in #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is in #{expected.label}"
|
"#{actual.label} is in #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"contains #{expected.label}"
|
"contains #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value.all? do |item|
|
expected.value.all? do |item|
|
||||||
actual.value.includes?(item)
|
actual.value.includes?(item)
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not match #{expected.label}"
|
"#{actual.label} does not match #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} contains #{expected.label}"
|
"#{actual.label} contains #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"is empty"
|
"is empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value.empty?
|
actual.value.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not empty"
|
"#{actual.label} is not empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is empty"
|
"#{actual.label} is empty"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"ends with #{expected.label}"
|
"ends with #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value == actual.value
|
expected.value == actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not equal #{expected.label}"
|
"#{actual.label} does not equal #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} equals #{expected.label}"
|
"#{actual.label} equals #{expected.label}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
if (message = @expected)
|
if (message = @expected)
|
||||||
"raises #{ExceptionType} with message #{message}"
|
"raises #{ExceptionType} with message #{message}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Spectator::Matchers
|
||||||
# Information about a failed match.
|
# Information about a failed match.
|
||||||
struct FailedMatchData < MatchData
|
struct FailedMatchData < MatchData
|
||||||
# Indicates that the match failed.
|
# Indicates that the match failed.
|
||||||
def matched?
|
def matched? : Bool
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value >= expected.value
|
actual.value >= expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is less than #{expected.label}"
|
"#{actual.label} is less than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is greater than or equal to #{expected.label}"
|
"#{actual.label} is greater than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value > expected.value
|
actual.value > expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is less than or equal to #{expected.label}"
|
"#{actual.label} is less than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is greater than #{expected.label}"
|
"#{actual.label} is greater than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value.has_key?(expected.value)
|
actual.value.has_key?(expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not have key #{expected.label}"
|
"#{actual.label} does not have key #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} has key #{expected.label}"
|
"#{actual.label} has key #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"includes #{expected.label}"
|
"includes #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
if (value = actual.value).is_a?(String)
|
if (value = actual.value).is_a?(String)
|
||||||
match_string?(value)
|
match_string?(value)
|
||||||
else
|
else
|
||||||
|
@ -46,7 +46,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not include #{expected.label}"
|
"#{actual.label} does not include #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} includes #{expected.label}"
|
"#{actual.label} includes #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"has #{expected.label}"
|
"has #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not have #{expected.label}"
|
"#{actual.label} does not have #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} has #{expected.label}"
|
"#{actual.label} has #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ module Spectator::Matchers
|
||||||
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 satisified.
|
||||||
private def match?(snapshot)
|
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 %}
|
||||||
return false unless snapshot[{{attribute.symbolize}}]
|
return false unless snapshot[{{attribute.symbolize}}]
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value.has_value?(expected.value)
|
actual.value.has_value?(expected.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not have value #{expected.label}"
|
"#{actual.label} does not have value #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} has value #{expected.label}"
|
"#{actual.label} has value #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value != actual.value
|
expected.value != actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is equal to #{expected.label}"
|
"#{actual.label} is equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is not equal to #{expected.label}"
|
"#{actual.label} is not equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value <= expected.value
|
actual.value <= expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is greater than #{expected.label}"
|
"#{actual.label} is greater than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is less than or equal to #{expected.label}"
|
"#{actual.label} is less than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value < expected.value
|
actual.value < expected.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is greater than or equal to #{expected.label}"
|
"#{actual.label} is greater than or equal to #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is less than #{expected.label}"
|
"#{actual.label} is less than #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"is nil"
|
"is nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value.nil?
|
actual.value.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not nil"
|
"#{actual.label} is not nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is nil"
|
"#{actual.label} is nil"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"is #{expected.label}"
|
"is #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not #{expected.label}"
|
"#{actual.label} is not #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is #{expected.label}"
|
"#{actual.label} is #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"is in #{expected.label}"
|
"is in #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value.includes?(actual.value)
|
expected.value.includes?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not in #{expected.label} (#{exclusivity})"
|
"#{actual.label} is not in #{expected.label} (#{exclusivity})"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is in #{expected.label} (#{exclusivity})"
|
"#{actual.label} is in #{expected.label} (#{exclusivity})"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value.same?(actual.value)
|
expected.value.same?(actual.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not #{expected.label}"
|
"#{actual.label} is not #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is #{expected.label}"
|
"#{actual.label} is #{expected.label}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"responds to #{label}"
|
"responds to #{label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value == actual.value.size
|
expected.value == actual.value.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} does not have #{expected.label} elements"
|
"#{actual.label} does not have #{expected.label} elements"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} has #{expected.label} elements"
|
"#{actual.label} has #{expected.label} elements"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"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 satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
expected.value.size == actual.value.size
|
expected.value.size == actual.value.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not the same size as #{expected.label}"
|
"#{actual.label} is not the same size as #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is the same size as #{expected.label}"
|
"#{actual.label} is the same size as #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"starts with #{expected.label}"
|
"starts with #{expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Spectator::Matchers
|
||||||
# Information about a successful match.
|
# Information about a successful match.
|
||||||
struct SuccessfulMatchData < MatchData
|
struct SuccessfulMatchData < MatchData
|
||||||
# Indicates that the match succeeded.
|
# Indicates that the match succeeded.
|
||||||
def matched?
|
def matched? : Bool
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"is #{label}"
|
"is #{label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
@truthy == !!actual.value
|
@truthy == !!actual.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is #{negated_label}"
|
"#{actual.label} is #{negated_label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is #{label}"
|
"#{actual.label} is #{label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"is as #{Expected}"
|
"is as #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the matcher is satisifed with the expression given to it.
|
# Checks whether the matcher is satisifed with the expression given to it.
|
||||||
private def match?(actual : TestExpression(T)) forall T
|
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||||
actual.value.is_a?(Expected)
|
actual.value.is_a?(Expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message(actual)
|
private def failure_message(actual) : String
|
||||||
"#{actual.label} is not a #{Expected}"
|
"#{actual.label} is not a #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
||||||
#
|
#
|
||||||
# The message should typically only contain the test expression labels.
|
# The message should typically only contain the test expression labels.
|
||||||
# Actual values should be returned by `#values`.
|
# Actual values should be returned by `#values`.
|
||||||
private def failure_message_when_negated(actual)
|
private def failure_message_when_negated(actual) : String
|
||||||
"#{actual.label} is a #{Expected}"
|
"#{actual.label} is a #{Expected}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Spectator::Matchers
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
# This explains what condition satisfies the matcher.
|
# This explains what condition satisfies the matcher.
|
||||||
# The description is used when the one-liner syntax is used.
|
# The description is used when the one-liner syntax is used.
|
||||||
def description
|
def description : String
|
||||||
"contains #{expected.label} in any order"
|
"contains #{expected.label} in any order"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the example satisfies the filter.
|
# Checks whether the example satisfies the filter.
|
||||||
def includes?(example)
|
def includes?(example) : Bool
|
||||||
@name == example.to_s
|
@name == example.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates wheter the group references a type.
|
# Indicates wheter the group references a type.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
@what.is_a?(Symbol)
|
@what.is_a?(Symbol)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Spectator
|
||||||
# Filter that matches all examples.
|
# Filter that matches all examples.
|
||||||
class NullExampleFilter < ExampleFilter
|
class NullExampleFilter < ExampleFilter
|
||||||
# Checks whether the example satisfies the filter.
|
# Checks whether the example satisfies the filter.
|
||||||
def includes?(example)
|
def includes?(example) : Bool
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator
|
||||||
# This class will not run example code.
|
# This class will not run example code.
|
||||||
abstract class PendingExample < Example
|
abstract class PendingExample < Example
|
||||||
# Returns a pending result.
|
# Returns a pending result.
|
||||||
private def run_impl
|
private def run_impl : Result
|
||||||
PendingResult.new(self)
|
PendingResult.new(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,12 @@ module Spectator
|
||||||
# The root has no parent.
|
# The root has no parent.
|
||||||
class RootExampleGroup < ExampleGroup
|
class RootExampleGroup < ExampleGroup
|
||||||
# Dummy value - this should never be used.
|
# Dummy value - this should never be used.
|
||||||
def what
|
def what : Symbol | String
|
||||||
"ROOT"
|
"ROOT"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that the group is symbolic.
|
# Indicates that the group is symbolic.
|
||||||
def symbolic?
|
def symbolic? : Bool
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Spectator
|
||||||
abstract class RunnableExample < Example
|
abstract class RunnableExample < Example
|
||||||
# Runs the example, hooks, and captures the result
|
# Runs the example, hooks, and captures the result
|
||||||
# and translates to a usable result.
|
# and translates to a usable result.
|
||||||
def run_impl
|
def run_impl : Result
|
||||||
result = capture_result
|
result = capture_result
|
||||||
expectations = Internals::Harness.current.expectations
|
expectations = Internals::Harness.current.expectations
|
||||||
translate_result(result, expectations)
|
translate_result(result, expectations)
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks whether the example satisfies the filter.
|
# Checks whether the example satisfies the filter.
|
||||||
def includes?(example)
|
def includes?(example) : Bool
|
||||||
@source === example.source
|
@source === example.source
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue