Sha256: f93825d9c28dbd75d2b9828f83f7474ebaf904670f8bba700625cd290b57a8fe

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

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.0 spec/wannabe_bool_spec.rb