Class: TargetPracticeTestCase
- Inherits:
-
MiniTest::Unit::TestCase
- Object
- MiniTest::Unit::TestCase
- TargetPracticeTestCase
- Defined in:
- lib/target_practice/target_practice_test_case.rb
Constant Summary collapse
- @@meta_assertions =
{}
Instance Method Summary collapse
- #assert_attributes(obj, hash = {}) ⇒ Object
- #files ⇒ Object
- #files=(f) ⇒ Object
- #is_meta_command?(v) ⇒ Boolean
- #perform_meta_assertion(obj, command, v) ⇒ Object
- #setup ⇒ Object
Instance Method Details
#assert_attributes(obj, hash = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/target_practice/target_practice_test_case.rb', line 16 def assert_attributes(obj, hash={}) return if hash.nil? hash.each do |k,v| assert obj.send(k.to_sym) if !(k) if k (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 |
#files ⇒ Object
8 9 10 |
# File 'lib/target_practice/target_practice_test_case.rb', line 8 def files @@files end |
#files=(f) ⇒ Object
12 13 14 |
# File 'lib/target_practice/target_practice_test_case.rb', line 12 def files=(f) @@files = f end |
#is_meta_command?(v) ⇒ Boolean
38 39 40 |
# File 'lib/target_practice/target_practice_test_case.rb', line 38 def (v) .keys.include? v end |
#perform_meta_assertion(obj, command, v) ⇒ Object
42 43 44 |
# File 'lib/target_practice/target_practice_test_case.rb', line 42 def (obj, command, v) [command].call(self, obj, v) if [command] end |
#setup ⇒ Object
4 5 6 |
# File 'lib/target_practice/target_practice_test_case.rb', line 4 def setup assert @@files, "File data was not set!" end |