|
69 | 69 | subject.call({}).first.should == 200 |
70 | 70 | end |
71 | 71 |
|
72 | | - it 'should return a 404 when no header is set but strict header based versioning is used' do |
73 | | - @options = { |
74 | | - :versions => ['v1'], |
75 | | - :version_options => {:using => :header, :strict => true} |
76 | | - } |
77 | | - expect { |
78 | | - env = subject.call('HTTP_ACCEPT' => '').last |
79 | | - }.to throw_symbol(:error, :status => 404, :headers => {'X-Cascade' => 'pass'}, :message => "404 API Version Not Found") |
| 72 | + context 'when strict header versioning is used' do |
| 73 | + it 'should return a 406 when no header' do |
| 74 | + @options = { |
| 75 | + :versions => ['v1'], |
| 76 | + :version_options => {:using => :header, :strict => true} |
| 77 | + } |
| 78 | + expect { |
| 79 | + env = subject.call('HTTP_ACCEPT' => '').last |
| 80 | + }.to throw_symbol( |
| 81 | + :error, |
| 82 | + :status => 406, |
| 83 | + :headers => {'X-Cascade' => 'pass'}, |
| 84 | + :message => "406 API Version Not Found" |
| 85 | + ) |
| 86 | + end |
| 87 | + |
| 88 | + it 'should return a 406 when incorrect header format is used' do |
| 89 | + @options = { |
| 90 | + :versions => ['v1'], |
| 91 | + :version_options => {:using => :header, :strict => true} |
| 92 | + } |
| 93 | + expect { |
| 94 | + env = subject.call('HTTP_ACCEPT' => '*/*').last |
| 95 | + }.to throw_symbol( |
| 96 | + :error, |
| 97 | + :status => 406, |
| 98 | + :headers => {'X-Cascade' => 'pass'}, |
| 99 | + :message => "406 API Version Not Found" |
| 100 | + ) |
| 101 | + end |
| 102 | + |
| 103 | + it 'should return a 200 when proper header is set' do |
| 104 | + @options = { |
| 105 | + :versions => ['v1'], |
| 106 | + :version_options => {:using => :header, :strict => true} |
| 107 | + } |
| 108 | + subject.call('HTTP_ACCEPT' => 'application/vnd.testing-v1+json').first.should == 200 |
| 109 | + end |
80 | 110 | end |
| 111 | + |
81 | 112 | end |
82 | 113 |
|
83 | 114 | context 'vendors' do |
|
96 | 127 | it 'should not match with an incorrect vendor' do |
97 | 128 | expect { |
98 | 129 | env = subject.call('HTTP_ACCEPT' => 'application/vnd.othervendor-v1+json').last |
99 | | - }.to throw_symbol(:error, :status => 404, :headers => {'X-Cascade' => 'pass'}, :message => "404 API Version Not Found") |
| 130 | + }.to throw_symbol(:error, :status => 406, :headers => {'X-Cascade' => 'pass'}, :message => "406 API Version Not Found") |
100 | 131 | end |
101 | 132 | end |
102 | 133 |
|
|
108 | 139 | } |
109 | 140 | end |
110 | 141 |
|
111 | | - it 'should throw 404 error with X-Cascade header set to pass' do |
| 142 | + it 'should throw 406 error with X-Cascade header set to pass' do |
112 | 143 | expect { |
113 | 144 | env = subject.call('HTTP_ACCEPT' => accept).last |
114 | | - }.to throw_symbol(:error, :status => 404, :headers => {'X-Cascade' => 'pass'}, :message => "404 API Version Not Found") |
| 145 | + }.to throw_symbol(:error, :status => 406, :headers => {'X-Cascade' => 'pass'}, :message => "406 API Version Not Found") |
115 | 146 | end |
116 | 147 | end |
117 | 148 | end |
0 commit comments