Class: RSpecApi::Matchers::Jsonp::Matcher
- Inherits:
-
RSpecApi::Matchers::Json::Matcher
- Object
- Response::Matcher
- RSpecApi::Matchers::Json::Matcher
- RSpecApi::Matchers::Jsonp::Matcher
- Defined in:
- lib/rspec-api/matchers/jsonp/matcher.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
Attributes inherited from Response::Matcher
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(callback) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(response) ⇒ Boolean
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
#callback ⇒ Object
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
#description ⇒ Object
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
13 14 15 |
# File 'lib/rspec-api/matchers/jsonp/matcher.rb', line 13 def matches?(response) super && body =~ %r{^#{callback || '.+?'}\((.*?)\)$} end |