Class: RESTful::Matchers::HaveRestfulJsonLink

Inherits:
Object
  • Object
show all
Defined in:
lib/restful/matchers/have_restful_json_link.rb

Instance Method Summary collapse

Constructor Details

#initialize(rel, href = nil) ⇒ HaveRestfulJsonLink

Returns a new instance of HaveRestfulJsonLink.



16
17
18
19
# File 'lib/restful/matchers/have_restful_json_link.rb', line 16

def initialize(rel, href = nil)
  @rel  = rel
  @href = href
end

Instance Method Details

#descriptionObject



37
38
39
# File 'lib/restful/matchers/have_restful_json_link.rb', line 37

def description
  "have RESTful link: #{link_representation}"
end

#failure_message_for_shouldObject



29
30
31
# File 'lib/restful/matchers/have_restful_json_link.rb', line 29

def failure_message_for_should
  "Expected RESTful link: #{link_representation}"
end

#failure_message_for_should_notObject



33
34
35
# File 'lib/restful/matchers/have_restful_json_link.rb', line 33

def failure_message_for_should_not
  "Expected no RESTful link: #{link_representation}"
end

#matches?(content) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/restful/matchers/have_restful_json_link.rb', line 21

def matches?(content)
  if links = parse_links_from(content)
    return @href ? links[@rel] == @href : links.has_key?(@rel)
  else
    raise StandardError.new("JSON has no RESTful links")
  end
end