Reduce nesting by collapsing modules with ::

This commit is contained in:
Michael Miller 2018-09-27 16:20:55 -06:00
parent 0d282d3d50
commit 77b4c71c2a
14 changed files with 440 additions and 468 deletions

View file

@ -1,5 +1,4 @@
module Spectator
module DSL
module Spectator::DSL
module Builder
extend self
@ -62,4 +61,3 @@ module Spectator
end
end
end
end

View file

@ -1,7 +1,6 @@
require "./matcher_dsl"
module Spectator
module DSL
module Spectator::DSL
module ExampleDSL
include MatcherDSL
@ -14,4 +13,3 @@ module Spectator
end
end
end
end

View file

@ -1,5 +1,4 @@
module Spectator
module DSL
module Spectator::DSL
class ExampleFactory
def initialize(@example_type : Example.class)
end
@ -9,4 +8,3 @@ module Spectator
end
end
end
end

View file

@ -1,5 +1,4 @@
module Spectator
module DSL
module Spectator::DSL
class ExampleGroupBuilder
alias Child = ExampleFactory | ExampleGroupBuilder
@ -57,4 +56,3 @@ module Spectator
end
end
end
end

View file

@ -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)
@ -26,4 +25,3 @@ module Spectator
end
end
end
end

View file

@ -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

View file

@ -1,7 +1,6 @@
require "../example_group"
module Spectator
module DSL
module Spectator::DSL
module StructureDSL
def initialize(sample_values : Internals::SampleValues)
@ -197,4 +196,3 @@ module Spectator
end
end
end
end

View file

@ -1,8 +1,7 @@
require "./formatter"
require "colorize"
module Spectator
module Formatters
module Spectator::Formatters
class DefaultFormatter < Formatter
SUCCESS_COLOR = :green
FAILURE_COLOR = :red
@ -117,4 +116,3 @@ module Spectator
end
end
end
end

View file

@ -1,5 +1,4 @@
module Spectator
module Formatters
module Spectator::Formatters
abstract class Formatter
abstract def start_suite
abstract def end_suite(results : TestResults)
@ -7,4 +6,3 @@ module Spectator
abstract def end_example(result : Result)
end
end
end

View file

@ -1,7 +1,6 @@
require "./value_wrapper"
module Spectator
module Internals
module Spectator::Internals
struct SampleValues
private record Entry, name : String, wrapper : ValueWrapper
@ -24,4 +23,3 @@ module Spectator
end
end
end
end

View file

@ -1,7 +1,6 @@
require "./value_wrapper"
module Spectator
module Internals
module Spectator::Internals
class TypedValueWrapper(T) < ValueWrapper
getter value : T
@ -9,4 +8,3 @@ module Spectator
end
end
end
end

View file

@ -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.
@ -8,4 +7,3 @@ module Spectator
abstract def value
end
end
end

View file

@ -1,7 +1,6 @@
require "./matcher"
module Spectator
module Matchers
module Spectator::Matchers
class EqualityMatcher(T) < Matcher
def initialize(label, @expected : T)
super(label)
@ -20,4 +19,3 @@ module Spectator
end
end
end
end

View file

@ -1,5 +1,4 @@
module Spectator
module Matchers
module Spectator::Matchers
abstract class Matcher
private getter label : String
@ -11,4 +10,3 @@ module Spectator
abstract def negated_message(expectation : Expectation) : String
end
end
end