Class: Assert::Config

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = nil) ⇒ Config

Returns a new instance of Config.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/assert/config.rb', line 27

def initialize(settings = nil)
  @suite  = Assert::Suite.new(self)
  @view   = Assert::DefaultView.new(self, $stdout)
  @runner = Assert::Runner.new(self)

  @test_dir    = "test"
  @test_helper = "helper.rb"
  @test_file_suffixes = ['_tests.rb', '_test.rb']

  @changed_proc  = Assert::U.git_changed_proc
  @pp_proc       = Assert::U.stdlib_pp_proc
  @use_diff_proc = Assert::U.default_use_diff_proc
  @run_diff_proc = Assert::U.syscmd_diff_proc

  # option settings
  @runner_seed    = begin; srand; srand % 0xFFFF; end.to_i
  @changed_only   = false
  @changed_ref    = ''
  @pp_objects     = false
  @capture_output = false
  @halt_on_fail   = true
  @profile        = false
  @verbose        = false
  @list           = false
  @debug          = false

  self.apply(settings || {})
end

Class Method Details

.settings(*items) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/assert/config.rb', line 10

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



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

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