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
end

Public Instance Methods

at_path(path) click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 18
def at_path(path)
  @path = path
  self
end
description() click to toggle source
# File lib/json_spec/matchers/have_json_size.rb, line 33
def description
  message_with_path(%Q(have JSON size "#{@expected}"))
end
failure_message() click to toggle source
# 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
Also aliased as: failure_message_for_should
failure_message_for_should()
Alias for: failure_message
failure_message_for_should_not()
failure_message_when_negated() click to toggle source
# 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
matches?(json) click to toggle source
# 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