Skip to content

Commit f3d910c

Browse files
committed
Block configs are lazy.
1 parent ecdd02f commit f3d910c

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

lib/rubytest.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def self.const_missing(name)
3030
require 'rubytest/recorder'
3131
require 'rubytest/advice'
3232
require 'rubytest/runner'
33-
require 'rubytest/cli'
3433
require 'rubytest/reporters/abstract'
3534
require 'rubytest/reporters/abstract_hash'
3635
else
@@ -40,7 +39,6 @@ def self.const_missing(name)
4039
require_relative 'rubytest/recorder'
4140
require_relative 'rubytest/advice'
4241
require_relative 'rubytest/runner'
43-
require_relative 'rubytest/cli'
4442
require_relative 'rubytest/reporters/abstract'
4543
require_relative 'rubytest/reporters/abstract_hash'
4644
end

lib/rubytest/autorun.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'rubytest'
22

33
at_exit {
4-
success = Test.run
4+
success = Test.run!(ENV['profile'] || ENV['p'])
55
exit -1 unless success
66
}
77

lib/rubytest/config.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ def initialize(settings={}, &block)
116116

117117
#apply_environment
118118

119-
apply(settings, &block)
119+
apply(settings)
120+
121+
# save for lazy execution
122+
@block = block
123+
end
124+
125+
# Apply lazy block.
126+
def apply!
127+
@block.call(self) if @block
120128
end
121129

122130
# Evaluate configuration block.
@@ -129,6 +137,16 @@ def apply(hash={}, &block)
129137
block.call(self) if block
130138
end
131139

140+
#
141+
def name
142+
@name
143+
end
144+
145+
#
146+
def name=(name)
147+
@name = name.to_s if name
148+
end
149+
132150
# Default test suite ($TEST_SUITE).
133151
#
134152
# @return [Array]
@@ -351,6 +369,8 @@ def mode=(type)
351369
# Convert configuration to shell options, compatible with the
352370
# rubytest command line.
353371
#
372+
# DEPRECATE: Shell command is considered bad approach.
373+
#
354374
# @return [Array<String>]
355375
def to_shellwords
356376
argv = []

lib/rubytest/runner.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def initialize(config) #:yield:
5555
else Test.configuration(config)
5656
end
5757

58-
yeild(@config) if block_given?
58+
@config.apply! # apply lazy config block
59+
60+
yield(@config) if block_given?
5961

6062
@advice = Advice.new
6163
end

0 commit comments

Comments
 (0)