Sha256: dd1dce953c366938355e4af3a57c5ac194a68ebb2059a3e3669bebbc37ac77be

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

RSpec.shared_examples Fear::RightBiased::Left do
  describe '#include?' do
    subject { left }
    it { is_expected.not_to include('value') }
  end

  describe '#get_or_else' do
    context 'with block' do
      subject { left.get_or_else { 'default' } }

      it 'returns default value' do
        is_expected.to eq('default')
      end
    end

    context 'with default argument' do
      subject { left.get_or_else('default') }

      it 'returns default value' do
        is_expected.to eq('default')
      end
    end
  end

  describe '#each' do
    subject do
      proc do |block|
        expect(left.each(&block)).to eq(left)
      end
    end

    it 'does not call the block' do
      is_expected.not_to yield_control
    end
  end

  describe '#map' do
    subject { left.map(&:length) }

    it 'returns self' do
      is_expected.to eq(left)
    end
  end

  describe '#flat_map' do
    subject { left.flat_map(&:length) }

    it 'returns self' do
      is_expected.to eq(left)
    end
  end

  describe '#to_a' do
    subject { left.to_a }
    it { is_expected.to eq([]) }
  end

  describe '#to_option' do
    subject { left.to_option }
    it { is_expected.to eq(Fear::None.new) }
  end

  describe '#any?' do
    subject { left.any? { |v| v == 'value' } }
    it { is_expected.to eq(false) }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fear-0.4.1 spec/fear/right_biased/left.rb
fear-0.4.0 spec/fear/right_biased/left.rb
fear-0.3.0 spec/fear/right_biased/left.rb
fear-0.2.0 spec/fear/right_biased/left.rb
fear-0.1.0 spec/fear/right_biased/left.rb
fear-0.0.1 spec/fear/right_biased/left.rb