File: headers_spec.rb

package info (click to toggle)
ruby-http 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 404 kB
  • ctags: 213
  • sloc: ruby: 2,397; makefile: 7
file content (22 lines) | stat: -rw-r--r-- 545 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'spec_helper'

describe HTTP::Options, 'headers' do

  let(:opts) { HTTP::Options.new }

  it 'defaults to be empty' do
    expect(opts.headers).to be_empty
  end

  it 'may be specified with with_headers' do
    opts2 = opts.with_headers('accept' => 'json')
    expect(opts.headers).to be_empty
    expect(opts2.headers).to eq([%w[Accept json]])
  end

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

end