Sha256: 80b25d1019244f2fa592748914e70444d079e721273fb9df102ad67538605026

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 KB

Contents

require 'sitehub/cookie'

class SiteHub
  describe Cookie do
    let(:attribute_class) { described_class::Attribute }
    let(:flag_class) { described_class::Flag }
    let(:domain_attribute) { attribute_class.new(:domain.to_s, 'example.com') }
    let(:name) { 'sitehub.recorded_route' }
    let(:value) { 'new' }
    let(:cookie_string) { "#{name}=#{value}; HttpOnly; #{domain_attribute}" }

    subject do
      described_class.new cookie_string
    end

    describe '#initialize' do
      it 'parse a cookie string in to attributes and flags' do
        expect(subject.attributes_and_flags).to eq([flag_class.new('HttpOnly'), domain_attribute])
      end

      it 'extracts name as a symbol' do
        expect(subject.name).to eq('sitehub.recorded_route'.to_sym)
      end

      it 'extracts the value' do
        expect(subject.value).to eq('new')
      end
    end

    describe '#find' do
      context 'entry found' do
        it 'returns the entry with the given name' do
          expect(subject.find(:domain)).to eq(domain_attribute)
        end
      end

      context 'entry not found' do
        it 'returns nil' do
          expect(subject.find(:missing)).to eq(nil)
        end
      end
    end

    describe '#to_s' do
      it 'prints the attributes and flags' do
        expect(subject.to_s).to eq(cookie_string)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sitehub-0.5.0.alpha12 spec/sitehub/cookie_spec.rb
sitehub-0.4.10 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha11 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha10 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha8 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha7 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha6 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha5 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha4 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha3 spec/sitehub/cookie_spec.rb
sitehub-0.5.0.alpha2 spec/sitehub/cookie_spec.rb
sitehub-0.4.9 spec/sitehub/cookie_spec.rb
sitehub-0.4.8 spec/sitehub/cookie_spec.rb
sitehub-0.4.7 spec/sitehub/cookie_spec.rb
sitehub-0.4.6 spec/sitehub/cookie_spec.rb
sitehub-0.4.3 spec/sitehub/cookie_spec.rb