Sha256: cc495f25a6f89177a3b38302a29df2407fc5a17121f09c195f2db759c0543df1

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
          -> { :wherever }
        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 argument error' 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.6.0 spec/wannabe_bool_spec.rb