Class: Waw::WSpec::Suite

Inherits:
Object show all
Defined in:
lib/waw/wspec/suite.rb

Overview

A suite of wspec scenarios

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenarios) ⇒ Suite

Creates a suite with given scenarios



16
17
18
19
# File 'lib/waw/wspec/suite.rb', line 16

def initialize(scenarios)
  @scenarios = scenarios
  @assertion_count, @failure_count, @error_count = 0, 0, 0
end

Instance Attribute Details

#assertion_countObject

How many assertions?



7
8
9
# File 'lib/waw/wspec/suite.rb', line 7

def assertion_count
  @assertion_count
end

#error_countObject

How many errors?



13
14
15
# File 'lib/waw/wspec/suite.rb', line 13

def error_count
  @error_count
end

#failure_countObject

How many failures?



10
11
12
# File 'lib/waw/wspec/suite.rb', line 10

def failure_count
  @failure_count
end

Instance Method Details

#run(waw_kernel) ⇒ Object

Runs the suite



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/waw/wspec/suite.rb', line 27

def run(waw_kernel)
  @scenarios.each do |sc|
    begin
      STDOUT.write('.')
      STDOUT.flush
      sc.run(waw_kernel)
      self.assertion_count += sc.assertion_count
    rescue Test::Unit::AssertionFailedError => ex
      # for ruby 1.8.6
      puts "\nAssertion failed #{sc.name}: #{ex.message}"
      puts ex.backtrace[0]
      self.failure_count += 1
    rescue MiniTest::Assertion => ex
      # for ruby 1.9.1
      puts "\nAssertion failed #{sc.name}: #{ex.message}"
      puts ex.backtrace[0]
      self.failure_count += 1
    rescue Exception => ex
      puts "Fatal error #{sc.name}: #{ex.message}"
      puts ex.backtrace.join("\n")
      self.error_count += 1
    end
  end
end

#scenario_countObject

How many scenarios?



22
23
24
# File 'lib/waw/wspec/suite.rb', line 22

def scenario_count
  @scenarios.size
end