typekit-client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGELOG.md +9 -5
  5. data/Guardfile +7 -0
  6. data/README.md +160 -131
  7. data/bin/typekit +21 -8
  8. data/lib/typekit/client.rb +5 -5
  9. data/lib/typekit/configuration/base.rb +1 -1
  10. data/lib/typekit/configuration/default.rb +9 -5
  11. data/lib/typekit/connection/dispatcher.rb +2 -2
  12. data/lib/typekit/connection/request.rb +5 -2
  13. data/lib/typekit/connection/response.rb +4 -8
  14. data/lib/typekit/helper.rb +22 -0
  15. data/lib/typekit/processing/converter/boolean.rb +11 -0
  16. data/lib/typekit/processing/converter/datetime.rb +11 -0
  17. data/lib/typekit/processing/converter/errors.rb +22 -0
  18. data/lib/typekit/processing/converter/record.rb +15 -0
  19. data/lib/typekit/processing/converter/records.rb +18 -0
  20. data/lib/typekit/processing/converter/unknown.rb +14 -0
  21. data/lib/typekit/processing/converter.rb +32 -0
  22. data/lib/typekit/processing/parser/json.rb +15 -0
  23. data/lib/typekit/processing/parser/yaml.rb +15 -0
  24. data/lib/typekit/processing/parser.rb +14 -0
  25. data/lib/typekit/processing/translator.rb +16 -0
  26. data/lib/typekit/processing.rb +9 -0
  27. data/lib/typekit/record/base.rb +30 -0
  28. data/lib/typekit/record/family.rb +7 -0
  29. data/lib/typekit/record/kit.rb +7 -0
  30. data/lib/typekit/record/library.rb +7 -0
  31. data/lib/typekit/record/variation.rb +8 -0
  32. data/lib/typekit/record.rb +35 -0
  33. data/lib/typekit/routing/{map.rb → mapper.rb} +1 -1
  34. data/lib/typekit/routing/node/base.rb +1 -0
  35. data/lib/typekit/routing.rb +1 -1
  36. data/lib/typekit/version.rb +1 -1
  37. data/lib/typekit.rb +4 -4
  38. data/spec/cassettes/delete_kits_xxx_ok.yml +16 -0
  39. data/spec/typekit/client_spec.rb +11 -3
  40. data/spec/typekit/configuration_spec.rb +20 -4
  41. data/spec/typekit/connection/dispatcher_spec.rb +4 -4
  42. data/spec/typekit/connection/response_spec.rb +18 -0
  43. data/spec/typekit/helper_spec.rb +34 -0
  44. data/spec/typekit/processing/converter_spec.rb +54 -0
  45. data/spec/typekit/processing/parser_spec.rb +23 -0
  46. data/spec/typekit/record/base_spec.rb +33 -0
  47. data/spec/typekit/record_spec.rb +48 -0
  48. data/spec/typekit/routing/mapper_spec.rb +177 -0
  49. data/spec/typekit/routing/node_spec.rb +31 -10
  50. data/typekit-client.gemspec +2 -1
  51. metadata +53 -13
  52. data/lib/typekit/parser/json.rb +0 -13
  53. data/lib/typekit/parser/yaml.rb +0 -13
  54. data/lib/typekit/parser.rb +0 -14
  55. data/lib/typekit/processor.rb +0 -38
  56. data/spec/typekit/processor_spec.rb +0 -34
  57. data/spec/typekit/routing/map_spec.rb +0 -106
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'typekit'
3
+
4
+ describe Typekit::Record::Base do
5
+ let(:subject_class) { Typekit::Record::Base }
6
+
7
+ describe '#new' do
8
+ it 'treats each option as an attribute to keep track of' do
9
+ subject = subject_class.new(name: 'Awesome')
10
+ expect { subject.name = 'Superb' }.to \
11
+ change { subject.name }.from('Awesome').to('Superb')
12
+ end
13
+
14
+ it 'handles attribute names given as strings' do
15
+ subject = subject_class.new('name' => 'Awesome')
16
+ expect { subject.name = 'Superb' }.to \
17
+ change { subject.name }.from('Awesome').to('Superb')
18
+ end
19
+ end
20
+
21
+ describe '#attributes' do
22
+ it 'returns all attributes' do
23
+ subject = subject_class.new(id: 1, name: 'Awesome')
24
+ expect(subject.attributes).to eq(id: 1, name: 'Awesome')
25
+ end
26
+
27
+ it 'reflects attribute assignments' do
28
+ subject = subject_class.new(id: 1)
29
+ subject.id = 42
30
+ expect(subject.attributes).to eq(id: 42)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'typekit'
3
+
4
+ describe Typekit::Record do
5
+ let(:subject_module) { Typekit::Record }
6
+
7
+ describe '.collections' do
8
+ it 'knows the major collections' do
9
+ expect(subject_module.collections).to \
10
+ match_array(%i{families kits libraries variations})
11
+ end
12
+ end
13
+
14
+ describe '.members' do
15
+ it 'knows the major members' do
16
+ expect(subject_module.members).to \
17
+ match_array(%i{family kit library variation})
18
+ end
19
+ end
20
+
21
+ describe '.collection?' do
22
+ %w{family kit library variation kitten kittens}.each do |name|
23
+ it "returns false for #{ name }" do
24
+ expect(subject_module.collection?(name)).to be_false
25
+ end
26
+ end
27
+
28
+ %w{families kits libraries variations}.each do |name|
29
+ it "returns true for #{ name }" do
30
+ expect(subject_module.collection?(name)).to be_true
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '.member?' do
36
+ %w{family kit library variation}.each do |name|
37
+ it "returns true for #{ name }" do
38
+ expect(subject_module.member?(name)).to be_true
39
+ end
40
+ end
41
+
42
+ %w{families kits libraries variations kitten kittens}.each do |name|
43
+ it "returns false for #{ name }" do
44
+ expect(subject_module.member?(name)).to be_false
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,177 @@
1
+ require 'spec_helper'
2
+ require 'typekit'
3
+
4
+ describe Typekit::Routing::Mapper do
5
+ extend RESTHelper
6
+
7
+ def create_request(action)
8
+ # TODO: mock?
9
+ Typekit::Connection::Request.new(action: action)
10
+ end
11
+
12
+ describe '#define' do
13
+ it 'declares new resources' do
14
+ subject.define { resources(:kits) }
15
+ request = subject.trace(create_request(:index), [ :kits ])
16
+ expect(request.address).to eq('kits')
17
+ end
18
+
19
+ it 'declares nested resources' do
20
+ subject.define { resources(:kits) { resources(:families) } }
21
+ request = subject.trace(create_request(:show),
22
+ [ :kits, 'xxx', :families, 'yyy' ])
23
+ expect(request.address).to eq('kits/xxx/families/yyy')
24
+ end
25
+
26
+ it 'declares scoped resources' do
27
+ subject.define do
28
+ scope 'https://typekit.com/api' do
29
+ scope [ 'v1', :json ] do
30
+ resources(:kits) { resources(:families) }
31
+ end
32
+ end
33
+ end
34
+ request = subject.trace(create_request(:show),
35
+ [ :kits, 'xxx', :families, 'yyy' ])
36
+ expect(request.address).to eq(
37
+ 'https://typekit.com/api/v1/json/kits/xxx/families/yyy')
38
+ end
39
+
40
+ it 'declares custom operations' do
41
+ subject.define { resources(:kits) { show(:published, on: :member) } }
42
+ request = subject.trace(create_request(:show),
43
+ [ :kits, 'xxx', :published ])
44
+ expect(request.address).to eq('kits/xxx/published')
45
+ end
46
+
47
+ it 'declares custom operations with variable names' do
48
+ subject.define do
49
+ resources :kits do
50
+ resources :families do
51
+ show ':variant', on: :member
52
+ end
53
+ end
54
+ end
55
+ request = subject.trace(create_request(:show),
56
+ [ :kits, 'xxx', :families, 'yyy', 'zzz' ])
57
+ expect(request.address).to eq('kits/xxx/families/yyy/zzz')
58
+ end
59
+ end
60
+
61
+ describe '#trace' do
62
+ shared_examples 'adequate resource tracer' do
63
+ restful_member_actions.each do |action|
64
+ it "assembles addresses of #{ action } Requests" do
65
+ request = subject.trace(create_request(action),
66
+ [ *subject_path, 'xxx' ])
67
+ expect(request.address).to eq("#{ subject_address }/xxx")
68
+ end
69
+ end
70
+
71
+ restful_collection_actions.each do |action|
72
+ it "assembles addresses of #{ action } Requests" do
73
+ request = subject.trace(create_request(action), subject_path)
74
+ expect(request.address).to eq(subject_address)
75
+ end
76
+ end
77
+
78
+ restful_member_actions.each do |action|
79
+ it "raises exceptions for #{ action } actions to collections" do
80
+ expect do
81
+ subject.trace(create_request(action), subject_path)
82
+ end.to raise_error(Typekit::Routing::Error, /Not permitted/i)
83
+ end
84
+ end
85
+
86
+ restful_collection_actions.each do |action|
87
+ it "raises exceptions for #{ action } actions to members" do
88
+ expect do
89
+ subject.trace(create_request(action), [ *subject_path, 'xxx' ])
90
+ end.to raise_error(Typekit::Routing::Error, /Not permitted/i)
91
+ end
92
+ end
93
+ end
94
+
95
+ context 'when working with plain collections' do
96
+ before(:each) do
97
+ subject.define { resources(:kits) }
98
+ end
99
+
100
+ let(:subject_path) { [ :kits ] }
101
+ let(:subject_address) { 'kits' }
102
+
103
+ it_behaves_like 'adequate resource tracer'
104
+ end
105
+
106
+ context 'when working with nested collections' do
107
+ before(:each) do
108
+ subject.define do
109
+ resources :kits do
110
+ resources :families
111
+ end
112
+ end
113
+ end
114
+
115
+ let(:subject_path) { [ :kits, 'yyy', :families ] }
116
+ let(:subject_address) { 'kits/yyy/families' }
117
+
118
+ it_behaves_like 'adequate resource tracer'
119
+ end
120
+
121
+ family_actions = [ :show, :update, :delete ]
122
+
123
+ context "when only #{ family_actions.join(', ') } are allowed" do
124
+ before(:each) do
125
+ subject.define do
126
+ resources :kits do
127
+ resources :families, only: family_actions
128
+ end
129
+ end
130
+ end
131
+
132
+ (restful_collection_actions - family_actions).each do |action|
133
+ it "raises expections for #{ action } actions" do
134
+ expect do
135
+ subject.trace(create_request(action),
136
+ [ :kits, 'xxx', :families ])
137
+ end.to raise_error(Typekit::Routing::Error, /Not permitted/i)
138
+ end
139
+ end
140
+
141
+ (restful_member_actions - family_actions).each do |action|
142
+ it "raises expections for #{ action } actions" do
143
+ expect do
144
+ subject.trace(create_request(action),
145
+ [ :kits, 'xxx', :families, 'yyy' ])
146
+ end.to raise_error(Typekit::Routing::Error, /Not permitted/i)
147
+ end
148
+ end
149
+ end
150
+
151
+ restful_actions.each do |action|
152
+ it "assembles addresses for custom #{ action } actions" do
153
+ subject.define do
154
+ resources :kits do
155
+ send(action, :havefun, on: :member)
156
+ end
157
+ end
158
+ request = subject.trace(create_request(action),
159
+ [ :kits, 'xxx', :havefun ])
160
+ expect(request.address).to eq('kits/xxx/havefun')
161
+ end
162
+ end
163
+
164
+ it 'does not support reopening of resource declarations' do
165
+ subject.define do
166
+ resources :kits
167
+ resources :kits do
168
+ resources :families
169
+ end
170
+ end
171
+ expect do
172
+ subject.trace(create_request(:show),
173
+ [ :kits, 'xxx', :families, 'yyy' ])
174
+ end.to raise_error(Typekit::Routing::Error, /Not found/i)
175
+ end
176
+ end
177
+ end
@@ -4,6 +4,11 @@ require 'typekit'
4
4
  describe Typekit::Routing::Node do
5
5
  extend RESTHelper
6
6
 
7
+ def create_request(action)
8
+ # TODO: mock?
9
+ Typekit::Connection::Request.new(action: action)
10
+ end
11
+
7
12
  let(:subject_module) { Typekit::Routing::Node }
8
13
 
9
14
  def create_tree(*path)
@@ -19,21 +24,37 @@ describe Typekit::Routing::Node do
19
24
  describe 'Base#assemble' do
20
25
  let(:root) { create_tree(:kits, :families) }
21
26
 
27
+ shared_examples 'adequate assembler' do
28
+ let(:request) { create_request(action) }
29
+
30
+ it 'builds up Requests' do
31
+ expect(request).to receive(:<<).
32
+ exactly(path.size).times.and_call_original
33
+ root.assemble(request, path)
34
+ end
35
+
36
+ it 'signs Requests' do
37
+ expect(request).to receive(:sign).
38
+ with(satisfy { |n| n.match(:families) })
39
+ root.assemble(request, path)
40
+ end
41
+ end
42
+
22
43
  restful_collection_actions.each do |action|
23
- it "builds up #{ action } Requests" do
24
- request = double('Request', :<< => nil, :action => action,
25
- :path => [ :kits, 'xxx', :families ])
26
- root.assemble(request, [ :kits, 'xxx', :families ])
27
- expect(request).to have_received(:<<).exactly(3).times
44
+ context "when tracing #{ action } actions" do
45
+ let(:action) { action }
46
+ let(:path) { [ :kits, 'xxx', :families ] }
47
+
48
+ it_behaves_like 'adequate assembler'
28
49
  end
29
50
  end
30
51
 
31
52
  restful_member_actions.each do |action|
32
- it "builds up #{ action } Requests" do
33
- request = double('Request', :<< => nil, :action => action,
34
- :path => [ :kits, 'xxx', :families, 'yyy' ])
35
- root.assemble(request, [ :kits, 'xxx', :families, 'yyy' ])
36
- expect(request).to have_received(:<<).exactly(4).times
53
+ context "when tracing #{ action } actions" do
54
+ let(:action) { action }
55
+ let(:path) { [ :kits, 'xxx', :families, 'yyy' ] }
56
+
57
+ it_behaves_like 'adequate assembler'
37
58
  end
38
59
  end
39
60
  end
@@ -26,8 +26,9 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'json', '~> 1.8'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.6'
29
- spec.add_development_dependency 'rake', '~> 0'
29
+ spec.add_development_dependency 'rake'
30
30
  spec.add_development_dependency 'rspec', '~> 2.14'
31
+ spec.add_development_dependency 'guard-rspec', '~> 4.2'
31
32
  spec.add_development_dependency 'webmock', '~> 1.18'
32
33
  spec.add_development_dependency 'vcr', '~> 2.9'
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typekit-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Ukhov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.2'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: webmock
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -119,8 +133,10 @@ extra_rdoc_files: []
119
133
  files:
120
134
  - ".gitignore"
121
135
  - ".rspec"
136
+ - ".travis.yml"
122
137
  - CHANGELOG.md
123
138
  - Gemfile
139
+ - Guardfile
124
140
  - LICENSE.txt
125
141
  - README.md
126
142
  - Rakefile
@@ -138,12 +154,26 @@ files:
138
154
  - lib/typekit/connection/response.rb
139
155
  - lib/typekit/core.rb
140
156
  - lib/typekit/helper.rb
141
- - lib/typekit/parser.rb
142
- - lib/typekit/parser/json.rb
143
- - lib/typekit/parser/yaml.rb
144
- - lib/typekit/processor.rb
157
+ - lib/typekit/processing.rb
158
+ - lib/typekit/processing/converter.rb
159
+ - lib/typekit/processing/converter/boolean.rb
160
+ - lib/typekit/processing/converter/datetime.rb
161
+ - lib/typekit/processing/converter/errors.rb
162
+ - lib/typekit/processing/converter/record.rb
163
+ - lib/typekit/processing/converter/records.rb
164
+ - lib/typekit/processing/converter/unknown.rb
165
+ - lib/typekit/processing/parser.rb
166
+ - lib/typekit/processing/parser/json.rb
167
+ - lib/typekit/processing/parser/yaml.rb
168
+ - lib/typekit/processing/translator.rb
169
+ - lib/typekit/record.rb
170
+ - lib/typekit/record/base.rb
171
+ - lib/typekit/record/family.rb
172
+ - lib/typekit/record/kit.rb
173
+ - lib/typekit/record/library.rb
174
+ - lib/typekit/record/variation.rb
145
175
  - lib/typekit/routing.rb
146
- - lib/typekit/routing/map.rb
176
+ - lib/typekit/routing/mapper.rb
147
177
  - lib/typekit/routing/node.rb
148
178
  - lib/typekit/routing/node/base.rb
149
179
  - lib/typekit/routing/node/collection.rb
@@ -152,6 +182,7 @@ files:
152
182
  - lib/typekit/routing/node/scope.rb
153
183
  - lib/typekit/routing/proxy.rb
154
184
  - lib/typekit/version.rb
185
+ - spec/cassettes/delete_kits_xxx_ok.yml
155
186
  - spec/cassettes/index_kits_ok.yml
156
187
  - spec/cassettes/index_kits_unauthorized.yml
157
188
  - spec/cassettes/show_families_calluna_found.yml
@@ -162,9 +193,13 @@ files:
162
193
  - spec/typekit/connection/adaptor_spec.rb
163
194
  - spec/typekit/connection/dispatcher_spec.rb
164
195
  - spec/typekit/connection/request_spec.rb
196
+ - spec/typekit/connection/response_spec.rb
165
197
  - spec/typekit/helper_spec.rb
166
- - spec/typekit/processor_spec.rb
167
- - spec/typekit/routing/map_spec.rb
198
+ - spec/typekit/processing/converter_spec.rb
199
+ - spec/typekit/processing/parser_spec.rb
200
+ - spec/typekit/record/base_spec.rb
201
+ - spec/typekit/record_spec.rb
202
+ - spec/typekit/routing/mapper_spec.rb
168
203
  - spec/typekit/routing/node_spec.rb
169
204
  - typekit-client.gemspec
170
205
  homepage: https://github.com/IvanUkhov/typekit-client
@@ -192,6 +227,7 @@ signing_key:
192
227
  specification_version: 4
193
228
  summary: A Ruby library for accessing the Typekit API
194
229
  test_files:
230
+ - spec/cassettes/delete_kits_xxx_ok.yml
195
231
  - spec/cassettes/index_kits_ok.yml
196
232
  - spec/cassettes/index_kits_unauthorized.yml
197
233
  - spec/cassettes/show_families_calluna_found.yml
@@ -202,7 +238,11 @@ test_files:
202
238
  - spec/typekit/connection/adaptor_spec.rb
203
239
  - spec/typekit/connection/dispatcher_spec.rb
204
240
  - spec/typekit/connection/request_spec.rb
241
+ - spec/typekit/connection/response_spec.rb
205
242
  - spec/typekit/helper_spec.rb
206
- - spec/typekit/processor_spec.rb
207
- - spec/typekit/routing/map_spec.rb
243
+ - spec/typekit/processing/converter_spec.rb
244
+ - spec/typekit/processing/parser_spec.rb
245
+ - spec/typekit/record/base_spec.rb
246
+ - spec/typekit/record_spec.rb
247
+ - spec/typekit/routing/mapper_spec.rb
208
248
  - spec/typekit/routing/node_spec.rb
@@ -1,13 +0,0 @@
1
- require 'json'
2
-
3
- module Typekit
4
- module Parser
5
- class JSON
6
- def process(data)
7
- ::JSON.parse(data)
8
- rescue
9
- raise Error, 'Unable to parse'
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require 'yaml'
2
-
3
- module Typekit
4
- module Parser
5
- class YAML
6
- def process(data)
7
- ::YAML.load(data)
8
- rescue
9
- raise Error, 'Unable to parse'
10
- end
11
- end
12
- end
13
- end
@@ -1,14 +0,0 @@
1
- require_relative 'parser/json'
2
- require_relative 'parser/yaml'
3
-
4
- module Typekit
5
- module Parser
6
- Error = Class.new(Typekit::Error)
7
-
8
- def self.build(format)
9
- self.const_get(format.to_s.upcase).new
10
- rescue NameError
11
- raise Error, 'Unknown format'
12
- end
13
- end
14
- end
@@ -1,38 +0,0 @@
1
- module Typekit
2
- class Processor
3
- ERRORS = {
4
- 400 => 'There are errors in the data provided by your application',
5
- 401 => 'Authentication is needed to access the requested endpoint',
6
- 403 => 'Your application has been rate limited',
7
- 404 => 'You are requesting a resource that does not exist',
8
- 500 => 'Typekit’s servers are unable to process the request',
9
- 503 => 'Typekit’s API is offline for maintenance'
10
- }.freeze
11
-
12
- def initialize(format:)
13
- @parser = Parser.build(format)
14
- end
15
-
16
- def process(response)
17
- if response.success?
18
- data = @parser.process(response.content)
19
- process_success(response, data)
20
- else
21
- data = @parser.process(response.content) rescue {}
22
- process_failure(response, data)
23
- end
24
- end
25
-
26
- private
27
-
28
- def process_success(request, data)
29
- data
30
- end
31
-
32
- def process_failure(request, data)
33
- return data if request.redirect?
34
- message = data['errors'] || ERRORS[request.code] || 'Unknown server error'
35
- raise Error, Array(message).join(', ')
36
- end
37
- end
38
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
- require 'typekit'
3
-
4
- describe Typekit::Processor do
5
- def create(format)
6
- Typekit::Processor.new(format: format)
7
- end
8
-
9
- it 'supports JSON' do
10
- parser = create(:json)
11
- response = double(success?: true, content: '{ "a": 1 }')
12
- result = parser.process(response)
13
- expect(result).to eq("a" => 1)
14
- end
15
-
16
- it 'supports YAML' do
17
- parser = create(:yaml)
18
- response = double(success?: true, content: "---\na: 1")
19
- result = parser.process(response)
20
- expect(result).to eq("a" => 1)
21
- end
22
-
23
- it 'does not support XML' do
24
- expect { create(:xml) }.to raise_error
25
- end
26
-
27
- it 'raises an appropriate exception when a request fails' do
28
- parser = create(:json)
29
- response = double(success?: false, redirect?: false, code: 401,
30
- content: '{ "errors": [ "Not authorized" ] }')
31
- expect { parser.process(response) }.to \
32
- raise_error(Typekit::Error, 'Not authorized')
33
- end
34
- end