class Lopata::Scenario::Execution
@private Scenario
execution and live-cycle information
Attributes
current_step[R]
scenario[R]
status[R]
steps[R]
title[R]
Public Class Methods
new(title, options_title, metadata = {})
click to toggle source
# File lib/lopata/scenario.rb, line 59 def initialize(title, options_title, metadata = {}) @title = [title, options_title].compact.reject(&:empty?).join(' ') @metadata = metadata @let_methods = {} @status = :not_runned @steps = [] @scenario = Lopata::Scenario.new(self) end
Public Instance Methods
cleanup()
click to toggle source
# File lib/lopata/scenario.rb, line 129 def cleanup @title = nil @metadata = nil @steps = nil @scenario = nil end
failed?()
click to toggle source
# File lib/lopata/scenario.rb, line 90 def failed? status == :failed end
let(method_name, &block)
click to toggle source
# File lib/lopata/scenario.rb, line 118 def let(method_name, &block) # define_singleton_method method_name, &block base = if current_step && !current_step.groups.empty? current_step.groups.last.let_methods else @let_methods end base[method_name] = block end
let_methods()
click to toggle source
# File lib/lopata/scenario.rb, line 110 def let_methods if current_step @let_methods.merge(current_step.let_methods) else @let_methods end end
metadata()
click to toggle source
# File lib/lopata/scenario.rb, line 102 def metadata if current_step @metadata.merge(current_step.metadata) else @metadata end end
run()
click to toggle source
# File lib/lopata/scenario.rb, line 68 def run @status = :running sort_steps world.notify_observers(:scenario_started, self) steps.each(&method(:run_step)) @status = steps.any?(&:failed?) ? :failed : :passed world.notify_observers(:scenario_finished, self) cleanup end
run_step(step)
click to toggle source
# File lib/lopata/scenario.rb, line 78 def run_step(step) return if step.skipped? @current_step = step step.run(scenario) skip_rest if step.failed? && step.skip_rest_on_failure? @current_step = nil end
skip_rest()
click to toggle source
# File lib/lopata/scenario.rb, line 98 def skip_rest steps.select { |s| s.status == :not_runned && !s.teardown? }.each(&:skip!) end
sort_steps()
click to toggle source
# File lib/lopata/scenario.rb, line 94 def sort_steps @steps = steps.reject(&:teardown_group?) + steps.select(&:teardown_group?) end
world()
click to toggle source
# File lib/lopata/scenario.rb, line 86 def world Lopata.world end