Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

accept symbols as field names

  • Loading branch information...
commit ec8367388f23ea8fd2cc66ba8649603dd7a99a75 1 parent b95b570
Alexander Pavlenko authored AlexanderPavlenko committed
2  lib/json_spec/matchers/have_json_fields.rb
@@ -11,7 +11,7 @@ def initialize(fields)
11 11 def matches?(json)
12 12 @data = parse_json(json, @path)
13 13 return false unless @data.is_a?(Hash)
14   - !@fields.map{|f| @data.has_key?(f)}.include?(false)
  14 + !@fields.map{|f| @data.has_key?(f.to_s)}.include?(false)
15 15 end
16 16
17 17 def at_path(path)
2  spec/json_spec/matchers/have_json_fields_spec.rb
@@ -9,9 +9,11 @@
9 9
10 10 it "fails for non-complete set of fields" do
11 11 %({"a": "a", "b": "b"}).should_not have_json_fields(%w(a b c))
  12 + %({"a": "a", "b": "b"}).should_not have_json_fields([:a, :b, :c])
12 13 end
13 14
14 15 it "matches complete set of fields" do
15 16 %({"a": "a", "b": "b", "c": "c"}).should have_json_fields(%w(a b c))
  17 + %({"a": "a", "b": "b", "c": "c"}).should have_json_fields([:a, :b, :c])
16 18 end
17 19 end

0 comments on commit ec83673

Please sign in to comment.
Something went wrong with that request. Please try again.