Sha256: 1c9c93da3f6c1c12ffbabe325e60c8cc67332b72667dd5cdcc4ee68babde1ea3

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8

module Selector

  describe Selector::Regexp do

    let(:one) { described_class.new(/1\.1/) }
    let(:two) { described_class.new(/2/) }

    describe ".new" do

      subject { one }

      it { is_expected.to be_kind_of Condition }
      it { is_expected.to be_frozen }

      it "requires exactly 1 argument" do
        expect { described_class.new }.to raise_error ArgumentError
        expect { described_class.new(/1/, /2/) }
          .to raise_error ArgumentError
      end

    end # describe .new

    describe "#[]" do

      subject { one[value] }

      context "value that matches the regexp" do

        let(:value) { 1.1 }
        it { is_expected.to eql(true) }

      end # context

      context "value that doesn't match the regexp" do

        let(:value) { 3 }
        it { is_expected.to eql(false) }

      end # context

    end # describe #[]

    describe "#|" do

      context "regexp" do

        subject { one | two }

        it "updates the regexp" do
          expect(subject).to be_kind_of Regexp
          expect(subject.attribute).to eql(/(#{/1\.1/})|(#{/2/})/)
        end

      end # context

      context "value that doesn't match the regexp" do

        subject { one | Condition.new }
        it { is_expected.to be_kind_of(Or) }

      end # context

    end # describe #[]

  end # describe Selector::Regexp

end # module Selector

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selector-0.0.3 spec/unit/selector/regexp_spec.rb
selector-0.0.2 spec/unit/selector/regexp_spec.rb
selector-0.0.1 spec/unit/selector/regexp_spec.rb