1 # Copyright 2010 Google Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 require 'google/api_client/parsers/json_parser'
19 require 'google/api_client/parsers/json/error_parser'
20 require 'google/api_client/parsers/json/pagination'
22 describe Google::APIClient::JSONParser, 'with error data' do
27 'message' => 'Token invalid - Invalid AuthSub token.',
30 'location' => 'Authorization',
32 'locationType' => 'header',
33 'reason' => 'authError',
34 'message' => 'Token invalid - Invalid AuthSub token.'
41 it 'should correctly match as an error' do
42 parser = Google::APIClient::JSONParser.match(@data)
43 parser.should == Google::APIClient::JSON::ErrorParser
46 it 'should be automatically handled as an error when parsed' do
47 data = Google::APIClient::JSONParser.parse(@data)
48 data.should be_kind_of(Google::APIClient::JSON::ErrorParser)
51 it 'should correctly expose error message' do
52 data = Google::APIClient::JSONParser.parse(@data)
53 data.error.should == 'Token invalid - Invalid AuthSub token.'