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 Spectator::DSL
|
||||||
module DSL
|
|
||||||
module Builder
|
module Builder
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
|
@ -62,4 +61,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "./matcher_dsl"
|
require "./matcher_dsl"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::DSL
|
||||||
module DSL
|
|
||||||
module ExampleDSL
|
module ExampleDSL
|
||||||
include MatcherDSL
|
include MatcherDSL
|
||||||
|
|
||||||
|
@ -14,4 +13,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
module Spectator
|
module Spectator::DSL
|
||||||
module DSL
|
|
||||||
class ExampleFactory
|
class ExampleFactory
|
||||||
def initialize(@example_type : Example.class)
|
def initialize(@example_type : Example.class)
|
||||||
end
|
end
|
||||||
|
@ -9,4 +8,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
module Spectator
|
module Spectator::DSL
|
||||||
module DSL
|
|
||||||
class ExampleGroupBuilder
|
class ExampleGroupBuilder
|
||||||
alias Child = ExampleFactory | ExampleGroupBuilder
|
alias Child = ExampleFactory | ExampleGroupBuilder
|
||||||
|
|
||||||
|
@ -57,4 +56,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "./example_group_builder"
|
require "./example_group_builder"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::DSL
|
||||||
module DSL
|
|
||||||
class GivenExampleGroupBuilder(T) < ExampleGroupBuilder
|
class GivenExampleGroupBuilder(T) < ExampleGroupBuilder
|
||||||
|
|
||||||
def initialize(what : String, @collection : Array(T), @symbol : Symbol)
|
def initialize(what : String, @collection : Array(T), @symbol : Symbol)
|
||||||
|
@ -26,4 +25,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
require "../matchers"
|
require "../matchers"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::DSL
|
||||||
module DSL
|
|
||||||
module MatcherDSL
|
module MatcherDSL
|
||||||
macro eq(expected)
|
macro eq(expected)
|
||||||
::Spectator::Matchers::EqualityMatcher.new({{expected.stringify}}, {{expected}})
|
::Spectator::Matchers::EqualityMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "../example_group"
|
require "../example_group"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::DSL
|
||||||
module DSL
|
|
||||||
module StructureDSL
|
module StructureDSL
|
||||||
|
|
||||||
def initialize(sample_values : Internals::SampleValues)
|
def initialize(sample_values : Internals::SampleValues)
|
||||||
|
@ -197,4 +196,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
require "./formatter"
|
require "./formatter"
|
||||||
require "colorize"
|
require "colorize"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::Formatters
|
||||||
module Formatters
|
|
||||||
class DefaultFormatter < Formatter
|
class DefaultFormatter < Formatter
|
||||||
SUCCESS_COLOR = :green
|
SUCCESS_COLOR = :green
|
||||||
FAILURE_COLOR = :red
|
FAILURE_COLOR = :red
|
||||||
|
@ -117,4 +116,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
module Spectator
|
module Spectator::Formatters
|
||||||
module Formatters
|
|
||||||
abstract class Formatter
|
abstract class Formatter
|
||||||
abstract def start_suite
|
abstract def start_suite
|
||||||
abstract def end_suite(results : TestResults)
|
abstract def end_suite(results : TestResults)
|
||||||
|
@ -7,4 +6,3 @@ module Spectator
|
||||||
abstract def end_example(result : Result)
|
abstract def end_example(result : Result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "./value_wrapper"
|
require "./value_wrapper"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::Internals
|
||||||
module Internals
|
|
||||||
struct SampleValues
|
struct SampleValues
|
||||||
private record Entry, name : String, wrapper : ValueWrapper
|
private record Entry, name : String, wrapper : ValueWrapper
|
||||||
|
|
||||||
|
@ -24,4 +23,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "./value_wrapper"
|
require "./value_wrapper"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::Internals
|
||||||
module Internals
|
|
||||||
class TypedValueWrapper(T) < ValueWrapper
|
class TypedValueWrapper(T) < ValueWrapper
|
||||||
getter value : T
|
getter value : T
|
||||||
|
|
||||||
|
@ -9,4 +8,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
module Spectator
|
module Spectator::Internals
|
||||||
module Internals
|
|
||||||
# Base class for proxying test values to examples.
|
# Base class for proxying test values to examples.
|
||||||
# This abstraction is required for inferring types.
|
# This abstraction is required for inferring types.
|
||||||
# The `DSL#let` macro makes heavy use of this.
|
# The `DSL#let` macro makes heavy use of this.
|
||||||
|
@ -8,4 +7,3 @@ module Spectator
|
||||||
abstract def value
|
abstract def value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "./matcher"
|
require "./matcher"
|
||||||
|
|
||||||
module Spectator
|
module Spectator::Matchers
|
||||||
module Matchers
|
|
||||||
class EqualityMatcher(T) < Matcher
|
class EqualityMatcher(T) < Matcher
|
||||||
def initialize(label, @expected : T)
|
def initialize(label, @expected : T)
|
||||||
super(label)
|
super(label)
|
||||||
|
@ -20,4 +19,3 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
module Spectator
|
module Spectator::Matchers
|
||||||
module Matchers
|
|
||||||
abstract class Matcher
|
abstract class Matcher
|
||||||
private getter label : String
|
private getter label : String
|
||||||
|
|
||||||
|
@ -11,4 +10,3 @@ module Spectator
|
||||||
abstract def negated_message(expectation : Expectation) : String
|
abstract def negated_message(expectation : Expectation) : String
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue