Retrieve test value for sample group

This commit is contained in:
Michael Miller 2019-09-26 14:57:31 -06:00
parent f6e95719ad
commit c3ea34e762

View file

@ -26,22 +26,25 @@ module Spectator
context({{what}}) {{block}} context({{what}}) {{block}}
end end
macro sample(what, &block) macro sample(collection, &block)
{% block_arg = block.args.empty? ? :value.id : block.args.first.id %} {% block_arg = block.args.empty? ? :value.id : block.args.first.id %}
class Sample%sample < {{@type.id}}
def %collection def %collection
{{what}} {{collection}}
end end
def %to_a
%collection.to_a
end end
class Context%sample < {{@type.id}} class Context%sample < {{@type.id}}
::Spectator::SpecBuilder.start_sample_group({{what.stringify}}, :%sample) do |values| ::Spectator::SpecBuilder.start_sample_group({{collection.stringify}}, :%sample) do |values|
sample = Sample%sample.new(values) sample = {{@type.id}}.new(values)
sample.%collection.to_a sample.%to_a
end end
def {{block_arg}} def {{block_arg}}
1 @spectator_test_values.get_value(:%sample, typeof(%to_a.first))
end end
{{block.body}} {{block.body}}