Class: Assert::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/assert.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/assert.rb', line 39

def initialize
  @view   = Assert::View::DefaultView.new($stdout)
  @suite  = Assert::Suite.new
  @runner = Assert::Runner.new
  @test_dir    = "test"
  @test_helper = "helper.rb"
  @changed_files = Assert::AssertRunner::DEFAULT_CHANGED_FILES_PROC

  # default option values
  @runner_seed    = begin; srand; srand % 0xFFFF; end.to_i
  @capture_output = false
  @halt_on_fail   = true
  @changed_only   = false
  @debug          = false
end

Class Method Details

.method_missing(m, *a, &b) ⇒ Object

map any class methods to the singleton



21
# File 'lib/assert.rb', line 21

def self.method_missing(m, *a, &b); self.instance.send(m, *a, &b); end

.respond_to?(m) ⇒ Boolean

Returns:

  • (Boolean)


22
# File 'lib/assert.rb', line 22

def self.respond_to?(m); super || self.instance.respond_to?(m); end

.settings(*items) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/assert.rb', line 24

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



55
56
57
58
59
60
61
# File 'lib/assert.rb', line 55

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