Sha256: e3fc355061d08ab4ba2422be2ad7c55ebd995558e9e47a96aa6be69aab6a36fa

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

RSpec.describe Rambo::RamlModels::Headers do
  let(:headers)   { { "Content-Type" => "application/json" } }

  subject { described_class.new(headers) }

  describe "#pretty" do
    let(:pretty) do
      %Q[{\n  "Content-Type" => "application/json"\n}]
    end

    it "makes it pretty" do
      expect(subject.pretty).to eql pretty
    end

    context "multiple headers" do
      let(:headers) { { "Content-Type" => "application/json", "Accept" => "application/json" } }

      let(:pretty) do
        %Q[{\n  "Content-Type" => "application/json",\n  "Accept" => "application/json"\n}]
      end

      it "formats the header hash" do
        expect(subject.pretty).to eql pretty
      end
    end
  end

  describe "#add" do
    it "adds an additional header" do
      subject.add("Accept" => "application/json")
      expect(subject.headers).to eql({ "Content-Type" => "application/json", "Accept" => "application/json" })
    end

    it "returns self" do
      expect(subject.add("Accept" => "application/json")).to be subject
    end
  end

  describe "#merge!" do
    it "combines two sets of headers" do
      expect(subject.merge!(described_class.new({"Accept" => "application/json"}))).to be_a(described_class)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rambo_ruby-0.7.1 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.7.0 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.6.0 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.5.0 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.4.0 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.3.3 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.3.2 spec/lib/rambo/raml_models/headers_spec.rb
rambo_ruby-0.3.1 spec/lib/rambo/raml_models/headers_spec.rb