Skip to content

Commit

Permalink
Block configs are lazy.
Browse files Browse the repository at this point in the history
  • Loading branch information
trans committed Jul 18, 2014
1 parent ecdd02f commit f3d910c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 0 additions & 2 deletions lib/rubytest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def self.const_missing(name)
require 'rubytest/recorder'
require 'rubytest/advice'
require 'rubytest/runner'
require 'rubytest/cli'
require 'rubytest/reporters/abstract'
require 'rubytest/reporters/abstract_hash'
else
Expand All @@ -40,7 +39,6 @@ def self.const_missing(name)
require_relative 'rubytest/recorder'
require_relative 'rubytest/advice'
require_relative 'rubytest/runner'
require_relative 'rubytest/cli'
require_relative 'rubytest/reporters/abstract'
require_relative 'rubytest/reporters/abstract_hash'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubytest/autorun.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rubytest'

at_exit {
success = Test.run
success = Test.run!(ENV['profile'] || ENV['p'])
exit -1 unless success
}

22 changes: 21 additions & 1 deletion lib/rubytest/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ def initialize(settings={}, &block)

#apply_environment

apply(settings, &block)
apply(settings)

# save for lazy execution
@block = block
end

# Apply lazy block.
def apply!
@block.call(self) if @block
end

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

#
def name
@name
end

#
def name=(name)
@name = name.to_s if name
end

# Default test suite ($TEST_SUITE).
#
# @return [Array]
Expand Down Expand Up @@ -351,6 +369,8 @@ def mode=(type)
# Convert configuration to shell options, compatible with the
# rubytest command line.
#
# DEPRECATE: Shell command is considered bad approach.
#
# @return [Array<String>]
def to_shellwords
argv = []
Expand Down
4 changes: 3 additions & 1 deletion lib/rubytest/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def initialize(config) #:yield:
else Test.configuration(config)
end

yeild(@config) if block_given?
@config.apply! # apply lazy config block

yield(@config) if block_given?

@advice = Advice.new
end
Expand Down

0 comments on commit f3d910c

Please sign in to comment.