Class: Spec::Story::StepGroup

Class | Spec::Story::StepGroup
In: | lib/spec/story/step_group.rb
Parent: | Object

### Methods

<< Given GivenScenario Then When add add_to clear create_matcher empty? find given given_scenario new steps then when

### Public Class methods

new(init_defaults=true, &block)

[Source]

        # File lib/spec/story/step_group.rb, line 19
    19:       def initialize(init_defaults=true, &block)
    20:         @hash_of_lists_of_steps = Hash.new {|h, k| h[k] = []}
    21:         if init_defaults
    22:           self.class.steps.add_to(self)
    23:         end
    24:         instance_eval(&block) if block
    25:       end

steps(&block)

[Source]

        # File lib/spec/story/step_group.rb, line 13
    13:       def self.steps(&block)
    14:         @step_group ||= StepGroup.new(false)
    15:         @step_group.instance_eval(&block) if block
    16:         @step_group
    17:       end

### Public Instance methods

<<(other_step_matchers)

[Source]

        # File lib/spec/story/step_group.rb, line 76
    76:       def <<(other_step_matchers)
    77:         other_step_matchers.add_to(self) if other_step_matchers.respond_to?(:add_to)
    78:       end

Given(name, &block)

[Source]

        # File lib/spec/story/step_group.rb, line 38
    38:       def Given(name, &block)
    39:         create_matcher(:given, name, &block)
    40:       end

GivenScenario(name, &block)

[Source]

        # File lib/spec/story/step_group.rb, line 34
    34:       def GivenScenario(name, &block)
    35:         create_matcher(:given_scenario, name, &block)
    36:       end

Then(name, &block)

[Source]

        # File lib/spec/story/step_group.rb, line 46
    46:       def Then(name, &block)
    47:         create_matcher(:then, name, &block)
    48:       end

When(name, &block)

[Source]

        # File lib/spec/story/step_group.rb, line 42
    42:       def When(name, &block)
    43:         create_matcher(:when, name, &block)
    44:       end

add(type, steps)

[Source]

        # File lib/spec/story/step_group.rb, line 55
    55:       def add(type, steps)
    56:         (@hash_of_lists_of_steps[type] << steps).flatten!
    57:       end

add_to(other_step_matchers)

[Source]

        # File lib/spec/story/step_group.rb, line 70
    70:       def add_to(other_step_matchers)
    71:         [:given_scenario, :given, :when, :then].each do |type|
    72:           other_step_matchers.add(type, @hash_of_lists_of_steps[type])
    73:         end
    74:       end

clear()

[Source]

        # File lib/spec/story/step_group.rb, line 59
    59:       def clear
    60:         @hash_of_lists_of_steps.clear
    61:       end

create_matcher(type, name, &block)

TODO - make me private

[Source]

        # File lib/spec/story/step_group.rb, line 81
    81:       def create_matcher(type, name, &block)
    82:         matcher = Step.new(name, &block)
    83:         @hash_of_lists_of_steps[type] << matcher
    84:         matcher
    85:       end

empty?()

[Source]

        # File lib/spec/story/step_group.rb, line 63
    63:       def empty?
    64:         [:given_scenario, :given, :when, :then].each do |type|
    65:           return false unless @hash_of_lists_of_steps[type].empty?
    66:         end
    67:         return true
    68:       end

find(type, name)

[Source]

        # File lib/spec/story/step_group.rb, line 27
    27:       def find(type, name)
    28:         @hash_of_lists_of_steps[type].each do |step|
    29:           return step if step.matches?(name)
    30:         end
    31:         return nil
    32:       end

given(name, &block)

Alias for Given

given_scenario(name, &block)

Alias for GivenScenario

then(name, &block)

Alias for Then

when(name, &block)

Alias for When

[Validate]