
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
check_please_rspec_matcher
Advanced tools
RSpec matcher to check for differences between two JSON strings (or Ruby data structures parsed from them). Most of the heavy lifting is done by the check_please gem; this is merely an RSpec wrapper that I didn't want to include in the main gem.
If you'd like more control over the output formatting, and especially if you'd like to provide custom logic for diffing your own classes, you might be better served by the super_diff gem. Check it out!
Add this line to your application's Gemfile:
gem 'check_please_rspec_matcher'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install check_please_rspec_matcher
The following code will raise a RSpec::Expectations::ExpectationNotMetError:
reference = '{ "foo": 42 }'
candidate = '{ "foo": 43 }'
expect( candidate ).to check_please( reference )
For more information on understanding the diffs in the failure message, see check_please.
The failure message should look something like this:
Expected two JSON data structures to match, but found the following diffs:
TYPE | PATH | REFERENCE | CANDIDATE
---------|------|-----------|----------
mismatch | /foo | 42 | 43
The check_please
helper method accepts keyword arguments that correspond to
the flags defined in the CheckPlease gem. I haven't documented these yet, but
if you feel like reading some source code, search this
file
for Flags.define
.
reference = '{ "foo": 42 }'
candidate = '{ "foo": 43 }'
expect( candidate ).to check_please( reference, format: :json )
Using :json
as above will output the diffs in JSON instead of a table:
Expected two JSON data structures to match, but found the following diffs:
[
{ "type": "mismatch", "path": "/foo", "reference": 42, "candidate": 43 }
]
After checking out the repo, run bin/setup
to install dependencies. Then, run
rake spec
to run the tests. You can also run bin/console
for an interactive
prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To
release a new version, update the version number in version.rb
, and then run
bundle exec rake release
, which will create a git tag for the version, push
git commits and tags, and push the .gem
file to
rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/check_please_rspec_matcher. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the CheckPleaseRspecMatcher project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that check_please_rspec_matcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.