Sha256: 13055c22bd74e3de2d866a27a875266527cd95e07e4c461495b82667335336c8

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 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
    specify 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
    specify 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

    specify 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

    specify 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.1.1 spec/normalizy/rspec/matcher/failure_message_spec.rb
normalizy-1.1.0 spec/normalizy/rspec/matcher/failure_message_spec.rb
normalizy-1.0.1 spec/normalizy/rspec/matcher/failure_message_spec.rb
normalizy-1.0.0 spec/normalizy/rspec/matcher/failure_message_spec.rb