Class: TargetPracticeTestCase

Inherits:
MiniTest::Unit::TestCase
  • Object
show all
Defined in:
lib/target_practice/target_practice_test_case.rb

Instance Method Summary collapse

Instance Method Details

#assert_attributes(obj, hash = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/target_practice/target_practice_test_case.rb', line 14

def assert_attributes(obj, hash={})
  return if hash.nil?

  hash.each do |k,v|
    assert obj.send(k.to_sym) if !is_meta_command?(k)

    if is_meta_command? k
      perform_meta_assertion(obj, k, v)
    elsif v.kind_of? Array
      index = 0
      v.each do |i|
        assert_attributes(obj.send(k.to_sym)[index], i)
        index += 1
      end
    elsif v.kind_of? Hash
      assert_attributes(obj.send(k.to_sym), v)
    elsif v.kind_of? String
      assert_equal v, obj.send(k.to_sym)
    end
  end
end

#filesObject



6
7
8
# File 'lib/target_practice/target_practice_test_case.rb', line 6

def files
  @@files
end

#files=(f) ⇒ Object



10
11
12
# File 'lib/target_practice/target_practice_test_case.rb', line 10

def files=(f)
  @@files = f
end

#is_meta_command?(v) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/target_practice/target_practice_test_case.rb', line 36

def is_meta_command?(v)
  meta_commands.include? v
end

#meta_commandsObject



40
41
42
# File 'lib/target_practice/target_practice_test_case.rb', line 40

def meta_commands
  []
end

#setupObject



2
3
4
# File 'lib/target_practice/target_practice_test_case.rb', line 2

def setup
  assert @@files, "File data was not set!"
end