Sha256: 91053f4d996907d1d077e53ceae33c9f91ed7d4c592002acbbe63d25b2aaebc1
Contents?: true
Size: 696 Bytes
Versions: 11
Compression:
Stored size: 696 Bytes
Contents
require 'rspec/expectations' RSpec::Matchers.define :be_a_json_attribute do match do |attribute| expect(attribute).to have_key 'type' expect(attribute['type']).to eq @type if @type.present? expect(attribute['example']).to eq @example if @example.present? true end chain :with_type do |type| @type = type end chain :with_example do |example| @example = example end failure_message_for_should do |attribute| "expected that #{attribute.try(:to_hash) || attribute} to be a json attribute".tap do |message| message << " with type '#{@type}'" if @type.present? message << " with example '#{@example}'" if @example.present? end end end
Version data entries
11 entries across 11 versions & 1 rubygems