Sha256: bcf3612d3b90c3dec803bbe433106ce07debc68ec2aabc8dc61a5204bdcbdc84

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Normalizy::RSpec::Matcher, '.failure_message' do
  let!(:model) { Match }

  context 'with no :with expectation' do
    it do
      matcher = described_class.new(:downcase_field)

      matcher.from :from
      matcher.to :to
      matcher.matches? model.new

      expect(matcher.failure_message).to eq %(expected: "to"\n     got: "from")
    end
  end

  context 'with :with expectation' do
    it do
      matcher = described_class.new(:alone)

      matcher.with :missing
      matcher.matches? model.new

      expect(matcher.failure_message).to eq %(expected: missing\n     got: nil)
    end

    it do
      matcher = described_class.new(:downcase_field_array)

      matcher.with :missing
      matcher.matches? model.new

      expect(matcher.failure_message).to eq %(expected: missing\n     got: downcase)
    end

    it do
      matcher = described_class.new(:trim_side_left)

      matcher.with :missing
      matcher.matches? model.new

      expect(matcher.failure_message).to eq %(expected: missing\n     got: {:trim=>{:side=>:left}})
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
normalizy-1.5.0 spec/normalizy/rspec/matcher/failure_message_spec.rb
normalizy-1.4.0 spec/normalizy/rspec/matcher/failure_message_spec.rb
normalizy-1.3.0 spec/normalizy/rspec/matcher/failure_message_spec.rb
normalizy-1.2.0 spec/normalizy/rspec/matcher/failure_message_spec.rb