Sha256: d1c23aac037956c198547d25018eec4b4d79e450d652f836ad918fd0d53f5b8e

Contents?: true

Size: 714 Bytes

Versions: 7

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

RSpec.describe Macros::Error::SetFromContract do
  subject(:step) { described_class.new }

  let(:ctx) do
    { 'contract.default' => RecursiveOpenStruct.new(errors: { messages: { email: ["can't be blank"] } }) }
  end

  it 'should set error messages in context' do
    result = step.call(ctx)

    expect(result).to be true
    expect(ctx[:error_messages][:email]).to include "can't be blank"
  end

  context 'contract errors not set' do
    let(:ctx) { { 'contract.default' => RecursiveOpenStruct.new } }

    it 'should not set any error messages' do
      result = step.call(ctx)

      expect(result).to be false
      expect(ctx[:error_messages]).to be nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ff-tbl-macros-2.0.2 spec/lib/error/set_from_contract_spec.rb
ff-tbl-macros-2.0.1 spec/lib/error/set_from_contract_spec.rb
ff-tbl-macros-2.0.0 spec/lib/error/set_from_contract_spec.rb
ff-tbl-macros-1.0.2 spec/lib/error/set_from_contract_spec.rb
ff-tbl-macros-1.0.1 spec/lib/error/set_from_contract_spec.rb
ff-tbl-macros-1.0.0 spec/lib/error/set_from_contract_spec.rb
ff-tbl-macros-0.1.8 spec/lib/error/set_from_contract_spec.rb