# 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 17 def at_path(path) @path = path self end
# File lib/json_spec/matchers/have_json_size.rb, line 32 def description message_with_path(%Q(have JSON size "#{@expected}")) end
# File lib/json_spec/matchers/have_json_size.rb, line 22 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 27 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) @actual = Enumerable === ruby ? ruby.size : 1 @actual == @expected end