Sha256: b74166cf7f53eb886104469d7280104ad15ffdd5fc34297f76a4db0b0a96b3f5

Contents?: true

Size: 1.79 KB

Versions: 8

Compression:

Stored size: 1.79 KB

Contents

require "spec_helper"

describe MongoSessionStore do
  describe ".collection_name" do
    subject { described_class.collection_name }

    it "defaults to 'sessions'" do
      expect(subject).to eq("sessions")
    end

    context "with modified collection name" do
      around do |example|
        collection_name = described_class.send :instance_variable_get, :@collection_name
        described_class.send :remove_instance_variable, :@collection_name
        example.run
        described_class.collection_name = collection_name
      end

      context "without collection name" do
        it "returns nil" do
          expect(subject).to be_nil
        end
      end

      context "with collection name" do
        before { described_class.collection_name = "foo" }

        it "returns the set collection name" do
          expect(subject).to eq("foo")
        end
      end
    end
  end

  describe ".collection_name=" do
    subject { described_class.collection_name }
    around do |example|
      collection_name = described_class.send :instance_variable_get, :@collection_name
      described_class.send :remove_instance_variable, :@collection_name
      example.run
      described_class.collection_name = collection_name
    end

    if mongo_orm == "mongoid"
      context "with mongo" do
        before { described_class.collection_name = "foo" }
        subject { MongoidStore::Session.collection.name }

        it "returns the set collection name" do
          expect(subject).to eq("foo")
        end
      end
    elsif mongo_orm == "mongo"
      context "with mongo" do
        before { described_class.collection_name = "foo" }
        subject { MongoStore::Session.collection.name }

        it "returns the set collection name" do
          expect(subject).to eq("foo")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
mongo_session_store-3.2.1 spec/lib/mongo_session_store_spec.rb
mongo_session_store-3.2.0 spec/lib/mongo_session_store_spec.rb
mongo_session_store-3.1.0 spec/lib/mongo_session_store_spec.rb
mongo_session_store-3.0.0 spec/lib/mongo_session_store_spec.rb
mongo_session_store-3.0.0.beta.1 spec/lib/mongo_session_store_spec.rb
mongo_session_store-rails-7.0.2 spec/lib/mongo_session_store_spec.rb
mongo_session_store-rails-7.0.1 spec/lib/mongo_session_store_spec.rb
mongo_session_store-rails-7.0.0 spec/lib/mongo_session_store_spec.rb