Short-hand syntax for blocks with yield

This commit is contained in:
Michael Miller 2018-09-27 18:49:01 -06:00
parent d670d96045
commit 4948fe0c6f
3 changed files with 7 additions and 7 deletions

View file

@ -17,11 +17,11 @@ module Spectator
end end
def examples : Enumerable(Example) def examples : Enumerable(Example)
children.compact_map { |child| child.as?(Example) } children.compact_map &.as?(Example)
end end
def groups : Enumerable(ExampleGroup) def groups : Enumerable(ExampleGroup)
children.compact_map { |child| child.as?(ExampleGroup) } children.compact_map &.as?(ExampleGroup)
end end
def example_count def example_count

View file

@ -20,19 +20,19 @@ module Spectator
end end
def run_before_all def run_before_all
@before_all.each(&.call) @before_all.each &.call
end end
def run_before_each def run_before_each
@before_each.each(&.call) @before_each.each &.call
end end
def run_after_all def run_after_all
@after_all.each(&.call) @after_all.each &.call
end end
def run_after_each def run_after_each
@after_each.each(&.call) @after_each.each &.call
end end
def wrap_around_each(&block : ->) def wrap_around_each(&block : ->)

View file

@ -37,7 +37,7 @@ module Spectator
end end
def example_runtime def example_runtime
@results.map { |result| result.elapsed }.sum @results.map(&.elapsed).sum
end end
def overhead_time def overhead_time