Class: Stories::ForrestScenarioRunner

Inherits:
Test::Unit::UI::Console::TestRunner
  • Object
show all
Defined in:
lib/forrest/scenario_runner.rb

Instance Method Summary collapse

Instance Method Details

#add_fault(fault) ⇒ Object



14
15
16
# File 'lib/forrest/scenario_runner.rb', line 14

def add_fault(fault)
  @faults << fault
end

#finished(elapsed_time) ⇒ Object



56
57
58
59
60
61
# File 'lib/forrest/scenario_runner.rb', line 56

def finished(elapsed_time)
  puts

  print_story
  super
end


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/forrest/scenario_runner.rb', line 27

def print_scenario
  @scenario.steps.each do |step|
    puts "      #{step}"
  end

  @scenario.assertions.each do |assertion|
    puts "      #{assertion}"
  end

  puts
end

#print_storyObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/forrest/scenario_runner.rb', line 39

def print_story
  puts "=" * 80
  puts "\n- #{colorize(@story.name, :bold)} \n\n"

  if @faults.empty?
    puts "    #{colorize(@scenario.name, :green)}"
  else
    puts "    #{colorize(@scenario.name, :red)}"
  end

  unless @scenario.steps.empty? && @scenario.assertions.empty?
    print_scenario
  end

  puts "=" * 80
end

#set_scenarioObject



23
24
25
# File 'lib/forrest/scenario_runner.rb', line 23

def set_scenario
  @scenario = @story.scenarios.find{|sc| sc.name == @scenario_name}
end

#set_storyObject



18
19
20
21
# File 'lib/forrest/scenario_runner.rb', line 18

def set_story
  s      ||= Story.new @suite.name
  @story ||= Stories.all[@story_name.constantize]
end

#test_finished(name) ⇒ Object



7
8
9
10
11
12
# File 'lib/forrest/scenario_runner.rb', line 7

def test_finished(name)
  @scenario_name = name.split("(")[0].gsub(/^test_/, "").humanize
  @story_name    = name.split("(")[1].gsub(/\)$/, "")
  set_story
  set_scenario
end