Sha256: 9389f10a94be782505e49ac083275a2dd0a1bfe7262b1834def9fc61b5902e46

Contents?: true

Size: 899 Bytes

Versions: 2

Compression:

Stored size: 899 Bytes

Contents

require 'spec_helper'

describe Kissable::SinatraCookieAdapter do
  let(:response)  { double('response') }
  let(:request)   { double('request') }
  let(:name)      { 'name' }
  let(:value)     { 'value' }
  subject(:cookie_adapter) { Kissable::SinatraCookieAdapter.new(request, response) }

  describe "#initialize" do
    it { should respond_to(:request) }
    it { should respond_to(:response) }
  end

  describe "#[]" do
    it "calls request.cookies with cookie_name" do
      request.should_receive(:cookies).and_return({})
      cookie_adapter[name]
    end

    it "returns the stored value" do
      request.stub(:cookies).and_return({name => value})
      expect(cookie_adapter[name]).to eq(value)
    end
  end

  describe "#[]=" do
    it "calls set_cookie on response" do
      response.should_receive(:set_cookie).with(name, value)
      cookie_adapter[name] = value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kissable-1.0.1 spec/kissable/sinatra_cookie_adapter_spec.rb
kissable-1.0.0a1 spec/kissable/sinatra_cookie_adapter_spec.rb