lib/gurke/configuration.rb in gurke-2.4.2 vs lib/gurke/configuration.rb in gurke-3.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require 'forwardable' module Gurke class Configuration # @@ -72,11 +74,11 @@ scenario: HookSet.new, step: HookSet.new, system: HookSet.new } - hooks.merge! each: hooks[:scenario] + hooks[:each] = hooks[:scenario] hooks end end # @api private @@ -124,29 +126,30 @@ end end def run(context, world, &block) ctx = Context.new context, block - @before.each{|hook| hook.run world, ctx } + @before.each {|hook| hook.run world, ctx } @around.reduce Context.new(context, block) do |c, e| - Context.new(context, ->{ e.run world, c }) + Context.new(context, -> { e.run world, c }) end.call ensure @after.each do |hook| begin hook.run world, ctx - rescue => e + rescue StandardError => e warn "Rescued error in after hook: #{e}\n#{e.backtrace.join("\n")}" end end end class Context extend Forwardable def initialize(context, block) - @context, @block = context, block + @context = context + @block = block end def tags @context.tags.map(&:name) end @@ -169,10 +172,10 @@ @opts = opts @block = block end def match?(context) - !opts.any?{|k, v| context.metadata[k] != v } + opts.none? {|k, v| context.metadata[k] != v } end def run(world, *args) block = @block if world