Sha256: f818d43cb0a8c7d3f0a6bdbd3c0193362e1abdf48a2637e86ff8ea5d809c8626

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

RSpec::Matchers.define :upcase_lower_case_for do |attribute, value|
  match do
    subject = new_model( attribute, value )
    expect( subject.send( attribute ) ).to eql( value.upcase )
  end

  failure_message do
    "expected #{subject.class} to upcase #{value} case for :#{attribute}"
  end
end

RSpec::Matchers.define :return_nil_for_invalid_types do |attribute, value|
  match do
    subject = new_model( attribute, value )
    expect( subject.send( attribute ) ).to eql( nil )
  end

  failure_message do
    "expected #{subject.class} to return nil when :#{attribute} is set to #{value}"
  end
end

  private

    def new_model( attribute, value )
      described_class.new( attribute => value )
    end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortnox-api-0.1.0 spec/support/matchers/models.rb