Module: Spec::Story::World

Module | Spec::Story::World
In: | lib/spec/story/world.rb

### Methods

And Given GivenScenario Then When add_listener create errors errors listeners run_given_scenario_with_suspended_listeners start_collecting_errors step_mother step_names store_and_call use

### Included Modules

::Spec::Example::Pending ::Spec::Matchers

### Public Class methods

add_listener(listener)

[Source]

        # File lib/spec/story/world.rb, line 31
    31:         def add_listener(listener)
    32:           listeners() << listener
    33:         end

create(cls = Object, *args)

[Source]

        # File lib/spec/story/world.rb, line 23
    23:         def create(cls = Object, *args)
    24:           cls.new(*args).extend(World)
    25:         end

errors()

[Source]

        # File lib/spec/story/world.rb, line 87
    87:         def errors
    88:           @errors ||= []
    89:         end

listeners()

[Source]

        # File lib/spec/story/world.rb, line 27
    27:         def listeners
    28:           @listeners ||= []
    29:         end

run_given_scenario_with_suspended_listeners(world, type, name, scenario)

[Source]

        # File lib/spec/story/world.rb, line 47
    47:         def run_given_scenario_with_suspended_listeners(world, type, name, scenario)
    48:           current_listeners = Array.new(listeners)
    49:           begin
    50:             listeners.each { |l| l.found_scenario(type, name) }
    51:             @listeners.clear
    52:             scenario.perform(world, name) unless ::Spec::Story::Runner.dry_run
    53:           ensure
    54:             @listeners.replace(current_listeners)
    55:           end
    56:         end

step_mother()

[Source]

        # File lib/spec/story/world.rb, line 35
    35:         def step_mother
    36:           @step_mother ||= StepMother.new
    37:         end

step_names()

[Source]

        # File lib/spec/story/world.rb, line 43
    43:         def step_names
    44:           @step_names ||= []
    45:         end

store_and_call(world, type, name, *args, &block)

[Source]

        # File lib/spec/story/world.rb, line 58
    58:         def store_and_call(world, type, name, *args, &block)
    59:           if block_given?
    60:             step_mother.store(type, Step.new(name, &block))
    61:           end
    62:           step = step_mother.find(type, name)
    63:
    64:           step_name = step.name
    65:           step_names << step_name
    66:
    67:           # It's important to have access to the parsed args here, so
    68:           # we can give them to the listeners. The HTML reporter needs
    69:           # the args so it can style them. See the generated output in
    70:           # story_server/prototype/rspec_stories.html (generated by rake stories)
    71:           args = step.parse_args(name) if args.empty?
    72:           begin
    73:             listeners.each { |l| l.step_upcoming(type, step_name, *args) }
    74:             step.perform(world, *args) unless ::Spec::Story::Runner.dry_run
    75:             listeners.each { |l| l.step_succeeded(type, step_name, *args) }
    76:           rescue Exception => e
    77:             case e
    78:             when Spec::Example::ExamplePendingError
    79:               @listeners.each { |l| l.step_pending(type, step_name, *args) }
    80:             else
    81:               @listeners.each { |l| l.step_failed(type, step_name, *args) }
    82:             end
    83:             errors << e
    84:           end
    85:         end

use(steps)

[Source]

        # File lib/spec/story/world.rb, line 39
    39:         def use(steps)
    40:           step_mother.use(steps)
    41:         end

### Public Instance methods

And(name, *args, &block)

[Source]

         # File lib/spec/story/world.rb, line 120
    120:       def And(name, *args, &block)
    121:         World.store_and_call self, @__previous_step, name, *args, &block
    122:       end

Given(name, *args, &block)

[Source]

         # File lib/spec/story/world.rb, line 105
    105:       def Given(name, *args, &block)
    106:         World.store_and_call self, :given, name, *args, &block
    107:         @__previous_step = :given
    108:       end

GivenScenario(name)

[Source]

         # File lib/spec/story/world.rb, line 100
    100:       def GivenScenario(name)
    101:         World.run_given_scenario_with_suspended_listeners(self, 'given scenario''given scenario', name, GivenScenario.new(name))
    102:         @__previous_step = :given
    103:       end

Then(name, *args, &block)

[Source]

         # File lib/spec/story/world.rb, line 115
    115:       def Then(name, *args, &block)
    116:         World.store_and_call self, :then, name, *args, &block
    117:         @__previous_step = :then
    118:       end

When(name, *args, &block)

[Source]

         # File lib/spec/story/world.rb, line 110
    110:       def When(name, *args, &block)
    111:         World.store_and_call self, :when, name, *args, &block
    112:         @__previous_step = :when
    113:       end

errors()

[Source]

        # File lib/spec/story/world.rb, line 96
    96:       def errors
    97:         World.errors
    98:       end

start_collecting_errors()

[Source]

        # File lib/spec/story/world.rb, line 92
    92:       def start_collecting_errors
    93:         errors.clear
    94:       end

[Validate]