Top Level Namespace
Defined Under Namespace
Modules: Rester
Instance Method Summary collapse
-
#include_stub_response ⇒ Object
include_stub_response custom matcher which checks inclusion on nested arrays and objects as opposed to the top level object which RSpec’s include only checks.
Instance Method Details
#include_stub_response ⇒ Object
include_stub_response custom matcher which checks inclusion on nested arrays and objects as opposed to the top level object which RSpec’s include only checks
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rester/rspec.rb', line 7 RSpec::Matchers.define :include_stub_response do |stub| failure = nil match { |actual| begin # If a stub is passed in by the user, check both the stub file and the # response for inclusion. This is helpful for cases when a field is better # tested with a Regex in the Producer-side testing: ie :created_at in POST Rester::Utils::RSpec.assert_deep_include(stub_response, stub) if stub expected = stub ? stub_response.merge(stub) : stub_response Rester::Utils::RSpec.assert_deep_include(actual, expected) rescue Rester::Errors::StubError => e failure = e false end } { failure } end |