Sha256: 55b3c4a63101355b1285905e6340567516a218c0c8d826aa3930c597dda5118f
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true require "spec_helper" require 'rack/test' describe Split::Persistence::CookieAdapter do let(:env) { Rack::MockRequest.env_for("http://example.com:8080/") } let(:request) { Rack::Request.new(env) } let(:response) { Rack::MockResponse.new(200, {}, "") } let(:context) { double(request: request, response: response) } subject { Split::Persistence::CookieAdapter.new(context) } describe "#[] and #[]=" do it "should set and return the value for given key" do subject["my_key"] = "my_value" expect(subject["my_key"]).to eq("my_value") end end describe "#delete" do it "should delete the given key" do subject["my_key"] = "my_value" subject.delete("my_key") expect(subject["my_key"]).to be_nil end end describe "#keys" do it "should return an array of the session's stored keys" do subject["my_key"] = "my_value" subject["my_second_key"] = "my_second_value" expect(subject.keys).to match(["my_key", "my_second_key"]) end end it "handles invalid JSON" do context.request.cookies[:split] = { :value => '{"foo":2,', :expires => Time.now } expect(subject["my_key"]).to be_nil subject["my_key"] = "my_value" expect(subject["my_key"]).to eq("my_value") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
split-3.2.0 | spec/persistence/cookie_adapter_spec.rb |
split-3.1.1 | spec/persistence/cookie_adapter_spec.rb |
split-3.1.0 | spec/persistence/cookie_adapter_spec.rb |