Sha256: 4059b1ec4d6209998f604976f6e1ed6d722c8812c24dd9a955f5a919c4286577

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
RSpec.describe WannabeBool do
  context 'configuration' do
    subject { described_class }

    describe '.invalid_value_behaviour' do
      context 'default behaviour' do
        it 'is WannabeBool::InvalidValueBehaviour::False' do
          expect(subject.invalid_value_behaviour).to eq WannabeBool::InvalidValueBehaviour::False
        end
      end
    end

    describe '.invalid_value_behaviour=' do
      context 'when behaviour responds to call method' do
        let(:behaviour) do
          -> { :whatever }
        end

        before do
          subject.invalid_value_behaviour = behaviour
        end

        after do
          subject.invalid_value_behaviour = WannabeBool::InvalidValueBehaviour::False
        end

        it "sets the behaviour" do
          expect(subject.invalid_value_behaviour).to eq behaviour
        end
      end

      context 'when behaviour does not respond to call method' do
        it 'raises ArgumentError' do
          expect { subject.invalid_value_behaviour = String }.to raise_error(ArgumentError, 'behaviour does not respond to call method')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wannabe_bool-0.7.1 spec/wannabe_bool_spec.rb