Sha256: c38d2fc64a9428035cf04b5b203968a6483e4b65be0e7e7bddef416edc5d3727

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

class SiteHub
  class Cookie
    describe Attribute do
      let(:attribute_name){'domain'}
      let(:attribute_value){'value'}
      subject do
        described_class.new(attribute_name, attribute_value)
      end
      describe '#initialize' do
        it 'stores the attribute name and its value' do
          expect(subject.name).to eq(attribute_name.to_sym)
          expect(subject.value).to eq(attribute_value)
        end

        it 'sanitises the string parameter' do
          expect(described_class.new("#{attribute_name} \n", attribute_value).name).to eq(attribute_name.to_sym)
        end

        context 'value is nil' do
          subject do
            described_class.new(attribute_name, nil)
          end

          it 'default to empty string' do
            expect(subject.value).to eq('')
          end
        end
      end

      describe '#to_s' do
        it 'contains the attribute name and value' do
          expect(subject.to_s).to eq("#{attribute_name}=#{attribute_value}")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitehub-0.4.2 spec/sitehub/cookie/attribute_spec.rb
sitehub-0.4.1 spec/sitehub/cookie/attribute_spec.rb