File: error_spec.rb

package info (click to toggle)
ruby-rack-oauth2 2.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 560 kB
  • sloc: ruby: 4,013; makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,734 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'spec_helper.rb'

describe Rack::OAuth2::Server::Abstract::Error do

  context 'when full attributes are given' do
    subject do
      Rack::OAuth2::Server::Abstract::Error.new 400, :invalid_request, 'Missing some required params', uri: 'http://server.example.com/error'
    end
    its(:status)      { should == 400 }
    its(:error)       { should == :invalid_request }
    its(:description) { should == 'Missing some required params' }
    its(:uri)         { should == 'http://server.example.com/error' }
    its(:protocol_params) do
      should == {
        error:             :invalid_request,
        error_description: 'Missing some required params',
        error_uri:         'http://server.example.com/error'
      }
    end
  end

  context 'when optional attributes are not given' do
    subject do
      Rack::OAuth2::Server::Abstract::Error.new 400, :invalid_request
    end
    its(:status)      { should == 400 }
    its(:error)       { should == :invalid_request }
    its(:description) { should be_nil }
    its(:uri)         { should be_nil }
    its(:protocol_params) do
      should == {
        error:             :invalid_request,
        error_description: nil,
        error_uri:         nil
      }
    end
  end

end

describe Rack::OAuth2::Server::Abstract::BadRequest do
  its(:status) { should == 400 }
end

describe Rack::OAuth2::Server::Abstract::Unauthorized do
  its(:status) { should == 401 }
end

describe Rack::OAuth2::Server::Abstract::Forbidden do
  its(:status) { should == 403 }
end

describe Rack::OAuth2::Server::Abstract::ServerError do
  its(:status) { should == 500 }
end

describe Rack::OAuth2::Server::Abstract::TemporarilyUnavailable do
  its(:status) { should == 503 }
end