Sha256: 615488f16bf357b15fd2a7bb49dd5241a969bd7f0b2ca8046e6735c3ed0c80ab

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'
require 'example_page'

require 'spidr/page'

describe Page do
  include_context "example Page"

  let(:name)    { 'foo' }
  let(:value)   { 'bar' }
  let(:path)    { '/'   }
  let(:cookie)  { "#{name}=#{value}; Path=#{path}; Domain=#{host}; Secure; HTTPOnly" }
  let(:headers) do
    {'Set-Cookie' => cookie}
  end

  describe "#cookie" do
    it "should return the Set-Cookie header as a String" do
      expect(subject.cookie).to be == cookie
    end

    context "when Set-Cookie is not set" do
      let(:headers) { {} }

      it "should return an empty String" do
        expect(subject.cookie).to be == ''
      end
    end
  end

  describe "#cookies" do
    it "should return the Set-Cookie header as an Array" do
      expect(subject.cookies).to be == [cookie]
    end

    context "when Set-Cookie is not set" do
      let(:headers) { {} }

      it "should return an empty Array" do
        expect(subject.cookies).to be == []
      end
    end
  end

  describe "#cookie_params" do
    it "should parse the cookie params into a Hash" do
      expect(subject.cookie_params).to be == {name => value}
    end

    context "when the cookie has no value" do
      let(:value) { '' }

      it "should default the value to an empty String" do
        expect(subject.cookie_params[name]).to be == ''
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spidr-0.7.1 spec/page/cookies_spec.rb
spidr-0.7.0 spec/page/cookies_spec.rb
spidr-0.6.1 spec/page/cookies_spec.rb
spidr-0.6.0 spec/page/cookies_spec.rb