class RSpec::Oj::Matchers::HaveJsonSize
Public Class Methods
new(size)
click to toggle source
# File lib/rspec/oj/matchers/have_json_size.rb, line 10 def initialize(size) @expected = size @path = nil end
Public Instance Methods
at_path(path)
click to toggle source
# File lib/rspec/oj/matchers/have_json_size.rb, line 23 def at_path(path) @path = path self end
description()
click to toggle source
# File lib/rspec/oj/matchers/have_json_size.rb, line 36 def description message_with_path(%(have JSON size "#{@expected}")) end
failure_message()
click to toggle source
# File lib/rspec/oj/matchers/have_json_size.rb, line 28 def failure_message message_with_path("Expected JSON value size to be #{@expected}, got #{@actual}") end
failure_message_when_negated()
click to toggle source
# File lib/rspec/oj/matchers/have_json_size.rb, line 32 def failure_message_when_negated message_with_path("Expected JSON value size to not be #{@expected}, got #{@actual}") end
matches?(json)
click to toggle source
# File lib/rspec/oj/matchers/have_json_size.rb, line 15 def matches?(json) ruby = parse_json(json, @path) raise EnumerableExpected, ruby unless Enumerable === ruby @actual = ruby.size @actual == @expected end