Module: RBehave::Runner

Defined in:
lib/rbehave/runner.rb,
lib/rbehave/runner/options.rb,
lib/rbehave/runner/story_runner.rb,
lib/rbehave/runner/scenario_runner.rb,
lib/rbehave/runner/scenario_collector.rb

Defined Under Namespace

Classes: Options, ScenarioCollector, ScenarioRunner, StoryRunner

Class Method Summary collapse

Class Method Details

.dry_runObject



43
44
45
# File 'lib/rbehave/runner.rb', line 43

def dry_run
  options.dry_run
end

.optionsObject



4
5
6
# File 'lib/rbehave/runner.rb', line 4

def options
  @options ||= Options.new.parse ARGV
end

.register_exit_hookObject



33
34
35
36
37
38
39
40
41
# File 'lib/rbehave/runner.rb', line 33

def register_exit_hook
  Exception.add_backtrace_filter(/lib\/rbehave/)
  Exception.add_backtrace_filter(/gems\/rbehave/)
  Exception.add_backtrace_filter(/gems\/rspec/)
  at_exit do
    RBehave::Runner.story_runner.run_stories unless $!
    # TODO exit with non-zero status if run fails
  end
end

.story_runnerObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rbehave/runner.rb', line 8

def story_runner
  unless @story_runner
    scenario_runner = ScenarioRunner.new
    RBehave::Runner.register_exit_hook
    world_creator = World
    @story_runner = StoryRunner.new(scenario_runner, world_creator)
    unless options.dry_run
      reporter = RBehave::Reporter::PlainTextReporter.new($stdout)
      scenario_runner.add_listener(reporter)
      @story_runner.add_listener(reporter)
    end
    case options.format
    when :simple then documenter = RBehave::Documenter::PlainTextDocumenter.new($stdout)
    when nil ;
    else raise "Unimplemented format - #{options.format.to_s}"
    end
    if documenter
      scenario_runner.add_listener(documenter)
      @story_runner.add_listener(documenter)
      world_creator.add_listener(documenter)
    end
  end
  @story_runner
end