Sha256: 87139761a30a525d300d070860181989052226adf5c8b465abf6f96a6dc6e6bc

Contents?: true

Size: 800 Bytes

Versions: 2

Compression:

Stored size: 800 Bytes

Contents

require 'spec_helper'

describe Http::Options, "headers" do

  let(:opts)       { Http::Options.new }
  let(:user_agent) { "RubyHttpGem/#{Http::VERSION}" }

  it 'defaults to just the user agent' do
    opts.headers.should eq("User-Agent" => user_agent)
  end

  it 'may be specified with with_headers' do
    opts2 = opts.with_headers("accept" => "json")
    opts.headers.should eq("User-Agent" => user_agent)
    opts2.headers.should eq("accept" => "json", "User-Agent" => user_agent)
  end

  it 'accepts any object that respond to :to_hash' do
    x = Struct.new(:to_hash).new("accept" => "json")
    opts.with_headers(x).headers["accept"].should eq("json")
  end

  it 'recognizes invalid headers' do
    lambda{
      opts.with_headers(self)
    }.should raise_error(ArgumentError)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
http-0.5.0.pre spec/http/options/headers_spec.rb
http-0.4.0 spec/http/options/headers_spec.rb