Sha256: 2db660ed7309cd2ea735d288f6657257e8c06f772667d156fdf75640c73a8e1a

Contents?: true

Size: 1.72 KB

Versions: 5

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

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

    context "with false argument" do
      subject { left.get_or_else(false) }

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

    context "with nil argument" do
      subject { left.get_or_else(nil) }

      it "returns default value" do
        is_expected.to eq(nil)
      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_option" do
    subject { left.to_option }
    it { is_expected.to eq(Fear::None) }
  end

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

  describe "#===" do
    subject { match === left }

    context "the same object" do
      let(:match) { left }
      it { is_expected.to eq(true) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fear-3.0.0 spec/fear/right_biased/left.rb
fear-2.0.1 spec/fear/right_biased/left.rb
fear-2.0.0 spec/fear/right_biased/left.rb
fear-1.2.0 spec/fear/right_biased/left.rb
fear-1.1.0 spec/fear/right_biased/left.rb