class RSpec::Siren::Matchers::HasProperty
Public Class Methods
new(expected_name)
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 5 def initialize(expected_name) @expected_name = expected_name end
Public Instance Methods
description()
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 34 def description message = "have" message << " property '#{@expected_name}'" message << " with value '#{@expected_value}'" end
expected_value_matches?()
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 26 def expected_value_matches? @value == @expected_value end
failure_message()
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 40 def failure_message message = "expected" message << " property '#{@expected_name}'" message << " with value '#{@expected_value}'" if @expected_value message << ". Found" if !property_exists? message << " no such property." else message << " with value '#{@value}'" end message end
has_expected_value?()
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 22 def has_expected_value? !!@expected_value end
matches?(target)
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 9 def matches?(target) @target = target @value = safe_properties[@expected_name] property_exists? && (!has_expected_value? || expected_value_matches?) end
property_exists?()
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 30 def property_exists? safe_properties.has_key?(@expected_name) end
with_value(expected_value)
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 17 def with_value(expected_value) @expected_value = expected_value self end
Private Instance Methods
safe_properties()
click to toggle source
# File lib/rspec/siren/matchers/has_property.rb, line 55 def safe_properties @target[:properties] || @target["properties"] || {} end