Class: Assert::Config
Class Method Summary collapse
-
.method_missing(m, *a, &b) ⇒ Object
map any class methods to the singleton.
- .respond_to?(m) ⇒ Boolean
- .settings(*items) ⇒ Object
Instance Method Summary collapse
- #apply(settings) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/assert.rb', line 51 def initialize @view = Assert::View::DefaultView.new($stdout) @suite = Assert::Suite.new @runner = Assert::Runner.new @test_dir = "test" @test_helper = "helper.rb" # default settings @runner_seed = begin; srand; srand % 0xFFFF; end.to_i @capture_output = true @halt_on_fail = true @debug = false end |
Class Method Details
.method_missing(m, *a, &b) ⇒ Object
map any class methods to the singleton
34 |
# File 'lib/assert.rb', line 34 def self.method_missing(m, *a, &b); self.instance.send(m, *a, &b); end |
.respond_to?(m) ⇒ Boolean
35 |
# File 'lib/assert.rb', line 35 def self.respond_to?(m); super || self.instance.respond_to?(m); end |
.settings(*items) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/assert.rb', line 37 def self.settings(*items) items.each do |item| define_method(item) do |*args| if !(value = args.size > 1 ? args : args.first).nil? instance_variable_set("@#{item}", value) end instance_variable_get("@#{item}") end end end |
Instance Method Details
#apply(settings) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/assert.rb', line 65 def apply(settings) settings.keys.each do |name| if !settings[name].nil? && self.respond_to?(name.to_s) self.send(name.to_s, settings[name]) end end end |