class JsonSpec::Matchers::HaveJsonSize
Public Class Methods
new(size)
click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 7 def initialize(size) @expected = size @path = nil end
Public Instance Methods
at_path(path)
click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 19 def at_path(path) @path = path self end
description()
click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 34 def description message_with_path(%(have JSON size "#{@expected}")) end
failure_message()
click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 24 def failure_message message_with_path("Expected JSON value size to be #{@expected}, got #{@actual}") end
Also aliased as: failure_message_for_should
failure_message_when_negated()
click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 29 def failure_message_when_negated message_with_path("Expected JSON value size to not be #{@expected}, got #{@actual}") end
Also aliased as: failure_message_for_should_not
matches?(json)
click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 12 def matches?(json) ruby = parse_json(json, @path) raise EnumerableExpected.new(ruby) unless Enumerable === ruby @actual = ruby.size @actual == @expected end