Sha256: d470773d8a545b13eaf7149265e7d5ad13060b179d9c23d38b93cd2d9ec6b5b3
Contents?: true
Size: 1.28 KB
Versions: 3
Compression:
Stored size: 1.28 KB
Contents
module Spec module Story module Runner class ScenarioRunner def initialize @listeners = [] end def run(scenario, world) @listeners.each { |l| l.scenario_started(scenario.story.title, scenario.name) } run_story_ignoring_scenarios(scenario.story, world) world.start_collecting_errors world.instance_eval(&scenario.body) if world.errors.empty? @listeners.each { |l| l.scenario_succeeded(scenario.story.title, scenario.name) } else if Spec::Example::ExamplePendingError === (e = world.errors.first) @listeners.each { |l| l.scenario_pending(scenario.story.title, scenario.name, e.message) } else @listeners.each { |l| l.scenario_failed(scenario.story.title, scenario.name, e) } end end end def add_listener(listener) @listeners << listener end private def run_story_ignoring_scenarios(story, world) class << world def Scenario(name, &block) # do nothing end end story.run_in(world) class << world remove_method(:Scenario) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems