class RSpec::Hal::Matchers::TemplatedRelationMatcher
Example
expect(doc).to have_templated_relation("search") expect(doc).to have_templated_relation("search", matching("{?q}"))
Attributes
expected[R]
link_rel[R]
outcome[R]
Public Class Methods
new(link_rel, expected=NullMatcher)
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 16 def initialize(link_rel, expected=NullMatcher) @link_rel = link_rel.to_s @expected = expected end
Public Instance Methods
description()
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 60 def description "have templated #{link_rel} link" end
failure_message()
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 44 def failure_message but_clause = if outcome == :no_templates "found only non-templated links" else "found none" end sentencize "Expected templated `#{link_rel}` link", expected.description, "but #{but_clause}" end
Also aliased as: failure_message_for_should
failure_message_when_negated()
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 55 def failure_message_when_negated "Expected `#{link_rel}` link to be absent or not templated" end
Also aliased as: failure_message_for_should_not
matches?(jsonish)
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 21 def matches?(jsonish) self.repr = jsonish repr.raw_related_hrefs(link_rel){[]} .tap{|it| if it.none? @outcome = :no_relations return false end } .select{|it| it.respond_to? :expand} .tap{|it| if it.none? @outcome = :no_templates return false end } .select{|it| expected === it.pattern } .tap{|it| if it.none? @outcome = :none_matched return false end } true end
Also aliased as: ===
uri_template()
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 69 def uri_template repr.raw_related_hrefs(link_rel){[]}.first end
with_variables(*vars)
click to toggle source
# File lib/rspec/hal/matchers/templated_relation_matcher.rb, line 64 def with_variables(*vars) self.class.new(link_rel, UriTemplateHasVariablesMatcher.new(vars)) end
Also aliased as: with_variable