Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add haveJsonValue matcher #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

EleanorRagone
Copy link

Adds a helper to match a specific value in JSON

Adds a helper to match a specific value in JSON
@skalee
Copy link
Contributor

skalee commented Jan 6, 2015

This pull request has couple of flaws:

  1. It adds files which shouldn't be there (*.gem, environment configs)
  2. Contains no documentation updates.

This effect can be achieved in the other ways, and that has been stated previously, see #23. That said, I would welcome matcher like this. +1, but changes are required before merge.

With such matchers, I could write ActiveModel::Serializers examples like this one:

describe ApiV1::SomeSerializer do

  subject do
    serializer_class.new(model, options).to_json
  end

  let(:serializer_class) { ApiV1::SomeSerializer } # this can be improved with RSpec metadata
  let(:model) { SomeModel.new("What a beautiful model") }
  let(:options) { Hash.new } # to be overriden in various contexts

  it { is_expected.to have_json_value("What a beautiful model").at_path("pretty_name") }
end

Which would be really great. Currently I can either write "What a beautiful model".inspect or %q["What a beautiful model"] which seems inferior and is error-prone to me and my team mates.

Getting comparably readable effect with #parse_json doesn't seem easy to me.

@mcnelson
Copy link

This PR appears dead. I would like to use this new matcher, see other PR above ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants