Sha256: 57e3d0911881656ab0579e31b22a04fc48b6be6951c3b3168f62daab652179ae

Contents?: true

Size: 837 Bytes

Versions: 13

Compression:

Stored size: 837 Bytes

Contents

RSpec.describe Tram::Policy::ValidationError do
  subject(:error) { described_class.new policy, filter }

  let(:one)    { double full_message: "OMG!",  level: "error" }
  let(:two)    { double full_message: "phew!", level: "warning" }
  let(:policy) { double :policy, errors: [one, two] }

  shared_examples :exception_with_messages do |text|
    it { is_expected.to be_a RuntimeError }
    its(:policy)  { is_expected.to eq policy }
    its(:message) { is_expected.to eq "Validation failed with errors:#{text}" }
  end

  context "with a liberal filter" do
    let(:filter) { proc { false } }
    it_behaves_like :exception_with_messages, "\n- OMG!\n- phew!"
  end

  context "with a restricting filter" do
    let(:filter) { proc { |error| error.level != "error" } }
    it_behaves_like :exception_with_messages, "\n- OMG!"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
tram-policy-0.3.1 spec/tram/policy/validation_error_spec.rb
tram-policy-0.3.0 spec/tram/policy/validation_error_spec.rb
tram-policy-0.2.5 spec/tram/policy/validation_error_spec.rb
tram-policy-0.2.4 spec/tram/policy/validation_error_spec.rb
tram-policy-0.2.3 spec/tram/policy/validation_error_spec.rb
tram-policy-0.2.2 spec/tram/policy/validation_error_spec.rb
tram-policy-0.2.1 spec/tram/policy/validation_error_spec.rb
tram-policy-0.2.0 spec/tram/policy/validation_error_spec.rb
tram-policy-0.1.1 spec/tram/policy/validation_error_spec.rb
tram-policy-0.1.0 spec/tram/policy/validation_error_spec.rb
tram-policy-0.0.3 spec/tram/policy/validation_error_spec.rb
tram-policy-0.0.2 spec/tram/policy/validation_error_spec.rb
tram-policy-0.0.1 spec/tram/policy/validation_error_spec.rb