zendesk_api 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zendesk_api/client.rb +1 -1
  3. data/lib/zendesk_api/middleware/response/parse_json.rb +0 -1
  4. data/lib/zendesk_api/version.rb +1 -1
  5. metadata +10 -205
  6. data/.gitignore +0 -15
  7. data/.rspec +0 -2
  8. data/.travis.yml +0 -10
  9. data/.yardopts +0 -10
  10. data/Gemfile +0 -14
  11. data/LICENSE +0 -176
  12. data/README.md +0 -425
  13. data/Rakefile +0 -52
  14. data/spec/core/association_spec.rb +0 -256
  15. data/spec/core/bulk_actions_spec.rb +0 -69
  16. data/spec/core/client_spec.rb +0 -280
  17. data/spec/core/collection_spec.rb +0 -901
  18. data/spec/core/configuration_spec.rb +0 -28
  19. data/spec/core/create_resource_spec.rb +0 -39
  20. data/spec/core/data_namespace_spec.rb +0 -15
  21. data/spec/core/data_resource_spec.rb +0 -239
  22. data/spec/core/inflection_spec.rb +0 -7
  23. data/spec/core/lru_cache_spec.rb +0 -26
  24. data/spec/core/middleware/request/encode_json_spec.rb +0 -73
  25. data/spec/core/middleware/request/etag_cache_spec.rb +0 -21
  26. data/spec/core/middleware/request/retry_spec.rb +0 -49
  27. data/spec/core/middleware/request/test.jpg +0 -0
  28. data/spec/core/middleware/request/upload_spec.rb +0 -164
  29. data/spec/core/middleware/response/callback_spec.rb +0 -17
  30. data/spec/core/middleware/response/deflate_spec.rb +0 -21
  31. data/spec/core/middleware/response/gzip_spec.rb +0 -25
  32. data/spec/core/middleware/response/parse_iso_dates_spec.rb +0 -44
  33. data/spec/core/middleware/response/parse_json_spec.rb +0 -53
  34. data/spec/core/middleware/response/raise_error_spec.rb +0 -128
  35. data/spec/core/middleware/response/sanitize_response_spec.rb +0 -19
  36. data/spec/core/read_resource_spec.rb +0 -97
  37. data/spec/core/resource_spec.rb +0 -541
  38. data/spec/core/resources/automation_spec.rb +0 -81
  39. data/spec/core/resources/macro_spec.rb +0 -27
  40. data/spec/core/resources/trigger_spec.rb +0 -67
  41. data/spec/core/resources/view_spec.rb +0 -97
  42. data/spec/core/search_spec.rb +0 -23
  43. data/spec/core/spec_helper.rb +0 -162
  44. data/spec/core/trackie_spec.rb +0 -129
  45. data/spec/fixtures/Argentina.gif +0 -0
  46. data/spec/fixtures/Argentina2.gif +0 -0
  47. data/spec/fixtures/credentials.yml.example +0 -3
  48. data/spec/fixtures/sample_app.zip +0 -0
  49. data/spec/fixtures/test_resources.rb +0 -22
  50. data/spec/fixtures/zendesk.rb +0 -109
  51. data/spec/live/Readme.md +0 -4
  52. data/spec/live/activity_spec.rb +0 -12
  53. data/spec/live/app_installation_spec.rb +0 -58
  54. data/spec/live/app_spec.rb +0 -58
  55. data/spec/live/audit_spec.rb +0 -15
  56. data/spec/live/automation_spec.rb +0 -23
  57. data/spec/live/bookmark_spec.rb +0 -11
  58. data/spec/live/brand_spec.rb +0 -14
  59. data/spec/live/category_spec.rb +0 -12
  60. data/spec/live/collection_spec.rb +0 -64
  61. data/spec/live/custom_role_spec.rb +0 -5
  62. data/spec/live/dynamic_content/item_spec.rb +0 -16
  63. data/spec/live/dynamic_content/variant_spec.rb +0 -19
  64. data/spec/live/forum_spec.rb +0 -14
  65. data/spec/live/forum_subscription_spec.rb +0 -12
  66. data/spec/live/group_membership_spec.rb +0 -18
  67. data/spec/live/group_spec.rb +0 -32
  68. data/spec/live/identity_spec.rb +0 -14
  69. data/spec/live/locale_spec.rb +0 -9
  70. data/spec/live/macro_spec.rb +0 -44
  71. data/spec/live/organization_field_spec.rb +0 -12
  72. data/spec/live/organization_membership_spec.rb +0 -11
  73. data/spec/live/organization_spec.rb +0 -12
  74. data/spec/live/push_notification_device_spec.rb +0 -21
  75. data/spec/live/request_spec.rb +0 -38
  76. data/spec/live/satisfaction_rating_spec.rb +0 -6
  77. data/spec/live/setting_spec.rb +0 -25
  78. data/spec/live/suspended_ticket_spec.rb +0 -8
  79. data/spec/live/tag_spec.rb +0 -58
  80. data/spec/live/target_spec.rb +0 -17
  81. data/spec/live/ticket_field_spec.rb +0 -12
  82. data/spec/live/ticket_form_spec.rb +0 -14
  83. data/spec/live/ticket_metrics_spec.rb +0 -6
  84. data/spec/live/ticket_spec.rb +0 -136
  85. data/spec/live/topic_comment_spec.rb +0 -52
  86. data/spec/live/topic_spec.rb +0 -46
  87. data/spec/live/topic_subscription_spec.rb +0 -12
  88. data/spec/live/topic_vote_spec.rb +0 -13
  89. data/spec/live/trigger_spec.rb +0 -23
  90. data/spec/live/upload_spec.rb +0 -10
  91. data/spec/live/user_field_spec.rb +0 -12
  92. data/spec/live/user_spec.rb +0 -71
  93. data/spec/live/user_view_spec.rb +0 -16
  94. data/spec/live/view_spec.rb +0 -22
  95. data/spec/live/voice/phone_number_spec.rb +0 -13
  96. data/spec/macros/resource_macros.rb +0 -169
  97. data/zendesk_api.gemspec +0 -38
@@ -1,256 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Association do
4
- let(:instance) { ZendeskAPI::TestResource.new(client, :id => 1) }
5
- let(:child) { ZendeskAPI::TestResource::TestChild.new(client, :id => 1, :test_resource_id => 2) }
6
-
7
- describe "setting/getting" do
8
- context "has" do
9
- before do
10
- ZendeskAPI::TestResource.associations.clear
11
- ZendeskAPI::TestResource.has :child, :class => ZendeskAPI::TestResource::TestChild
12
- end
13
-
14
- it "should not try and fetch nil child" do
15
- instance.child_id = nil
16
- expect(instance.child).to be_nil
17
- end
18
-
19
- it "should cache an set object" do
20
- instance.child = child
21
- expect(instance.child).to eq(child)
22
- end
23
-
24
- it "should set id on set if it was there" do
25
- instance.child_id = nil
26
- instance.child = child
27
- expect(instance.child_id).to eq(child.id)
28
- end
29
-
30
- it "should build a object set via hash" do
31
- instance.child = {:id => 2}
32
- expect(instance.child.id).to eq(2)
33
- end
34
-
35
- it "should build a object set via id" do
36
- instance.child = 2
37
- expect(instance.child.id).to eq(2)
38
- end
39
-
40
- it "should not fetch an unknown object" do
41
- expect(instance.child).to be_nil
42
- end
43
-
44
- it "should fetch an object known by id" do
45
- stub_json_request(:get, %r{test_resources/1/child/5}, json(:test_child => {:id => 5}))
46
- instance.child_id = 5
47
- expect(instance.child.id).to eq(5)
48
- end
49
-
50
- it "should handle client errors" do
51
- stub_request(:get, %r{test_resources/1/child/5}).to_return(:status => 500)
52
- instance.child_id = 5
53
- expect { silence_logger { instance.child } }.to_not raise_error
54
- end
55
-
56
- it "should handle resource not found errors" do
57
- stub_request(:get, %r{test_resources/1/child/5}).to_return(:status => 404)
58
- instance.child_id = 5
59
- silence_logger{ expect(instance.child).to be_nil }
60
- end
61
-
62
- it "is not used when not used" do
63
- expect(instance.child_used?).to eq(false)
64
- end
65
-
66
- it "is used when used" do
67
- instance.child = child
68
- expect(instance.child_used?).to eq(true)
69
- end
70
- end
71
-
72
- context "has_many" do
73
- it "should cache a set object" do
74
- instance.children = [child]
75
- expect(instance.children.map(&:id)).to eq([1])
76
- expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
77
- end
78
-
79
- it "should set ids" do
80
- instance.children_ids = []
81
- instance.children = [child]
82
- expect(instance.children_ids).to eq([child.id])
83
- expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
84
- end
85
-
86
- it "should build and cache objects set via hash" do
87
- instance.children = [{:id => 2}]
88
- expect(instance.children.map(&:id)).to eq([2])
89
- expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
90
- end
91
-
92
- it "should build a object set via id" do
93
- instance.children = [2]
94
- expect(instance.children.map(&:id)).to eq([2])
95
- expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
96
- end
97
-
98
- it "should fetch unknown objects" do
99
- stub_json_request(:get, %r{test_resources/1/children}, json(:test_children => [{:id => 2}, {:id => 3}]))
100
- expect(instance.children.map(&:id)).to eq([2,3])
101
- expect(instance.children).to be_instance_of(ZendeskAPI::Collection)
102
- end
103
-
104
- it "should not change objects" do
105
- child = 'foo'
106
- children = [child]
107
- instance.children = children
108
- expect(children[0]).to eq('foo')
109
- end
110
-
111
- it "is not used when not used" do
112
- expect(instance.children_used?).to eq(false)
113
- end
114
-
115
- it "is used when used" do
116
- instance.children = [child]
117
- expect(instance.children_used?).to eq(true)
118
- end
119
- end
120
- end
121
-
122
- context "class only" do
123
- subject { described_class.new(:class => ZendeskAPI::TestResource) }
124
-
125
- it "should generate resource path" do
126
- expect(subject.generate_path).to eq("test_resources")
127
- end
128
-
129
- context "with an instance" do
130
- it "should generate a specific resource path" do
131
- expect(subject.generate_path(instance)).to eq("test_resources/1")
132
- end
133
-
134
- context "with_id => false" do
135
- it "should generate general resource path" do
136
- expect(subject.generate_path(instance, :with_id => false)).to eq("test_resources")
137
- end
138
- end
139
-
140
- context "with an instance that is a new record" do
141
- it "should generate general resource path" do
142
- expect(subject.generate_path(ZendeskAPI::TestResource.new(client))).to eq("test_resources")
143
- end
144
- end
145
- end
146
-
147
- context "with a specified path" do
148
- before(:each) { subject.options[:path] = "blergh" }
149
-
150
- it "should generate general resource path" do
151
- expect(subject.generate_path).to eq("blergh")
152
- end
153
- end
154
-
155
- context "with a passed in id" do
156
- it "should generate specific resource path" do
157
- opts = { :id => 1 }
158
- expect(subject.generate_path(opts)).to eq("test_resources/1")
159
- expect(opts).to be_empty
160
- end
161
- end
162
- end
163
-
164
- context "class with a specified parent" do
165
- subject { described_class.new(:class => ZendeskAPI::TestResource::TestChild, :parent => instance, :name => :children) }
166
-
167
- it "should generate nested resource path" do
168
- expect(subject.generate_path).to eq("test_resources/1/children")
169
- end
170
-
171
- context "with an instance" do
172
- it "should generate a specific nested resource path" do
173
- expect(subject.generate_path(child)).to eq("test_resources/1/children/1")
174
- end
175
-
176
- context "with_id => false" do
177
- it "should generate nested resource path" do
178
- expect(subject.generate_path(child, :with_id => false)).to eq("test_resources/1/children")
179
- end
180
- end
181
- end
182
-
183
- context "when parent has a namespace" do
184
- before(:each) do
185
- instance.class.namespace 'hello'
186
- end
187
-
188
- after(:each) do
189
- instance.class.namespace nil
190
- end
191
-
192
- it "should generate a specific nested resource path" do
193
- expect(subject.generate_path(child)).to eq("hello/test_resources/1/children/1")
194
- end
195
- end
196
-
197
- context "with a specified path" do
198
- before(:each) { subject.options[:path] = "blergh" }
199
-
200
- it "should generate nested resource path" do
201
- expect(subject.generate_path).to eq("test_resources/1/blergh")
202
- end
203
- end
204
-
205
- context "with a path on the association" do
206
- before(:each) do
207
- association = ZendeskAPI::TestResource.associations.detect {|a| a[:name] == :children}
208
- association[:path] = "blergh"
209
- end
210
-
211
- it "should generate nested resource path" do
212
- expect(subject.generate_path).to eq("test_resources/1/blergh")
213
- end
214
- end
215
-
216
- context "with no association" do
217
- before(:each) do
218
- ZendeskAPI::TestResource.associations.clear
219
- end
220
-
221
- it "should generate nested resource path" do
222
- expect(subject.generate_path).to eq("test_resources/1/test_children")
223
- end
224
- end
225
- end
226
-
227
- context "class with a parent id" do
228
- subject { described_class.new(:class => ZendeskAPI::TestResource::TestChild, :name => :children) }
229
-
230
- it "should raise an error if not passed an instance or id" do
231
- expect { subject.generate_path }.to raise_error(ArgumentError)
232
- end
233
-
234
- it "should generate specific nested resource path" do
235
- expect(subject.generate_path(child)).to eq("test_resources/2/children/1")
236
- end
237
-
238
- context "with parent id passed in" do
239
- it "should generate nested resource path" do
240
- opts = { :test_resource_id => 3 }
241
- expect(subject.generate_path(opts)).to eq("test_resources/3/children")
242
- expect(opts).to be_empty
243
- end
244
- end
245
- end
246
-
247
- context "with a singular resource" do
248
- subject { described_class.new(:class => ZendeskAPI::SingularTestResource) }
249
-
250
- context "with an instance" do
251
- it "should not generate a specific resource path" do
252
- expect(subject.generate_path(ZendeskAPI::SingularTestResource.new(client, :id => 1))).to eq("singular_test_resources")
253
- end
254
- end
255
- end
256
- end
@@ -1,69 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::DestroyMany do
4
- subject { ZendeskAPI::BulkTestResource }
5
-
6
- context "destroy_many!" do
7
- before(:each) do
8
- stub_json_request(:delete, %r{bulk_test_resources/destroy_many}, json(:job_status => {:id => 'abc'}))
9
- @response = subject.destroy_many!(client, [1,2,3])
10
- end
11
-
12
- it 'calls the destroy_many endpoint' do
13
- assert_requested(:delete, %r{bulk_test_resources/destroy_many\?ids=1,2,3$})
14
- end
15
-
16
- it 'returns a JobStatus' do
17
- expect(@response).to be_instance_of(ZendeskAPI::JobStatus)
18
- expect(@response.id).to eq('abc')
19
- end
20
- end
21
- end
22
-
23
- describe ZendeskAPI::CreateMany do
24
- subject { ZendeskAPI::BulkTestResource }
25
-
26
- context "create_many!" do
27
- let(:attributes) { [{:name => 'A'}, {:name => 'B'}] }
28
-
29
- before(:each) do
30
- stub_json_request(:post, %r{bulk_test_resources/create_many}, json(:job_status => {:id => 'def'}))
31
- @response = subject.create_many!(client, attributes)
32
- end
33
-
34
- it 'calls the create_many endpoint' do
35
- assert_requested(:post, %r{bulk_test_resources/create_many},
36
- :body => json(:bulk_test_resources => attributes)
37
- )
38
- end
39
-
40
- it 'returns a JobStatus' do
41
- expect(@response).to be_instance_of(ZendeskAPI::JobStatus)
42
- expect(@response.id).to eq('def')
43
- end
44
- end
45
-
46
- describe ZendeskAPI::UpdateMany do
47
- subject { ZendeskAPI::BulkTestResource }
48
-
49
- context "update_many!" do
50
- let(:attributes) { {:name => 'A', :age => 25} }
51
-
52
- before(:each) do
53
- stub_json_request(:put, %r{bulk_test_resources/update_many}, json(:job_status => {:id => 'ghi'}))
54
- @response = subject.update_many!(client, [1,2,3], attributes)
55
- end
56
-
57
- it 'calls the update_many endpoint' do
58
- assert_requested(:put, %r{bulk_test_resources/update_many\?ids=1,2,3$},
59
- :body => json(:bulk_test_resource => attributes)
60
- )
61
- end
62
-
63
- it 'returns a JobStatus' do
64
- expect(@response).to be_instance_of(ZendeskAPI::JobStatus)
65
- expect(@response.id).to eq('ghi')
66
- end
67
- end
68
- end
69
- end
@@ -1,280 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- class SimpleClient < ZendeskAPI::Client
4
- def build_connection
5
- "FOO"
6
- end
7
- end
8
-
9
- describe ZendeskAPI::Client do
10
- subject { client }
11
-
12
- context "#initialize" do
13
- it "should require a block" do
14
- expect { ZendeskAPI::Client.new }.to raise_error(ArgumentError)
15
- end
16
-
17
- it "should raise an exception when url isn't ssl" do
18
- expect do
19
- ZendeskAPI::Client.new do |config|
20
- config.url = "http://www.google.com"
21
- end
22
- end.to raise_error(ArgumentError)
23
- end
24
-
25
- it "should not raise an exception when url isn't ssl and allow_http is set to true" do
26
- expect do
27
- ZendeskAPI::Client.new do |config|
28
- config.allow_http = true
29
- config.url = "http://www.google.com/"
30
- end
31
- end.to_not raise_error
32
- end
33
-
34
- it "should handle valid url" do
35
- expect do
36
- ZendeskAPI::Client.new do |config|
37
- config.url = "https://example.zendesk.com/api/v2"
38
- end.to_not raise_error
39
- end
40
- end
41
-
42
- context "basic_auth" do
43
- subject do
44
- ZendeskAPI::Client.new do |config|
45
- config.url = "https://example.zendesk.com/api/v2"
46
- config.username = "hello"
47
- config.password = "token"
48
- end
49
- end
50
-
51
- it "should build basic auth middleware" do
52
- expect(subject.connection.builder.handlers.index(Faraday::Request::BasicAuthentication)).to_not be_nil
53
- end
54
-
55
- it "should not build token middleware" do
56
- expect(subject.connection.headers["Authorization"]).to be_nil
57
- end
58
- end
59
-
60
- context "access token" do
61
- subject do
62
- ZendeskAPI::Client.new do |config|
63
- config.url = "https://example.zendesk.com/api/v2"
64
- config.access_token = "hello"
65
- end
66
- end
67
-
68
- it "should not build basic auth middleware" do
69
- expect(subject.connection.builder.handlers.index(Faraday::Request::BasicAuthentication)).to be_nil
70
- end
71
-
72
- it "should build token middleware" do
73
- expect(subject.connection.headers["Authorization"]).to match(/Bearer/)
74
- end
75
- end
76
-
77
- context "#token" do
78
- let(:client) do
79
- ZendeskAPI::Client.new do |config|
80
- config.url = "https://example.zendesk.com/api/v2"
81
- config.username = username
82
- config.token = "token"
83
- end
84
- end
85
-
86
- subject { client.config }
87
- let(:username) { "hello" }
88
-
89
- context "with a username with /token" do
90
- let(:username) { "hello/token" }
91
-
92
- it "should not add /token to the username" do
93
- expect(subject.username).to eq("hello/token")
94
- end
95
- end
96
-
97
- context "with no password" do
98
- it "should build basic auth middleware" do
99
- expect(client.connection.builder.handlers.index(Faraday::Request::BasicAuthentication)).to_not be_nil
100
- end
101
-
102
- it "should not build token middleware" do
103
- expect(client.connection.builder.handlers.index(Faraday::Request::TokenAuthentication)).to be_nil
104
- end
105
-
106
- it "should copy token to password" do
107
- expect(subject.token).to eq(subject.password)
108
- end
109
-
110
- it "should add /token to the username" do
111
- expect(subject.username).to eq("hello/token")
112
- end
113
- end
114
- end
115
-
116
- context "#logger" do
117
- before(:each) do
118
- @client = ZendeskAPI::Client.new do |config|
119
- config.url = "https://example.zendesk.com/api/v2"
120
- config.logger = subject
121
- end
122
-
123
- stub_request(:get, %r{/bs$}).to_return(:status => 200)
124
- end
125
-
126
- context "with true value" do
127
- subject { true }
128
-
129
- it "should log in faraday" do
130
- expect(@client.connection.builder.handlers).to include(ZendeskAPI::Middleware::Response::Logger)
131
- end
132
-
133
- context "with a request" do
134
- it "should log" do
135
- expect(client.config.logger).to receive(:info).at_least(:once)
136
- @client.connection.get('/bs')
137
- end
138
- end
139
- end
140
-
141
- context "with false value" do
142
- subject { false }
143
-
144
- it "should not log" do
145
- expect(@client.connection.builder.handlers).to_not include(ZendeskAPI::Middleware::Response::Logger)
146
- end
147
- end
148
-
149
- context "with a nil value" do
150
- subject { nil }
151
-
152
- it "should log" do
153
- expect(@client.connection.builder.handlers).to include(ZendeskAPI::Middleware::Response::Logger)
154
- end
155
- end
156
-
157
- context "with a logger" do
158
- let(:out){ StringIO.new }
159
- subject { Logger.new(out) }
160
-
161
- it "should log" do
162
- expect(@client.connection.builder.handlers).to include(ZendeskAPI::Middleware::Response::Logger)
163
- end
164
-
165
- context "with a request" do
166
- it "should log to the subject" do
167
- expect(out).to receive(:write).at_least(:once)
168
- @client.connection.get('/bs')
169
- end
170
- end
171
- end
172
- end
173
- end
174
-
175
- context "#current_user" do
176
- before(:each) do
177
- stub_json_request(:get, %r{users/me}, json("user" => {}))
178
- end
179
-
180
- it "should be a user instance" do
181
- expect(client.current_user).to be_instance_of(ZendeskAPI::User)
182
- end
183
- end
184
-
185
- context "#connection" do
186
- it "should initially be false" do
187
- expect(subject.instance_variable_get(:@connection)).to be_falsey
188
- end
189
-
190
- it "connection should be initialized on first call to #connection" do
191
- expect(subject.connection).to be_instance_of(Faraday::Connection)
192
- end
193
- end
194
-
195
- context "resources" do
196
- it "should return an instance of ZendeskAPI::Collection if there is no method" do
197
- expect(subject.instance_variable_get(:@resource_cache)["tickets"]).to be_nil
198
-
199
- expect(subject.tickets).to be_instance_of(ZendeskAPI::Collection)
200
-
201
- expect(subject.instance_variable_get(:@resource_cache)["tickets"]).to_not be_empty
202
- expect(subject.instance_variable_get(:@resource_cache)["tickets"][:class]).to eq(ZendeskAPI::Ticket)
203
- expect(subject.instance_variable_get(:@resource_cache)["tickets"][:cache]).to be_instance_of(ZendeskAPI::LRUCache)
204
-
205
- expect(ZendeskAPI).to_not receive(:const_get)
206
- expect(subject.tickets).to be_instance_of(ZendeskAPI::Collection)
207
- end
208
-
209
- it "should not cache calls with different options" do
210
- expect(subject.search(:query => 'abc')).to_not eq(subject.search(:query => '123'))
211
- end
212
-
213
- it "should not cache calls with :reload => true options" do
214
- expect(subject.search(:query => 'abc')).to_not eq(subject.search(:query => 'abc', :reload => true))
215
- end
216
-
217
- it "should not pass reload to the underlying collection" do
218
- collection = subject.search(:query => 'abc', :reload => true)
219
- expect(collection.options.key?(:reload)).to be(false)
220
- end
221
-
222
- it "should cache calls with the same options" do
223
- expect(subject.search(:query => 'abc')).to eq(subject.search(:query => 'abc'))
224
- end
225
-
226
- it "should respond_to? for valid resources" do
227
- expect(subject.respond_to?(:tickets)).to eq(true)
228
- end
229
-
230
- it "should respond_to? for valid cached resources" do
231
- subject.tickets
232
-
233
- expect(subject.respond_to?(:tickets)).to eq(true)
234
- end
235
-
236
- it "should respond_to? for actual instance methods" do
237
- expect(subject.respond_to?(:set_default_logger, true)).to eq(true)
238
- expect(subject.respond_to?(:set_default_logger)).to eq(false)
239
- end
240
-
241
- it "should not respond_to? invalid resources" do
242
- expect(subject.respond_to?(:nope)).to eq(false)
243
- end
244
-
245
- it "delegates voice correctly" do
246
- expect(subject.voice.greetings).to be_instance_of(ZendeskAPI::Collection)
247
- end
248
-
249
- it "looks in the appropriate namespaces" do
250
- expect(subject.greetings.association.options['class']).to eq(ZendeskAPI::Voice::Greeting)
251
- end
252
-
253
- it 'raises if the resource does not exist' do
254
- expect { subject.random_resource }.to raise_error(RuntimeError)
255
- end
256
- end
257
-
258
- it "can be subclassed" do
259
- client = SimpleClient.new do |config|
260
- config.allow_http = true
261
- end
262
- expect(client.config.allow_http).to eq(true)
263
- expect(client.connection).to eq("FOO")
264
- expect(client.connection.object_id).to eq(client.connection.object_id) # it's cached
265
- end
266
-
267
- context ZendeskAPI::Voice do
268
- it "defers to voice delegator" do
269
- expect(subject).to receive(:phone_numbers).once
270
- subject.voice.phone_numbers
271
- end
272
-
273
- it "manages namespace correctly" do
274
- expect(client.addresses.path).to match(/channels\/voice\/addresses/)
275
- expect(client.phone_numbers.path).to match(/channels\/voice\/phone_numbers/)
276
- expect(client.greetings.path).to match(/channels\/voice\/greetings/)
277
- expect(client.greeting_categories.path).to match(/channels\/voice\/greeting_categories/)
278
- end
279
- end
280
- end