collectiveidea / json_spec

Easily handle JSON in RSpec and Cucumber
rubygems.org/gems/json_spec
MIT License
919 stars 114 forks source link

Make include_json an identity function #61

Closed myitcv closed 10 years ago

myitcv commented 10 years ago

To effectively support the following (which is also in a test):

it "is an identity function" do
  json = %({"one":1})
  json.should include_json(%({"one":1}))
end
charlierudolph commented 10 years ago

I'm not a big fan of this. Can you please give an example where you needed this? Maybe there is a different approach.

I'd like to keep include_json in line with Ruby Enumerable module's include? We follow the pattern for strings and arrays, though not for hashes (that probably should change).

Also when looking up identity function, its definition is a function that returns its input.

myitcv commented 10 years ago

Wow, I was clearly doing too many things at once when submitting this.

You can almost certainly tell from the code that I intended for include_json to obey the rules of a subset relation. Definitely not an identity function!

I can understand if you want to keep include_json more in line with Ruby Enumerable semantics and terminology.

But on the basis that a JSON object is more like a set of attribute-value pairs, you can see where I'm coming from?

I will close this PR on the basis the name of the branch is clearly bonkers.... and then reference the new PR from here.

myitcv commented 10 years ago

Recreated as #62