class RSpec::Hal::Matchers::HavePropertyMatcher
Example
expect(doc).to have_property("name") expect(doc).to have_property("search", matching("Alice"))
Attributes
expected[R]
outcome[R]
prop_name[R]
Public Class Methods
new(property_name, expected=NullMatcher)
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 13 def initialize(property_name, expected=NullMatcher) @prop_name = property_name.to_s @expected = matcherize expected end
Public Instance Methods
description()
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 35 def description "have property `#{prop_name}` #{@expected.description}" end
failure_message()
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 25 def failure_message sentencize "Expected property `#{prop_name}`", expected.description end
Also aliased as: failure_message_for_should
failure_message_when_negated()
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 30 def failure_message_when_negated sentencize "Expected property `#{prop_name}`", expected.description, "to be absent" end
Also aliased as: failure_message_for_should_not
including(expected)
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 45 def including(expected) self.class.new(prop_name, RSpec::Matchers::BuiltIn::Include.new(expected)) end
matches?(jsonish)
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 18 def matches?(jsonish) self.repr = jsonish repr.property?(prop_name) && expected === repr.property(prop_name){ nil } end
matching(expected)
click to toggle source
# File lib/rspec/hal/matchers/have_property_matcher.rb, line 40 def matching(expected) self.class.new(prop_name, matcherize(expected)) end
Also aliased as: that_is