Module: YamlExtension::Assertions
- Defined in:
- lib/yaml_extension.rb
Instance Attribute Summary collapse
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#str ⇒ Object
Returns the value of attribute str.
-
#val ⇒ Object
Returns the value of attribute val.
Instance Method Summary collapse
- #assert_yaml_dump(anObject, ref, options = {}) ⇒ Object
- #assert_yaml_load(aString, aClass, anObject = nil) ⇒ Object
Instance Attribute Details
#ref ⇒ Object
Returns the value of attribute ref.
75 76 77 |
# File 'lib/yaml_extension.rb', line 75 def ref @ref end |
#str ⇒ Object
Returns the value of attribute str.
75 76 77 |
# File 'lib/yaml_extension.rb', line 75 def str @str end |
#val ⇒ Object
Returns the value of attribute val.
75 76 77 |
# File 'lib/yaml_extension.rb', line 75 def val @val end |
Instance Method Details
#assert_yaml_dump(anObject, ref, options = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/yaml_extension.rb', line 84 def assert_yaml_dump ( anObject, ref, ={} ) assert_nothing_raised { @str = anObject.to_yaml() } @str.gsub!(/---\s*/, '') @str.chomp! if ref.is_a? Regexp assert_match(ref, @str) else assert_equal(ref, @str) end end |
#assert_yaml_load(aString, aClass, anObject = nil) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/yaml_extension.rb', line 77 def assert_yaml_load ( aString, aClass, anObject=nil ) assert_nothing_raised { @val = YAML::load("---\n" + aString) } assert_kind_of(aClass, @val) assert_equal(anObject, @val) unless anObject.nil? @ref = aString end |