ResponseMatcher alternatives and similar gems
Based on the "RSpec" category.
Alternatively, view ResponseMatcher alternatives based on common mentions on social networks and blogs.
-
shoulda-matchers
Simple one-liner tests for common Rails functionality -
Spork
A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state. -
Aruba
Test command-line applications with Cucumber-Ruby, RSpec or Minitest. -
Phony
E164 international phone number normalizing, splitting, formatting. -
RR
RR is a test double framework that features a rich selection of double techniques and a terse syntax. ⛺ -
Pundit Matchers
A set of RSpec matchers for testing Pundit authorisation policies. -
RSpecTracer
RSpec Tracer is a specs dependency analyzer, flaky tests detector, tests accelerator, and coverage reporter tool for RSpec. It maintains a list of files for each test, enabling itself to skip tests in the subsequent runs if none of the dependent files are changed. It uses Ruby's built-in coverage library to keep track of the coverage for each test. -
RSpec clone
A minimalist RSpec clone with all the essentials.
Collect and Analyze Billions of Data Points in Real Time
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of ResponseMatcher or a related project?
README
ResponseMatcher
Solution for matching JSON response into RSpec request tests.
Installation
Add this line to your application's Gemfile:
gem 'response_matcher'
And then execute:
$ bundle
Or install it yourself as:
$ gem install response_matcher
Usage
Quick start
In registration_spec.rb
describe RegistrationsController do
describe 'POST /auth' do
it 'response' do
post user_registration_path, params: params
expect(response).to response_match('schema_path', user: User.last)
end
end
end
You can create your own schema
└─ spec
├─ schemas
│ ├─ my_schema.rb
│ └─ ...
└─ ...
In my_schema.rb
you can describe by ruby language how looks like your response
# All the parameters that you transmit will be available as variables, like 'user'
{
data: {
id: user.id,
type: user.class.name,
attributes: {
email: user.email,
provider: user.provider,
uid: user.uid
}
}
}
You can reuse your schemas in another schemas
└─ spec
├─ schemas
│ ├─ my_schema.rb
│ ├─ attributes.rb
│ └─ ...
└─ ...
In my_schema.rb
# All the parameters that you transmit will be available as variables, like 'user'
{
data: {
id: user.id,
type: user.class.name,
attributes: call('attributes', user: user)
}
}
In attributes.rb
{
email: user.email,
provider: user.provider,
uid: user.uid
}
You can use helpers in your schemas:
└─ spec
├─ schemas
│ ├─ my_schema.rb
│ ├─ attributes.rb
│ └─ ...
├─ helpers
│ ├─ my_helper.rb
│ └─ ...
├─ rails_helper.rb
└─ ...
In my_helper.rb
module Helpers
module MyHelper
def entity_class(entity)
entity.class.name
end
end
end
In rails_helper.rb
ResponseMatcher::Settings.configure do |config|
config.helpers = [
Helpers::MyHelper,
...
]
end
In my_schema.rb
{
data: {
id: user.id,
type: entity_class(user),
attributes: call('attributes', user: user)
}
}
You can set base directory of your schemas:
In rails_helper.rb
ResponseMatcher::Settings.configure do |config|
config.directory = 'spec/schemas/api/v1'
end
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/bezrukavyi/response_matcher
License
The gem is available as open source under the terms of the MIT License.
*Note that all licence references and agreements mentioned in the ResponseMatcher README section above
are relevant to that project's source code only.