Default reason for missing example block "Not yet implemented"

This commit is contained in:
Michael Miller 2021-06-11 21:16:46 -06:00
parent 6f4cc12dfd
commit bfbeaf7454
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
3 changed files with 10 additions and 6 deletions

View file

@ -68,7 +68,8 @@ module Spectator::DSL
::Spectator::DSL::Builder.add_pending_example( ::Spectator::DSL::Builder.add_pending_example(
_spectator_example_name(\{{what}}), _spectator_example_name(\{{what}}),
::Spectator::Location.new(\{{what.filename}}, \{{what.line_number}}), ::Spectator::Location.new(\{{what.filename}}, \{{what.line_number}}),
\%tags \%tags,
"Not yet implemented"
) )
\{% end %} \{% end %}
end end
@ -110,7 +111,8 @@ module Spectator::DSL
::Spectator::DSL::Builder.add_pending_example( ::Spectator::DSL::Builder.add_pending_example(
_spectator_example_name(\{{what}}), _spectator_example_name(\{{what}}),
::Spectator::Location.new(\{{(what || block).filename}}, \{{(what || block).line_number}}, \{{(what || block).end_line_number}}), ::Spectator::Location.new(\{{(what || block).filename}}, \{{(what || block).line_number}}, \{{(what || block).end_line_number}}),
\%tags \%tags,
"Not yet implemented"
) )
end end
end end

View file

@ -74,8 +74,9 @@ module Spectator
# A set of *tags* can be used for filtering and modifying example behavior. # A set of *tags* can be used for filtering and modifying example behavior.
# Note: The tags will not be merged with the parent tags. # Note: The tags will not be merged with the parent tags.
def self.pending(name : String? = nil, location : Location? = nil, def self.pending(name : String? = nil, location : Location? = nil,
group : ExampleGroup? = nil, tags = Tags.new) group : ExampleGroup? = nil, tags = Tags.new, reason = nil)
tags = tags.merge({:pending => nil}) { |_, v, _| v } # Add pending tag if it doesn't exist. # Add pending tag and reason if they don't exist.
tags = tags.merge({:pending => nil, :reason => reason}) { |_, v, _| v }
new(name, location, group, tags) { nil } new(name, location, group, tags) { nil }
end end

View file

@ -116,11 +116,12 @@ module Spectator
# #
# A set of *tags* can be used for filtering and modifying example behavior. # A set of *tags* can be used for filtering and modifying example behavior.
# For instance, adding a "pending" tag will mark the test as pending and skip execution. # For instance, adding a "pending" tag will mark the test as pending and skip execution.
# A default *reason* can be given in case the user didn't provide one.
# #
# The newly created example is returned. # The newly created example is returned.
def add_pending_example(name, location, tags = Tags.new) : Example def add_pending_example(name, location, tags = Tags.new, reason = nil) : Example
Log.trace { "Add pending example: #{name} @ #{location}; tags: #{tags}" } Log.trace { "Add pending example: #{name} @ #{location}; tags: #{tags}" }
Example.pending(name, location, current_group, tags) Example.pending(name, location, current_group, tags, reason)
# The example is added to the current group by `Example` initializer. # The example is added to the current group by `Example` initializer.
end end