Sha256: 0ea6863fb00c941bf91c16faf33296916f69498f3ac4b41cf84a7b25084582ef
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
# frozen_string_literal: true # encoding: utf-8 require "spec_helper" describe Mongoid::Criteria::Queryable::Extensions::Regexp::Raw do describe ".evolve" do context "when provided a bson raw regexp" do let(:regexp) do BSON::Regexp::Raw.new("^[123]") end let(:evolved) do BSON::Regexp::Raw.evolve(regexp) end it "returns the regexp" do expect(evolved).to be(regexp) end end context "when providing a string" do let(:regexp_string) do '^[123]' end let(:evolved) do BSON::Regexp::Raw.evolve(regexp_string) end it "returns the converted raw regexp" do expect(evolved).to eq(BSON::Regexp::Raw.new(regexp_string)) end end context "when provided an array" do context "when the elements are bson raw regexps" do let(:regexp) do BSON::Regexp::Raw.new("^[123]") end let(:array) do [ regexp ] end let(:evolved) do BSON::Regexp::Raw.evolve(array) end it "returns the array containing raw regexps" do expect(evolved).to eq([ regexp ]) end it "does not evolve in place" do expect(evolved).to_not equal(array) end end context "when the elements are strings" do let(:regexp_string) do "^[123]" end let(:evolved) do BSON::Regexp::Raw.evolve([ regexp_string ]) end it "returns the regexps" do expect(evolved).to eq([ BSON::Regexp::Raw.new(regexp_string) ]) end end end end describe "#regexp?" do let(:regexp) do BSON::Regexp::Raw.new('^[123]') end it "returns true" do expect(regexp).to be_regexp end end end
Version data entries
4 entries across 4 versions & 1 rubygems