Class: Spec::Story::Runner::StoryMediator

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/story/runner/story_mediator.rb

Defined Under Namespace

Classes: Scenario, Step, Story

Instance Method Summary collapse

Constructor Details

#initialize(step_group, runner, options = {}) ⇒ StoryMediator

Returns a new instance of StoryMediator.



6
7
8
9
10
11
# File 'lib/spec/story/runner/story_mediator.rb', line 6

def initialize(step_group, runner, options={})
  @step_group = step_group
  @stories = []
  @runner = runner
  @options = options
end

Instance Method Details

#add_to_last(name) ⇒ Object



45
46
47
# File 'lib/spec/story/runner/story_mediator.rb', line 45

def add_to_last(name)
  last_step.name << name
end

#create_given(name) ⇒ Object



25
26
27
# File 'lib/spec/story/runner/story_mediator.rb', line 25

def create_given(name)
  current_scenario.add_step Step.new('Given', name)
end

#create_given_scenario(name) ⇒ Object



29
30
31
# File 'lib/spec/story/runner/story_mediator.rb', line 29

def create_given_scenario(name)
  current_scenario.add_step Step.new('GivenScenario', name)
end

#create_scenario(title) ⇒ Object



21
22
23
# File 'lib/spec/story/runner/story_mediator.rb', line 21

def create_scenario(title)
  current_story.add_scenario Scenario.new(title)
end

#create_story(title, narrative) ⇒ Object



17
18
19
# File 'lib/spec/story/runner/story_mediator.rb', line 17

def create_story(title, narrative)
  @stories << Story.new(title, narrative, @step_group, @options)
end

#create_then(name) ⇒ Object



37
38
39
# File 'lib/spec/story/runner/story_mediator.rb', line 37

def create_then(name)
  current_scenario.add_step Step.new('Then', name)
end

#create_when(name) ⇒ Object



33
34
35
# File 'lib/spec/story/runner/story_mediator.rb', line 33

def create_when(name)
  current_scenario.add_step Step.new('When', name)
end

#last_stepObject



41
42
43
# File 'lib/spec/story/runner/story_mediator.rb', line 41

def last_step
  current_scenario.last_step
end

#run_storiesObject



49
50
51
# File 'lib/spec/story/runner/story_mediator.rb', line 49

def run_stories
  stories.each { |story| @runner.instance_eval(&story) }
end

#storiesObject



13
14
15
# File 'lib/spec/story/runner/story_mediator.rb', line 13

def stories
  @stories.collect { |p| p.to_proc }
end