Sha256: 82734423a39827d887551aa05a8addff98b9b9657292c57d2b4ee6ff80e01818

Contents?: true

Size: 818 Bytes

Versions: 59

Compression:

Stored size: 818 Bytes

Contents

require "spec_helper"

describe Mongoid::Extensions::Regexp do

  describe ".demongoize" do

    let(:value) do
      Regexp.demongoize(/[^abc]/)
    end

    it "returns the provided value" do
      expect(value).to eq(/[^abc]/)
    end
  end

  describe ".mongoize" do

    context "when providing a regex" do

      let(:value) do
        Regexp.mongoize(/[^abc]/)
      end

      it "returns the provided value" do
        expect(value).to eq(/[^abc]/)
      end
    end

    context "when providing a string" do

      let(:value) do
        Regexp.mongoize("[^abc]")
      end

      it "returns the provided value as a regex" do
        expect(value).to eq(/[^abc]/)
      end
    end
  end

  describe "#mongoize" do

    it "returns self" do
      expect(/[^abc]/.mongoize).to eq(/[^abc]/)
    end
  end
end

Version data entries

59 entries across 54 versions & 6 rubygems

Version Path
mongoid-5.4.1 spec/mongoid/extensions/regexp_spec.rb
mongoid-6.4.2 spec/mongoid/extensions/regexp_spec.rb
mongoid-7.0.2 spec/mongoid/extensions/regexp_spec.rb
mongoid-7.0.1 spec/mongoid/extensions/regexp_spec.rb
mongoid-6.4.1 spec/mongoid/extensions/regexp_spec.rb
mongoid-5.4.0 spec/mongoid/extensions/regexp_spec.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/spec/mongoid/extensions/regexp_spec.rb
mongoid-7.0.0 spec/mongoid/extensions/regexp_spec.rb
mongoid-6.4.0 spec/mongoid/extensions/regexp_spec.rb
mongoid-6.3.0 spec/mongoid/extensions/regexp_spec.rb
mongoid-6.2.1 spec/mongoid/extensions/regexp_spec.rb
mongoid-7.0.0.beta spec/mongoid/extensions/regexp_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/extensions/regexp_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/extensions/regexp_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/spec/mongoid/extensions/regexp_spec.rb
mongoid-6.2.0 spec/mongoid/extensions/regexp_spec.rb
mongoid-6.1.1 spec/mongoid/extensions/regexp_spec.rb
mongoid-5.2.1 spec/mongoid/extensions/regexp_spec.rb
tdiary-5.0.4 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/extensions/regexp_spec.rb
mongoid-6.1.0 spec/mongoid/extensions/regexp_spec.rb