module RSpecApi::Matchers::Jsonp
Public Instance Methods
be_wrapped_in_callback(callback = nil)
click to toggle source
Passes if the object has a JSONP callback-wrapped body
@param [Symbol or String] callback Name of the wrapping JSONP callback
@example Passes if the body is wrapped in the function “alert”
require 'rspec-api-matchers' body = 'alert([{"id": 1}])' obj = OpenStruct.new body: body describe 'be_wrapped_in_callback' do include RSpecApi::Matchers::Jsonp it { expect(obj).to be_wrapped_in_callback(:alert) } end # => (rspec) 1 example, 0 failures
@see git.io/XLeIOg be_wrapped_in_callback_spec.rb for more examples
# File lib/rspec-api/matchers/jsonp/be_wrapped_in_callback.rb, line 24 def be_wrapped_in_callback(callback = nil) RSpecApi::Matchers::Jsonp::Matcher.new callback end