mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add return type annotations
Addresses Crystal compiler warning about abstract method return types.
This commit is contained in:
parent
adbfb7da7c
commit
43dc106c18
58 changed files with 146 additions and 139 deletions
|
@ -1,17 +1,17 @@
|
|||
# Example that always raises an exception.
|
||||
class ErroredExample < Spectator::RunnableExample
|
||||
# Dummy description.
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"ERROR"
|
||||
end
|
||||
|
||||
# Dummy source.
|
||||
def source
|
||||
def source : ::Spectator::Source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy symbolic flag.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# Example that always fails.
|
||||
class FailingExample < Spectator::RunnableExample
|
||||
# Dummy description.
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"FAIL"
|
||||
end
|
||||
|
||||
# Dummy source.
|
||||
def source
|
||||
def source : ::Spectator::Source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy symbolic flag.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -6,17 +6,17 @@ class PassingExample < Spectator::RunnableExample
|
|||
end
|
||||
|
||||
# Dummy description.
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"PASS"
|
||||
end
|
||||
|
||||
# Dummy source.
|
||||
def source
|
||||
def source : ::Spectator::Source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy symbolic flag.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
@symbolic
|
||||
end
|
||||
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
# This is useful for capturing what's going on when an event is running.
|
||||
class SpyExample < Spectator::RunnableExample
|
||||
# Dummy description.
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"SPY"
|
||||
end
|
||||
|
||||
# Dummy source.
|
||||
def source
|
||||
def source : ::Spectator::Source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
# Dummy symbolic flag.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
require "./spec_helper"
|
||||
|
||||
class ConcretePendingExample < Spectator::PendingExample
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"PENDING_TEST_EXAMPLE"
|
||||
end
|
||||
|
||||
def source
|
||||
def source : ::Spectator::Source
|
||||
::Spectator::Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Checks whether the example satisfies the filter.
|
||||
def includes?(example)
|
||||
def includes?(example) : Bool
|
||||
@filters.any?(&.includes?(example))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,17 +10,17 @@ module Spectator
|
|||
# This class shouldn't be used, it's just to trick the compiler.
|
||||
private class DummyExample < RunnableExample
|
||||
# Dummy description.
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"DUMMY"
|
||||
end
|
||||
|
||||
# Dummy symbolic flag.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
false
|
||||
end
|
||||
|
||||
# Dummy source.
|
||||
def source
|
||||
def source : Source
|
||||
Source.new(__FILE__, __LINE__)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,8 +4,12 @@ module Spectator
|
|||
# Base class for all types of examples.
|
||||
# Concrete types must implement the `#run_impl, `#what`, `#instance`, and `#source` methods.
|
||||
abstract class Example < ExampleComponent
|
||||
@finished = false
|
||||
|
||||
# Indicates whether the example has already been run.
|
||||
getter? finished = false
|
||||
def finished? : Bool
|
||||
@finished
|
||||
end
|
||||
|
||||
# Group that the example belongs to.
|
||||
getter group : ExampleGroup
|
||||
|
@ -36,12 +40,12 @@ module Spectator
|
|||
end
|
||||
|
||||
# Indicates there is only one example to run.
|
||||
def example_count
|
||||
def example_count : Int
|
||||
1
|
||||
end
|
||||
|
||||
# Retrieve the current example.
|
||||
def [](index : Int)
|
||||
def [](index : Int) : Example
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ module Spectator
|
|||
# This is used as the base node type for the composite design pattern.
|
||||
abstract class ExampleComponent
|
||||
# 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.
|
||||
abstract def finished? : Bool
|
||||
|
|
|
@ -18,6 +18,7 @@ module Spectator
|
|||
# Creates the example group.
|
||||
# The hooks are stored to be triggered later.
|
||||
def initialize(@hooks : ExampleHooks, @conditions : ExampleConditions)
|
||||
@example_count = 0
|
||||
@before_all_hooks_run = false
|
||||
@after_all_hooks_run = false
|
||||
end
|
||||
|
@ -53,7 +54,9 @@ module Spectator
|
|||
end
|
||||
|
||||
# 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.
|
||||
# This recursively searches for an example.
|
||||
|
@ -118,7 +121,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Checks whether all examples in the group have been run.
|
||||
def finished?
|
||||
def finished? : Bool
|
||||
children.all?(&.finished?)
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Formatting
|
|||
end
|
||||
|
||||
# Status string specific to the result type.
|
||||
private def status
|
||||
private def status : String
|
||||
"FAIL"
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Formatting
|
|||
end
|
||||
|
||||
# Status string specific to the result type.
|
||||
private def status
|
||||
private def status : String
|
||||
"TODO"
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Formatting
|
|||
end
|
||||
|
||||
# Status string specific to the result type.
|
||||
private def status
|
||||
private def status : String
|
||||
"PASS"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Checks whether the example satisfies the filter.
|
||||
def includes?(example)
|
||||
def includes?(example) : Bool
|
||||
@line == example.source.line
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"all #{matcher.description}"
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"contains exactly #{expected.label}"
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"has attributes #{expected.label}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"matches #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"changes #{expression.label} from #{expected}"
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"changes #{expression.label}"
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"changes #{expression.label} #{@relativity}"
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"changes #{expression.label} to #{expected}"
|
||||
end
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is in #{expected.label}"
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"contains #{expected.label}"
|
||||
end
|
||||
|
||||
# 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|
|
||||
actual.value.includes?(item)
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -35,7 +35,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is empty"
|
||||
end
|
||||
|
||||
# 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?
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# Actual values should be returned by `#values`.
|
||||
private def failure_message(actual)
|
||||
private def failure_message(actual) : String
|
||||
"#{actual.label} is not empty"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"ends with #{expected.label}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"equals #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
if (message = @expected)
|
||||
"raises #{ExceptionType} with message #{message}"
|
||||
else
|
||||
|
|
|
@ -4,7 +4,7 @@ module Spectator::Matchers
|
|||
# Information about a failed match.
|
||||
struct FailedMatchData < MatchData
|
||||
# Indicates that the match failed.
|
||||
def matched?
|
||||
def matched? : Bool
|
||||
false
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"greater than or equal to #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"greater than #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"has key #{expected.label}"
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"includes #{expected.label}"
|
||||
end
|
||||
|
||||
# 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)
|
||||
match_string?(value)
|
||||
else
|
||||
|
@ -46,7 +46,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"has #{expected.label}"
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -59,7 +59,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -76,7 +76,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
# 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.
|
||||
{% for attribute in ExpectedType.keys %}
|
||||
return false unless snapshot[{{attribute.symbolize}}]
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"has value #{expected.label}"
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is not equal to #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"less than or equal to #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"less than #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is nil"
|
||||
end
|
||||
|
||||
# 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?
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# Actual values should be returned by `#values`.
|
||||
private def failure_message(actual)
|
||||
private def failure_message(actual) : String
|
||||
"#{actual.label} is not nil"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is #{expected.label}"
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# Actual values should be returned by `#values`.
|
||||
private def failure_message(actual)
|
||||
private def failure_message(actual) : String
|
||||
"#{actual.label} is not #{expected.label}"
|
||||
end
|
||||
|
||||
|
@ -58,7 +58,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is in #{expected.label}"
|
||||
end
|
||||
|
||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
@ -36,7 +36,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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})"
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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})"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is #{expected.label}"
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# Actual values should be returned by `#values`.
|
||||
private def failure_message(actual)
|
||||
private def failure_message(actual) : String
|
||||
"#{actual.label} is not #{expected.label}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"responds to #{label}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"has size #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is the same size as #{expected.label}"
|
||||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"starts with #{expected.label}"
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ module Spectator::Matchers
|
|||
# Information about a successful match.
|
||||
struct SuccessfulMatchData < MatchData
|
||||
# Indicates that the match succeeded.
|
||||
def matched?
|
||||
def matched? : Bool
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is #{label}"
|
||||
end
|
||||
|
||||
|
@ -83,7 +83,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
# 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
|
||||
end
|
||||
|
||||
|
@ -93,7 +93,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# Actual values should be returned by `#values`.
|
||||
private def failure_message(actual)
|
||||
private def failure_message(actual) : String
|
||||
"#{actual.label} is #{negated_label}"
|
||||
end
|
||||
|
||||
|
@ -104,7 +104,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"is as #{Expected}"
|
||||
end
|
||||
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# Actual values should be returned by `#values`.
|
||||
private def failure_message(actual)
|
||||
private def failure_message(actual) : String
|
||||
"#{actual.label} is not a #{Expected}"
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module Spectator::Matchers
|
|||
#
|
||||
# The message should typically only contain the test expression labels.
|
||||
# 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}"
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ module Spectator::Matchers
|
|||
# Short text about the matcher's purpose.
|
||||
# This explains what condition satisfies the matcher.
|
||||
# The description is used when the one-liner syntax is used.
|
||||
def description
|
||||
def description : String
|
||||
"contains #{expected.label} in any order"
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Checks whether the example satisfies the filter.
|
||||
def includes?(example)
|
||||
def includes?(example) : Bool
|
||||
@name == example.to_s
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Indicates wheter the group references a type.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
@what.is_a?(Symbol)
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ module Spectator
|
|||
# Filter that matches all examples.
|
||||
class NullExampleFilter < ExampleFilter
|
||||
# Checks whether the example satisfies the filter.
|
||||
def includes?(example)
|
||||
def includes?(example) : Bool
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator
|
|||
# This class will not run example code.
|
||||
abstract class PendingExample < Example
|
||||
# Returns a pending result.
|
||||
private def run_impl
|
||||
private def run_impl : Result
|
||||
PendingResult.new(self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,12 +5,12 @@ module Spectator
|
|||
# The root has no parent.
|
||||
class RootExampleGroup < ExampleGroup
|
||||
# Dummy value - this should never be used.
|
||||
def what
|
||||
def what : Symbol | String
|
||||
"ROOT"
|
||||
end
|
||||
|
||||
# Indicates that the group is symbolic.
|
||||
def symbolic?
|
||||
def symbolic? : Bool
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ module Spectator
|
|||
abstract class RunnableExample < Example
|
||||
# Runs the example, hooks, and captures the result
|
||||
# and translates to a usable result.
|
||||
def run_impl
|
||||
def run_impl : Result
|
||||
result = capture_result
|
||||
expectations = Internals::Harness.current.expectations
|
||||
translate_result(result, expectations)
|
||||
|
|
|
@ -7,7 +7,7 @@ module Spectator
|
|||
end
|
||||
|
||||
# Checks whether the example satisfies the filter.
|
||||
def includes?(example)
|
||||
def includes?(example) : Bool
|
||||
@source === example.source
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue