Change "description" to "what" for consistency

This commit is contained in:
Michael Miller 2018-10-14 11:50:08 -06:00
parent 68412daec0
commit 3facf3af9d
2 changed files with 10 additions and 10 deletions

View file

@ -110,10 +110,10 @@ module Spectator::DSL
raise NotImplementedError.new("Spectator::DSL#include_examples") raise NotImplementedError.new("Spectator::DSL#include_examples")
end end
macro it(description, &block) macro it(what, &block)
_spectator_example_wrapper(Wrapper%example, %run) {{block}} _spectator_example_wrapper(Wrapper%example, %run) {{block}}
_spectator_example(Example%example, Wrapper%example, ::Spectator::RunnableExample, {{description}}) do _spectator_example(Example%example, Wrapper%example, ::Spectator::RunnableExample, {{what}}) do
protected def run_instance protected def run_instance
@instance.%run @instance.%run
end end
@ -122,10 +122,10 @@ module Spectator::DSL
::Spectator::DSL::Builder.add_example(Example%example) ::Spectator::DSL::Builder.add_example(Example%example)
end end
macro pending(description, &block) macro pending(what, &block)
_spectator_example_wrapper(Wrapper%example, %run) {{block}} _spectator_example_wrapper(Wrapper%example, %run) {{block}}
_spectator_example(Example%example, Wrapper%example, ::Spectator::PendingExample, {{description}}) _spectator_example(Example%example, Wrapper%example, ::Spectator::PendingExample, {{what}})
::Spectator::DSL::Builder.add_example(Example%example) ::Spectator::DSL::Builder.add_example(Example%example)
end end
@ -176,7 +176,7 @@ module Spectator::DSL
end end
end end
private macro _spectator_example(example_class_name, wrapper_class_name, base_class, description, &block) private macro _spectator_example(example_class_name, wrapper_class_name, base_class, what, &block)
class {{example_class_name.id}} < {{base_class.id}} class {{example_class_name.id}} < {{base_class.id}}
def initialize(group : ::Spectator::ExampleGroup, sample_values : ::Spectator::Internals::SampleValues) def initialize(group : ::Spectator::ExampleGroup, sample_values : ::Spectator::Internals::SampleValues)
super super
@ -187,8 +187,8 @@ module Spectator::DSL
{{block.body}} {{block.body}}
{% end %} {% end %}
def description def what
{{description.is_a?(StringLiteral) ? description : description.stringify}} {{what.is_a?(StringLiteral) ? what : what.stringify}}
end end
end end
end end

View file

@ -1,6 +1,6 @@
module Spectator module Spectator
# Base class for all types of examples. # Base class for all types of examples.
# Concrete types must implement the `#run_inner` and `#description` methods. # Concrete types must implement the `#run_inner` and `#what` methods.
abstract class Example abstract class Example
# Indicates whether the example has already been run. # Indicates whether the example has already been run.
getter? finished = false getter? finished = false
@ -22,7 +22,7 @@ module Spectator
private abstract def run_inner : Result private abstract def run_inner : Result
# Message that describes what the example tests. # Message that describes what the example tests.
abstract def description : String abstract def what : String
# Creates the base of the example. # Creates the base of the example.
# The group should be the example group the example belongs to. # The group should be the example group the example belongs to.
@ -36,7 +36,7 @@ module Spectator
def to_s(io) def to_s(io)
@group.to_s(io) @group.to_s(io)
io << ' ' io << ' '
io << description io << what
end end
end end
end end