mcmire-protest 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  doc
2
2
  dist
3
+ *.gem
@@ -11,13 +11,18 @@ module Protest
11
11
  # and before and after each test case (+enter+ and +exit+.)
12
12
  def run(*test_cases)
13
13
  @report.on_start if @report.respond_to?(:on_start)
14
- test_cases.each do |test_case|
15
- @report.on_enter(test_case) if @report.respond_to?(:on_enter)
16
- test_case.run(self)
17
- @report.on_exit(test_case) if @report.respond_to?(:on_exit)
18
- end
14
+ test_cases.each {|test_case| run_test_case(test_case) }
19
15
  @report.on_end if @report.respond_to?(:on_end)
20
16
  end
17
+
18
+ # Run a test case, along with any child test cases. This will fire the +enter+
19
+ # event before running the test case and the +exit+ event afterward.
20
+ def run_test_case(test_case)
21
+ @report.on_enter(test_case) if @report.respond_to?(:on_enter)
22
+ sub_test_cases = Protest.send(:available_test_cases).select {|tc| tc.superclass == test_case }
23
+ test_case.run(self, sub_test_cases)
24
+ @report.on_exit(test_case) if @report.respond_to?(:on_exit)
25
+ end
21
26
 
22
27
  # Run a test and report if it passes, fails, or is pending. Takes the name
23
28
  # of the test as an argument. By passing +true+ as the second argument, you
@@ -31,16 +31,21 @@ module Protest
31
31
  rescue LoadError
32
32
  end
33
33
 
34
- # Run all tests in this context. Takes a Report instance in order to
35
- # provide output.
36
- def self.run(runner)
34
+ # Run all tests in this context, then run any test cases under this test case.
35
+ # Takes a Report instance in order to provide output. <tt>global_setup</tt>
36
+ # will be run before the first test is run; <tt>global_teardown</tt> will
37
+ # be run after the final test is run (including any tests in child test cases).
38
+ def self.run(runner, sub_test_cases)
37
39
  runner.report(TestWrapper.new(:setup, self), true)
38
40
  tests.each {|test| runner.report(test, false) }
41
+ sub_test_cases.each {|test_case| runner.run_test_case(test_case) }
39
42
  runner.report(TestWrapper.new(:teardown, self), true)
40
43
  rescue Exception => e
41
44
  # If any exception bubbles up here, then it means it was during the
42
45
  # global setup/teardown blocks, so let's just skip the rest of this
43
46
  # context.
47
+ #warn "#{e.class}: #{e.message}"
48
+ #warn e.backtrace.join("\n")
44
49
  return
45
50
  end
46
51
 
@@ -81,7 +86,7 @@ module Protest
81
86
  def self.global_setup(&block)
82
87
  (class << self; self; end).class_eval do
83
88
  define_method :do_global_setup do
84
- super()
89
+ #super()
85
90
  instance_eval(&block)
86
91
  end
87
92
  end
@@ -110,7 +115,7 @@ module Protest
110
115
  (class << self; self; end).class_eval do
111
116
  define_method :do_global_teardown do
112
117
  instance_eval(&block)
113
- super()
118
+ #super()
114
119
  end
115
120
  end
116
121
  end
data/lib/protest.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Protest
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
 
4
4
  # Exception raised when an assertion fails. See TestCase#assert
5
5
  class AssertionFailed < StandardError; end
@@ -45,7 +45,7 @@ module Protest
45
45
  #
46
46
  # See Protest.add_test_case and Protest.report_with
47
47
  def self.run_all_tests!(*report_args)
48
- Runner.new(@report).run(*available_test_cases)
48
+ Runner.new(@report).run(*root_test_cases)
49
49
  end
50
50
 
51
51
  # Select the name of the Report to use when running tests. See
@@ -76,6 +76,12 @@ module Protest
76
76
  @backtrace_filter
77
77
  end
78
78
 
79
+ def self.root_test_cases
80
+ v = available_test_cases.select {|tc| tc.superclass == Protest::TestCase }
81
+ #pp :root_test_cases => v
82
+ v
83
+ end
84
+
79
85
  def self.available_test_cases
80
86
  @test_cases ||= []
81
87
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mcmire-protest"
3
- s.version = "0.2.5"
3
+ s.version = "0.3.0"
4
4
  s.date = "2010-01-10"
5
5
 
6
6
  s.description = "Protest is a tiny, simple, and easy-to-extend test framework"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcmire-protest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Nicol\xC3\xA1s Sanguinetti"