Skip to content

Commit 2810713

Browse files
committed
Restore Runner initialize.
1 parent df96206 commit 2810713

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

demo/01_test.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ a test. For instance, given an abtriray object defined as follows.
1515

1616
If we pass this to a test runner as part of a test suite,
1717

18-
runner = Test::Runner.new(:suite=>[test], :format=>'test')
18+
config = Test::Config.new(:suite=>[test], :format=>'test')
19+
runner = Test::Runner.new(config)
1920

2021
success = runner.run
2122

lib/rubytest/runner.rb

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,31 @@ class Runner
3535
# instance with, or a name of a configuration profile.
3636
#
3737
# @return [Boolean] Success of test run.
38-
def self.run(config=nil) #:yield:
39-
case config
40-
when Config
41-
when Hash
42-
config = Config.new(config)
43-
else
44-
config = Test.configuration(config)
45-
end
46-
47-
yeild(config) if block_given?
48-
49-
runner = Runner.new(config)
38+
def self.run(config=nil, &config_proc) #:yield:
39+
runner = Runner.new(config, &config_proc)
5040
runner.run
5141
end
5242

5343
# Exceptions that are not caught by test runner.
5444
OPEN_ERRORS = [NoMemoryError, SignalException, Interrupt, SystemExit]
5545

46+
# New Runner.
47+
#
48+
# @param [Config] config
49+
# Config instance.
50+
#
51+
def initialize(config) #:yield:
52+
@config = case config
53+
when Config then config
54+
when Hash then Config.new(config)
55+
else Test.configuration(config)
56+
end
57+
58+
yeild(@config) if block_given?
59+
60+
@advice = Advice.new
61+
end
62+
5663
# Handle all configuration via the config instance.
5764
attr :config
5865

@@ -102,16 +109,6 @@ def upon(type, &block)
102109
advice.join(type, &block)
103110
end
104111

105-
# New Runner.
106-
#
107-
# @param [Config] config
108-
# Config instance.
109-
#
110-
def initialize(config)
111-
@config = config
112-
@advice = Advice.new
113-
end
114-
115112
# The reporter to use for ouput.
116113
attr :reporter
117114

0 commit comments

Comments
 (0)