Class Spec::Story::Runner::StoryParser
In: vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb
Parent: Object

Methods

Classes and Modules

Class Spec::Story::Runner::StoryParser::GivenState
Class Spec::Story::Runner::StoryParser::ScenarioState
Class Spec::Story::Runner::StoryParser::StartingState
Class Spec::Story::Runner::StoryParser::State
Class Spec::Story::Runner::StoryParser::StoryState
Class Spec::Story::Runner::StoryParser::ThenState
Class Spec::Story::Runner::StoryParser::WhenState

Public Class methods

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 12
12:         def initialize(story_mediator)
13:           @story_mediator = story_mediator
14:           @current_story_lines = []
15:           transition_to(:starting_state)
16:         end

Public Instance methods

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 46
46:         def add_story_line(line)
47:           @current_story_lines << line
48:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 77
77:         def add_to_last(line)
78:           @story_mediator.add_to_last("\n#{line}")
79:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 61
61:         def create_given(name)
62:           @story_mediator.create_given(name)
63:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 65
65:         def create_given_scenario(name)
66:           @story_mediator.create_given_scenario(name)
67:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 57
57:         def create_scenario(title)
58:           @story_mediator.create_scenario(title.gsub("Scenario: ",""))
59:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 50
50:         def create_story()
51:           unless @current_story_lines.empty?
52:             @story_mediator.create_story(@current_story_lines[0].gsub("Story: ",""), @current_story_lines[1..-1].join("\n"))
53:             @current_story_lines.clear
54:           end
55:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 73
73:         def create_then(name)
74:           @story_mediator.create_then(name)
75:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 69
69:         def create_when(name)
70:           @story_mediator.create_when(name)
71:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 41
41:         def init_story(title)
42:           @current_story_lines.clear
43:           add_story_line(title)
44:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 18
18:         def parse(lines)
19:           lines.reject! {|line| line == ""}
20:           until lines.empty?
21:             process_line(lines.shift)
22:           end
23:           @state.eof
24:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 26
26:         def process_line(line)
27:           line.strip!
28:           case line
29:           when /^#/                 then @state.comment(line)
30:           when /^Story: /           then @state.story(line)
31:           when /^Scenario: /        then @state.scenario(line)
32:           when /^Given:? /          then @state.given(line)
33:           when /^GivenScenario:? /  then @state.given_scenario(line)
34:           when /^When:? /           then @state.event(line)
35:           when /^Then:? /           then @state.outcome(line)
36:           when /^And:? /            then @state.one_more_of_the_same(line)
37:           else                           @state.other(line)
38:           end
39:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 85
85:         def states
86:           @states ||= {
87:             :starting_state => StartingState.new(self),
88:             :story_state => StoryState.new(self),
89:             :scenario_state => ScenarioState.new(self),
90:             :given_state => GivenState.new(self),
91:             :when_state => WhenState.new(self),
92:             :then_state => ThenState.new(self)
93:           }
94:         end

[Source]

    # File vendor/plugins/rspec/lib/spec/story/runner/story_parser.rb, line 81
81:         def transition_to(key)
82:           @state = states[key]
83:         end

[Validate]