Sha256: 2cfbb98247f89c695b2376f79e94fcd9130b20cb2b23f371baba9dc2940e6f9f

Contents?: true

Size: 1.32 KB

Versions: 21

Compression:

Stored size: 1.32 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

21 entries across 21 versions & 4 rubygems

Version Path
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
picolena-0.1.0 rails_plugins/rspec/lib/spec/story/runner/scenario_runner.rb
picolena-0.1.1 rails_plugins/rspec/lib/spec/story/runner/scenario_runner.rb
picolena-0.1.3 rails_plugins/rspec/lib/spec/story/runner/scenario_runner.rb
picolena-0.1.4 rails_plugins/rspec/lib/spec/story/runner/scenario_runner.rb
picolena-0.1.2 rails_plugins/rspec/lib/spec/story/runner/scenario_runner.rb
picolena-0.1.5 rails_plugins/rspec/lib/spec/story/runner/scenario_runner.rb
rspec-1.1.1 lib/spec/story/runner/scenario_runner.rb
rspec-1.1.0 lib/spec/story/runner/scenario_runner.rb
rspec-1.1.2 lib/spec/story/runner/scenario_runner.rb
rspec-1.1.3 lib/spec/story/runner/scenario_runner.rb
spree-0.2.0 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.0.2 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.0.1 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.0.3.98.1 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.0.3.98 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.0 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.1.2 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.1.1 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
typo-5.1.3 vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb