lib/lopata/step.rb in lopata-0.1.5 vs lib/lopata/step.rb in lopata-0.1.6

- old
+ new

@@ -77,10 +77,14 @@ end steps.reject! { |s| !s.block } steps.reject { |s| s.teardown_group?(self) } + steps.select { |s| s.teardown_group?(self) } end + def let_methods + @let_methods ||= {} + end + private # Group step's block is a block in context of builder, not scenario. So hide the @block to not be used in scenario. def initialized! builder = Lopata::ScenarioBuilder.new(title) @@ -110,11 +114,10 @@ "#{group_title}#{step.title}" end def run(scenario) @status = :running - world.notify_observers(:step_started, self) begin run_step(scenario) if pending? @status = :failed raise PendingStepFixedError, 'Expected step to fail since it is pending, but it passed.' @@ -123,22 +126,17 @@ end rescue Exception => e @status = :failed unless pending? @exception = e end - world.notify_observers(:step_finished, self) end def run_step(scenario) return unless block scenario.instance_exec(&block) end - def world - @world ||= Lopata::Config.world - end - def failed? status == :failed end def passed? @@ -174,9 +172,14 @@ %i{ setup action }.include?(method_name) end # Step metadata is a combination of metadata given for step and all contexts (groups) the step included def metadata - ([step] + groups).compact.inject({}) { |merged, part| merged.merge(part.metadata) } + (groups + [step]).compact.inject({}) { |merged, part| merged.merge(part.metadata) } + end + + # Step methods is a combination of let_methods for all contexts (group) the step included + def let_methods + (groups).compact.inject({}) { |merged, part| merged.merge(part.let_methods) } end end end