Matic::Testing
Installation
Add this line to your application's Gemfile:
gem 'matic-testing'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install matic-testing
Plugins
By itself gem does nothing, you need to require the plugin to make some use of it.
VCR JSON API
Add this line to enable it
require 'matic/testing/vcr_json_api'
Features:
Custom Cassette serializers.
You can use them with :serialize_with
VCR config.
Available options
:json_api_serializer # Serializes request and response body as formatted JSON.
:json_api_serializer_without_headers # Works as previous, additionally removes headers from request and response.
:json_api_as_yml # Serializes request and response body as formatted YML
:json_api_as_yml_without_headers # Works as previous, additionally removes headers from request and response.
Examples:
As Rspec metadata:
describe ClassName, vcr: {cassette_name: 'name',
serialize_with: :json_api_serializer} do
end
Through VCR.use_cassette
VCR.use_cassette('name', serialize_with: :json_api_serializer) do
end
Through default options
VCR.configure do |c|
c.default_cassette_options = {
serialize_with: :json_api_serializer
...
}
end
JSON Body request matcher
Matches Recorded and Executed Request bodies, but instead of comparing strings, converts JSONs into hashes and does clever matching.
Additionally it does better job in reporting what exactly wrong with the request. Like this:
Examples:
As Rspec metadata:
describe ClassName, vcr: {cassette_name: 'name',
match_requests_on: %i[uri method json_body]} do
end
Through VCR.use_cassette
VCR.use_cassette('name', match_requests_on: %i[uri method json_body]) do
end
Through default options
VCR.configure do |c|
c.default_cassette_options = {
match_requests_on: %i[uri method json_body]
...
}
end