# File lib/json_spec/matchers/have_json_size.rb, line 7 def initialize(size) @expected = size end
# File lib/json_spec/matchers/have_json_size.rb, line 18 def at_path(path) @path = path self end
# File lib/json_spec/matchers/have_json_size.rb, line 33 def description message_with_path(%Q(have JSON size "#{@expected}")) end
# File lib/json_spec/matchers/have_json_size.rb, line 23 def failure_message message_with_path("Expected JSON value size to be #{@expected}, got #{@actual}") end
# File lib/json_spec/matchers/have_json_size.rb, line 28 def failure_message_when_negated message_with_path("Expected JSON value size to not be #{@expected}, got #{@actual}") end
# File lib/json_spec/matchers/have_json_size.rb, line 11 def matches?(json) ruby = parse_json(json, @path) raise EnumerableExpected.new(ruby) unless Enumerable === ruby @actual = ruby.size @actual == @expected end