chancancode / json_expressions

JSON matchmaking for all your API testing needs.
MIT License
415 stars 38 forks source link

Add support for rspec 3+ #24

Closed george closed 10 years ago

george commented 10 years ago

Alias new rspec matcher protocol names (rspec 3+) to the old (rspec 2). From https://www.relishapp.com/rspec/rspec-expectations/docs/changelog:

Update matcher protocol and custom matcher DSL to better align with the newer expect syntax. If you want your matchers to maintain compatibility with multiple versions of RSpec, you can alias the new names to the old. (Myron Marston)


Running rspec v3.0.0.beta2 without this patch results in the following:

   Failure/Error: expect(last_response.body).to match_json_expression(expected_json_pattern)
   --------------------------------------------------------------------------
   JsonExpressions::RSpec::Matchers::MatchJsonExpression implements a legacy RSpec matcher
   protocol. For the current protocol you should expose the failure messages
   via the `failure_message` and `failure_message_when_negated` methods.
   (Used from <path>/spec/support/shared_api_endpoint_spec.rb:101:in `block (3 levels) in <top (required)>')
   --------------------------------------------------------------------------
chancancode commented 10 years ago

If you can send a PR for this, it would be awesome ;) Ideally we should keep it working for both rspec 2 and 3. Preferably if we can just keep the existing require, detect the rspec version and load the right stuff conditionally. But if that's too difficult for some reason we can do a require 'json_expressions/rspec3 or something.

george commented 10 years ago

This is a pull request :) And a simple one at that; it merely aliases the new rspec 3 method names to the current rspec 2 names.

chancancode commented 10 years ago

My bad :see_no_evil: