Sha256: f80a748ff9abb80a47002e45dff6045c5441a16fd4e354bb4f3d80e8cf4227d4

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require "spec_helper"

describe Split::Persistence do

  subject { Split::Persistence }

  describe ".adapter" do
    context "when the persistence config is a symbol" do
      it "should return the appropriate adapter for the symbol" do
        expect(Split.configuration).to receive(:persistence).twice.and_return(:cookie)
        expect(subject.adapter).to eq(Split::Persistence::CookieAdapter)
      end

      it "should return an adapter whose class is present in Split::Persistence::ADAPTERS" do
        expect(Split.configuration).to receive(:persistence).twice.and_return(:cookie)
        expect(Split::Persistence::ADAPTERS.values).to include(subject.adapter)
      end

      it "should raise if the adapter cannot be found" do
        expect(Split.configuration).to receive(:persistence).twice.and_return(:something_weird)
        expect { subject.adapter }.to raise_error
      end
    end
    context "when the persistence config is a class" do
      let(:custom_adapter_class) { MyCustomAdapterClass = Class.new }
      it "should return that class" do
        expect(Split.configuration).to receive(:persistence).twice.and_return(custom_adapter_class)
        expect(subject.adapter).to eq(MyCustomAdapterClass)
      end
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
split-1.3.0 spec/persistence_spec.rb
split-1.2.1 spec/persistence_spec.rb
split-1.2.0 spec/persistence_spec.rb
split-1.1.0 spec/persistence_spec.rb
split-1.0.0 spec/persistence_spec.rb
split-0.8.0 spec/persistence_spec.rb
split-0.7.3 spec/persistence_spec.rb