Sha256: 3c073fda72e784c4f99b14ca6b785ce8684887cce40378963d1c4182245cf54f

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Webmachine::Response do

  it "should have sane default values" do
    expect(subject.code).to eq(200)
    expect(subject.is_redirect?).to be(false)
    expect(subject.headers).to be_empty
  end

  describe "a redirected response" do
    let(:redirect_url) { "/" }

    before(:each) { subject.redirect_to redirect_url }

    its(:is_redirect?) { should be(true) }

    it "should have a proper Location header" do
      expect(subject.headers["Location"]).to eq(redirect_url)
    end
  end

  describe "setting a cookie" do
    let(:cookie) { "monster" }
    let(:cookie_value) { "mash" }

    before(:each) { subject.set_cookie(cookie, cookie_value) }

    it "should have a proper Set-Cookie header" do
      expect(subject.headers["Set-Cookie"]).to include "monster=mash"
    end

    describe "setting multiple cookies" do
      let(:cookie2) { "rodeo" }
      let(:cookie2_value) { "clown" }
      before(:each) { subject.set_cookie(cookie2, cookie2_value) }

      it "should have a proper Set-Cookie header" do
        expect(subject.headers["Set-Cookie"]).to be_a Array
        expect(subject.headers["Set-Cookie"]).to include "rodeo=clown"
        expect(subject.headers["Set-Cookie"]).to include "monster=mash"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
webmachine-1.4.0 spec/webmachine/response_spec.rb
webmachine-1.3.1 spec/webmachine/response_spec.rb
webmachine-1.3.0 spec/webmachine/response_spec.rb