class RESTful::Matchers::HaveLink

Public Class Methods

new(rel, href = nil) click to toggle source
# File lib/restful/matchers/have_link.rb, line 19
def initialize(rel, href = nil)
  @rel  = rel.to_s
  @href = href
end

Public Instance Methods

failure_message_for_should() click to toggle source
# File lib/restful/matchers/have_link.rb, line 33
def failure_message_for_should
  error_message "Expected RESTful link"
end
failure_message_for_should_not() click to toggle source
# File lib/restful/matchers/have_link.rb, line 37
def failure_message_for_should_not
  error_message "Expected no RESTful link"
end
matches?(content) click to toggle source
# File lib/restful/matchers/have_link.rb, line 24
def matches?(content)
  @content = content
  if links = RESTful::Matchers::Parsers::JSONLinkParser.parse(content)
    return @href ? links[@rel] == @href : links.has_key?(@rel)
  else
    return false
  end
end

Private Instance Methods

error_message(message) click to toggle source
# File lib/restful/matchers/have_link.rb, line 42
def error_message(message)
  "#{message} '{\"rel\": \"#{@rel}\", \"href\": \"#{@href || "<any>" }\"}' in '#{@content}'" 
end