Module: YamlExtension::Assertions

Defined in:
lib/yaml_extension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#refObject

Returns the value of attribute ref.



75
76
77
# File 'lib/yaml_extension.rb', line 75

def ref
  @ref
end

#strObject

Returns the value of attribute str.



75
76
77
# File 'lib/yaml_extension.rb', line 75

def str
  @str
end

#valObject

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, options={} )
  assert_nothing_raised { @str = anObject.to_yaml(options) }
  @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