Class: RSpecApi::Matchers::Jsonp::Matcher

Inherits:
RSpecApi::Matchers::Json::Matcher show all
Defined in:
lib/rspec-api/matchers/jsonp/matcher.rb

Instance Attribute Summary collapse

Attributes inherited from Response::Matcher

#response

Instance Method Summary collapse

Methods inherited from Response::Matcher

#failure_message_for_should, #failure_message_for_should_not

Constructor Details

#initialize(callback) ⇒ Matcher

Returns a new instance of Matcher.



9
10
11
# File 'lib/rspec-api/matchers/jsonp/matcher.rb', line 9

def initialize(callback)
  @callback = callback
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



7
8
9
# File 'lib/rspec-api/matchers/jsonp/matcher.rb', line 7

def callback
  @callback
end

Instance Method Details

#descriptionObject



17
18
19
# File 'lib/rspec-api/matchers/jsonp/matcher.rb', line 17

def description
  %Q(be wrapped in a JSONP callback #{callback}).rstrip
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rspec-api/matchers/jsonp/matcher.rb', line 13

def matches?(response)
  super && body =~ %r{^#{callback || '.+?'}\((.*?)\)$}
end