-
Notifications
You must be signed in to change notification settings - Fork 125
Extra Matchers from Community
PikachuEXE edited this page Oct 23, 2014
·
1 revision
module AirborneJsonSizesMatcher
def expect_json_sizes(*args)
if args.last.is_a?(Hash)
args.push(convert_expectations(args.pop))
end
expect_json_types(*args)
end
private
def convert_expectations(old_expectations)
old_expectations.each_with_object({}) do |(prop_name, expected_size), memo|
new_value = if expected_size.is_a?(Hash)
convert_expectations(expected_size)
else
-> (data) { expect(data.size).to eq(expected_size) }
end
memo[prop_name] = new_value
end
end
end
RSpec.configure do |config|
config.include AirborneJsonSizesMatcher
end