OSDN Git Service

98ee4709d1584b2654b6f1ed2ba1774d6a9e0eb5
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / thin-1.2.11-x86-mswin32 / spec / headers_spec.rb
1 require File.dirname(__FILE__) + '/spec_helper'
2
3 describe Headers do
4   before do
5     @headers = Headers.new
6   end
7   
8   it 'should allow duplicate on some fields' do
9     @headers['Set-Cookie'] = 'twice'
10     @headers['Set-Cookie'] = 'is cooler the once'
11     
12     @headers.to_s.should == "Set-Cookie: twice\r\nSet-Cookie: is cooler the once\r\n"
13   end
14   
15   it 'should overwrite value on non duplicate fields' do
16     @headers['Host'] = 'this is unique'
17     @headers['Host'] = 'so is this'
18
19     @headers.to_s.should == "Host: this is unique\r\n"
20   end
21   
22   it 'should output to string' do
23     @headers['Host'] = 'localhost:3000'
24     @headers['Set-Cookie'] = 'twice'
25     @headers['Set-Cookie'] = 'is cooler the once'
26     
27     @headers.to_s.should == "Host: localhost:3000\r\nSet-Cookie: twice\r\nSet-Cookie: is cooler the once\r\n"
28   end
29
30   it 'should ignore nil values' do
31     @headers['Something'] = nil
32     @headers.to_s.should_not include('Something: ')
33   end
34
35   it 'should format Time values correctly' do
36     time = Time.now
37     @headers['Modified-At'] = time
38     @headers.to_s.should include("Modified-At: #{time.httpdate}")
39   end
40 end