mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Reduce nesting by collapsing modules with ::
This commit is contained in:
parent
0d282d3d50
commit
77b4c71c2a
14 changed files with 440 additions and 468 deletions
|
@ -1,5 +1,4 @@
|
|||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
module Builder
|
||||
extend self
|
||||
|
||||
|
@ -61,5 +60,4 @@ module Spectator
|
|||
root_group.build(nil, Internals::SampleValues.empty)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require "./matcher_dsl"
|
||||
|
||||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
module ExampleDSL
|
||||
include MatcherDSL
|
||||
|
||||
|
@ -13,5 +12,4 @@ module Spectator
|
|||
::Spectator::Expectation.new({{actual.stringify}}, {{actual}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
class ExampleFactory
|
||||
def initialize(@example_type : Example.class)
|
||||
end
|
||||
|
@ -8,5 +7,4 @@ module Spectator
|
|||
@example_type.new(group, sample_values)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
class ExampleGroupBuilder
|
||||
alias Child = ExampleFactory | ExampleGroupBuilder
|
||||
|
||||
|
@ -56,5 +55,4 @@ module Spectator
|
|||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require "./example_group_builder"
|
||||
|
||||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
class GivenExampleGroupBuilder(T) < ExampleGroupBuilder
|
||||
|
||||
def initialize(what : String, @collection : Array(T), @symbol : Symbol)
|
||||
|
@ -25,5 +24,4 @@ module Spectator
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
require "../matchers"
|
||||
|
||||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
module MatcherDSL
|
||||
macro eq(expected)
|
||||
::Spectator::Matchers::EqualityMatcher.new({{expected.stringify}}, {{expected}})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require "../example_group"
|
||||
|
||||
module Spectator
|
||||
module DSL
|
||||
module Spectator::DSL
|
||||
module StructureDSL
|
||||
|
||||
def initialize(sample_values : Internals::SampleValues)
|
||||
|
@ -196,5 +195,4 @@ module Spectator
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
require "./formatter"
|
||||
require "colorize"
|
||||
|
||||
module Spectator
|
||||
module Formatters
|
||||
module Spectator::Formatters
|
||||
class DefaultFormatter < Formatter
|
||||
SUCCESS_COLOR = :green
|
||||
FAILURE_COLOR = :red
|
||||
|
@ -116,5 +115,4 @@ module Spectator
|
|||
return sprintf("%i days %i:%02i:%02i", days, hours, minutes, int_seconds)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
module Spectator
|
||||
module Formatters
|
||||
module Spectator::Formatters
|
||||
abstract class Formatter
|
||||
abstract def start_suite
|
||||
abstract def end_suite(results : TestResults)
|
||||
abstract def start_example(example : Example)
|
||||
abstract def end_example(result : Result)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require "./value_wrapper"
|
||||
|
||||
module Spectator
|
||||
module Internals
|
||||
module Spectator::Internals
|
||||
struct SampleValues
|
||||
private record Entry, name : String, wrapper : ValueWrapper
|
||||
|
||||
|
@ -23,5 +22,4 @@ module Spectator
|
|||
@values[id].wrapper
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
require "./value_wrapper"
|
||||
|
||||
module Spectator
|
||||
module Internals
|
||||
module Spectator::Internals
|
||||
class TypedValueWrapper(T) < ValueWrapper
|
||||
getter value : T
|
||||
|
||||
def initialize(@value : T)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Spectator
|
||||
module Internals
|
||||
module Spectator::Internals
|
||||
# Base class for proxying test values to examples.
|
||||
# This abstraction is required for inferring types.
|
||||
# The `DSL#let` macro makes heavy use of this.
|
||||
|
@ -7,5 +6,4 @@ module Spectator
|
|||
# Retrieves the underlying value.
|
||||
abstract def value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require "./matcher"
|
||||
|
||||
module Spectator
|
||||
module Matchers
|
||||
module Spectator::Matchers
|
||||
class EqualityMatcher(T) < Matcher
|
||||
def initialize(label, @expected : T)
|
||||
super(label)
|
||||
|
@ -19,5 +18,4 @@ module Spectator
|
|||
"Expected #{expectation.label} to not equal #{label} (using ==)"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module Spectator
|
||||
module Matchers
|
||||
module Spectator::Matchers
|
||||
abstract class Matcher
|
||||
private getter label : String
|
||||
|
||||
|
@ -10,5 +9,4 @@ module Spectator
|
|||
abstract def message(expectation : Expectation) : String
|
||||
abstract def negated_message(expectation : Expectation) : String
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue