Class: RESTful::Matchers::HaveRestfulJsonLink
- Inherits:
-
Object
- Object
- RESTful::Matchers::HaveRestfulJsonLink
- Defined in:
- lib/restful/matchers/have_restful_json_link.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(rel, href = nil) ⇒ HaveRestfulJsonLink
constructor
A new instance of HaveRestfulJsonLink.
- #matches?(content) ⇒ Boolean
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
#description ⇒ Object
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_should ⇒ Object
29 30 31 |
# File 'lib/restful/matchers/have_restful_json_link.rb', line 29 def "Expected RESTful link: #{link_representation}" end |
#failure_message_for_should_not ⇒ Object
33 34 35 |
# File 'lib/restful/matchers/have_restful_json_link.rb', line 33 def "Expected no RESTful link: #{link_representation}" end |
#matches?(content) ⇒ 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 |