mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Rename DSL::Builder to SpecBuilder
Place all builders under SpecBuilder.
This commit is contained in:
parent
5d86b4f50e
commit
fafe5606e6
9 changed files with 27 additions and 26 deletions
|
@ -101,7 +101,7 @@ module Spectator
|
|||
# Builds the tests and runs the framework.
|
||||
private def run
|
||||
# Build the test suite and run it.
|
||||
suite = ::Spectator::DSL::Builder.build(config.example_filter)
|
||||
suite = ::Spectator::SpecBuilder.build(config.example_filter)
|
||||
Runner.new(suite, config).run
|
||||
rescue ex
|
||||
# Catch all unhandled exceptions here.
|
||||
|
|
|
@ -263,7 +263,7 @@ module Spectator::DSL
|
|||
{% end %}
|
||||
|
||||
# Start a new group.
|
||||
::Spectator::DSL::Builder.start_group(
|
||||
::Spectator::SpecBuilder.start_group(
|
||||
{% if what.is_a?(StringLiteral) %}
|
||||
{% if what.starts_with?("#") || what.starts_with?(".") %}
|
||||
{{what.id.symbolize}}
|
||||
|
@ -279,7 +279,7 @@ module Spectator::DSL
|
|||
{{block.body}}
|
||||
|
||||
# End the current group.
|
||||
::Spectator::DSL::Builder.end_group
|
||||
::Spectator::SpecBuilder.end_group
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -543,7 +543,7 @@ module Spectator::DSL
|
|||
|
||||
# Start a new example group.
|
||||
# Sample groups require additional configuration.
|
||||
::Spectator::DSL::Builder.start_sample_group(
|
||||
::Spectator::SpecBuilder.start_sample_group(
|
||||
{{collection.stringify}}, # String representation of the collection.
|
||||
Sample%sample, # Type that can construct the elements.
|
||||
->(s : Sample%sample) { s.%to_a }, # Proc to build the array of elements in the collection.
|
||||
|
@ -555,7 +555,7 @@ module Spectator::DSL
|
|||
{{block.body}}
|
||||
|
||||
# End the current group.
|
||||
::Spectator::DSL::Builder.end_group
|
||||
::Spectator::SpecBuilder.end_group
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -656,7 +656,7 @@ module Spectator::DSL
|
|||
|
||||
# Start a new example group.
|
||||
# Sample groups require additional configuration.
|
||||
::Spectator::DSL::Builder.start_sample_group(
|
||||
::Spectator::SpecBuilder.start_sample_group(
|
||||
{{collection.stringify}}, # String representation of the collection.
|
||||
Sample%sample, # All elements in the collection.
|
||||
{{name.stringify}}, # Name for the current element.
|
||||
|
@ -667,7 +667,7 @@ module Spectator::DSL
|
|||
{{block.body}}
|
||||
|
||||
# End the current group.
|
||||
::Spectator::DSL::Builder.end_group
|
||||
::Spectator::SpecBuilder.end_group
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -990,7 +990,7 @@ module Spectator::DSL
|
|||
#
|
||||
# See also: `#before_each`, `#after_all`, `#after_each`, and `#around_each`.
|
||||
macro before_all(&block)
|
||||
::Spectator::DSL::Builder.add_before_all_hook {{block}}
|
||||
::Spectator::SpecBuilder.add_before_all_hook {{block}}
|
||||
end
|
||||
|
||||
# Creates a hook that will run prior to every example in the group.
|
||||
|
@ -1051,7 +1051,7 @@ module Spectator::DSL
|
|||
{{yield}}
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.add_before_each_hook do
|
||||
::Spectator::SpecBuilder.add_before_each_hook do
|
||||
# Get the wrapper instance and cast to current group type.
|
||||
example = ::Spectator::Internals::Harness.current.example
|
||||
instance = example.instance.as({{@type.id}})
|
||||
|
@ -1110,7 +1110,7 @@ module Spectator::DSL
|
|||
#
|
||||
# See also: `#before_all`, `#before_each`, `#after_each`, and `#around_each`.
|
||||
macro after_all(&block)
|
||||
::Spectator::DSL::Builder.add_after_all_hook {{block}}
|
||||
::Spectator::SpecBuilder.add_after_all_hook {{block}}
|
||||
end
|
||||
|
||||
# Creates a hook that will run following every example in the group.
|
||||
|
@ -1170,7 +1170,7 @@ module Spectator::DSL
|
|||
{{yield}}
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.add_after_each_hook do
|
||||
::Spectator::SpecBuilder.add_after_each_hook do
|
||||
# Get the wrapper instance and cast to current group type.
|
||||
example = ::Spectator::Internals::Harness.current.example
|
||||
instance = example.instance.as({{@type.id}})
|
||||
|
@ -1266,7 +1266,7 @@ module Spectator::DSL
|
|||
{{yield}}
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.add_around_each_hook do |proc|
|
||||
::Spectator::SpecBuilder.add_around_each_hook do |proc|
|
||||
# Get the wrapper instance and cast to current group type.
|
||||
example = ::Spectator::Internals::Harness.current.example
|
||||
instance = example.instance.as({{@type.id}})
|
||||
|
@ -1325,7 +1325,7 @@ module Spectator::DSL
|
|||
{{yield}}
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.add_pre_condition do
|
||||
::Spectator::SpecBuilder.add_pre_condition do
|
||||
example = ::Spectator::Internals::Harness.current.example
|
||||
instance = example.instance.as({{@type.id}})
|
||||
instance.%condition
|
||||
|
@ -1384,7 +1384,7 @@ module Spectator::DSL
|
|||
{{yield}}
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.add_post_condition do
|
||||
::Spectator::SpecBuilder.add_post_condition do
|
||||
example = ::Spectator::Internals::Harness.current.example
|
||||
instance = example.instance.as({{@type.id}})
|
||||
instance.%condition
|
||||
|
@ -1429,7 +1429,7 @@ module Spectator::DSL
|
|||
{% end %}
|
||||
|
||||
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||
::Spectator::DSL::Builder.add_example({{what.stringify}}, %source, {{@type.name}}) { |test| test.as({{@type.name}}).%run }
|
||||
::Spectator::SpecBuilder.add_example({{what.stringify}}, %source, {{@type.name}}) { |test| test.as({{@type.name}}).%run }
|
||||
end
|
||||
|
||||
# Creates an example, or a test case.
|
||||
|
|
|
@ -18,6 +18,7 @@ require "./matchers"
|
|||
require "./formatting"
|
||||
|
||||
# Then all of the top-level types.
|
||||
require "./spec_builder"
|
||||
require "./example_component"
|
||||
require "./example"
|
||||
require "./runnable_example"
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
require "../builders/example_group_stack"
|
||||
require "./spec_builder/*"
|
||||
|
||||
module Spectator::DSL
|
||||
module Spectator
|
||||
# Global builder used to create the runtime instance of the spec.
|
||||
# The DSL methods call into this module to generate parts of the spec.
|
||||
# Once the DSL is done, the `#build` method can be invoked
|
||||
# to create the entire spec as a runtime instance.
|
||||
module Builder
|
||||
module SpecBuilder
|
||||
extend self
|
||||
|
||||
@@stack = Builders::ExampleGroupStack.new
|
||||
@@stack = ExampleGroupStack.new
|
||||
|
||||
# Begins a new nested group in the spec.
|
||||
# A corresponding `#end_group` call must be made
|
||||
|
@ -16,7 +16,7 @@ module Spectator::DSL
|
|||
# See `NestedExampleGroupBuilder#initialize` for the arguments
|
||||
# as arguments to this method are passed directly to it.
|
||||
def start_group(*args) : Nil
|
||||
group = Builders::NestedExampleGroupBuilder.new(*args)
|
||||
group = NestedExampleGroupBuilder.new(*args)
|
||||
@@stack.push(group)
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ module Spectator::DSL
|
|||
example_type : ::SpectatorTest.class, &runner : ::SpectatorTest ->) : Nil
|
||||
builder = ->{ example_type.new.as(::SpectatorTest) }
|
||||
wrapper = TestWrapper.new(description, source, builder, runner)
|
||||
factory = Builders::ExampleBuilder.new(wrapper)
|
||||
factory = ExampleBuilder.new(wrapper)
|
||||
@@stack.current.add_child(factory)
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module Spectator::Builders
|
||||
module Spectator::SpecBuilder
|
||||
class ExampleBuilder
|
||||
def initialize(@wrapper : TestWrapper)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require "./example_builder"
|
||||
|
||||
module Spectator::Builders
|
||||
module Spectator::SpecBuilder
|
||||
abstract class ExampleGroupBuilder
|
||||
alias Child = NestedExampleGroupBuilder | ExampleBuilder
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
require "./root_example_group_builder"
|
||||
require "./nested_example_group_builder"
|
||||
|
||||
module Spectator::Builders
|
||||
module Spectator::SpecBuilder
|
||||
struct ExampleGroupStack
|
||||
getter root
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
require "./example_group_builder"
|
||||
|
||||
module Spectator::Builders
|
||||
module Spectator::SpecBuilder
|
||||
class NestedExampleGroupBuilder < ExampleGroupBuilder
|
||||
def initialize(@what : String | Symbol)
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require "./example_group_builder"
|
||||
|
||||
module Spectator::Builders
|
||||
module Spectator::SpecBuilder
|
||||
class RootExampleGroupBuilder < ExampleGroupBuilder
|
||||
def build
|
||||
RootExampleGroup.new.tap do |group|
|
Loading…
Reference in a new issue