yam 0.0.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.travis.yml +5 -0
  3. data/.yardopts +10 -0
  4. data/AUTHORS +1 -0
  5. data/CHANGELOG.md +7 -0
  6. data/CONTRIBUTING.md +0 -7
  7. data/Gemfile +27 -1
  8. data/README.md +190 -67
  9. data/Rakefile +9 -3
  10. data/certs/public.pem +20 -0
  11. data/lib/yammer.rb +47 -0
  12. data/lib/yammer/api.rb +29 -0
  13. data/lib/yammer/api/autocomplete.rb +39 -0
  14. data/lib/yammer/api/group.rb +92 -0
  15. data/lib/yammer/api/group_membership.rb +46 -0
  16. data/lib/yammer/api/invitation.rb +39 -0
  17. data/lib/yammer/api/like.rb +57 -0
  18. data/lib/yammer/api/message.rb +227 -0
  19. data/lib/yammer/api/network.rb +35 -0
  20. data/lib/yammer/api/notification.rb +32 -0
  21. data/lib/yammer/api/open_graph_object.rb +92 -0
  22. data/lib/yammer/api/pending_attachment.rb +64 -0
  23. data/lib/yammer/api/search.rb +42 -0
  24. data/lib/yammer/api/subscription.rb +32 -0
  25. data/lib/yammer/api/thread.rb +37 -0
  26. data/lib/yammer/api/topic.rb +37 -0
  27. data/lib/yammer/api/user.rb +168 -0
  28. data/lib/yammer/api_handler.rb +27 -0
  29. data/lib/yammer/api_response.rb +57 -0
  30. data/lib/yammer/base.rb +208 -0
  31. data/lib/yammer/client.rb +100 -0
  32. data/lib/yammer/configurable.rb +81 -0
  33. data/lib/yammer/error.rb +75 -0
  34. data/lib/yammer/group.rb +27 -0
  35. data/lib/yammer/group_membership.rb +25 -0
  36. data/lib/yammer/http_adapter.rb +100 -0
  37. data/lib/yammer/identity_map.rb +56 -0
  38. data/lib/yammer/message.rb +32 -0
  39. data/lib/yammer/message_body.rb +27 -0
  40. data/lib/yammer/pending_attachment.rb +19 -0
  41. data/lib/yammer/thread.rb +58 -0
  42. data/lib/yammer/user.rb +66 -0
  43. data/lib/yammer/version.rb +32 -0
  44. data/{lib/yam/configuration.rb → spec/api/autocomplete_spec.rb} +18 -23
  45. data/spec/api/group_membership_spec.rb +48 -0
  46. data/spec/api/group_spec.rb +76 -0
  47. data/spec/api/invitation_spec.rb +60 -0
  48. data/spec/api/like_spec.rb +46 -0
  49. data/spec/api/message_spec.rb +136 -0
  50. data/spec/api/network_spec.rb +41 -0
  51. data/{lib/yam/client.rb → spec/api/notification_spec.rb} +22 -4
  52. data/spec/api/open_graph_object_spec.rb +67 -0
  53. data/spec/api/pending_attachment_spec.rb +56 -0
  54. data/{lib/yam/constants.rb → spec/api/search_spec.rb} +21 -8
  55. data/spec/api/subscription_spec.rb +41 -0
  56. data/{lib/yam.rb → spec/api/thread_spec.rb} +19 -12
  57. data/{lib/yam/request.rb → spec/api/topic_spec.rb} +19 -15
  58. data/spec/api/user_spec.rb +108 -0
  59. data/spec/api_response.rb +86 -0
  60. data/spec/client_spec.rb +364 -0
  61. data/spec/error_spec.rb +88 -0
  62. data/spec/fixtures/group.json +1 -0
  63. data/spec/fixtures/message.json +1 -0
  64. data/spec/fixtures/messages_in_thread.json +1 -0
  65. data/spec/fixtures/portal_thread.json +1 -0
  66. data/spec/fixtures/private_thread.json +1 -0
  67. data/spec/fixtures/public_thread.json +1 -0
  68. data/spec/fixtures/user.json +1 -0
  69. data/spec/fixtures/users_followed.json +1 -0
  70. data/spec/fixtures/users_following.json +1 -0
  71. data/spec/http_adapter_spec.rb +109 -0
  72. data/spec/identity_map_spec.rb +127 -0
  73. data/spec/mocks/attachment.txt +1 -0
  74. data/spec/model/base_spec.rb +196 -0
  75. data/spec/model/group_membership_spec.rb +57 -0
  76. data/spec/model/group_spec.rb +73 -0
  77. data/spec/model/message_spec.rb +74 -0
  78. data/spec/model/thread_spec.rb +91 -0
  79. data/spec/model/user_spec.rb +222 -0
  80. data/spec/spec_helper.rb +39 -14
  81. data/yam.gemspec +50 -28
  82. metadata +270 -187
  83. metadata.gz.sig +0 -0
  84. data/lib/yam/api.rb +0 -53
  85. data/lib/yam/connection.rb +0 -57
  86. data/lib/yam/version.rb +0 -20
  87. data/spec/yam/client_spec.rb +0 -50
  88. data/spec/yam_spec.rb +0 -87
@@ -0,0 +1,57 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+
22
+ describe Yammer::GroupMembership do
23
+
24
+ before :all do
25
+ Yammer.configure do |conf|
26
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
27
+ end
28
+ end
29
+
30
+ after :all do
31
+ Yammer.reset!
32
+ end
33
+
34
+ context 'class methods' do
35
+
36
+ subject { Yammer::GroupMembership }
37
+
38
+ describe '#create_group_membership' do
39
+ it 'creates a new group membership' do
40
+ stub_request(:post, "https://www.yammer.com/api/v1/group_memberships").with(
41
+ :body => { :group_id => '6' },
42
+ :headers => {
43
+ 'Accept' => 'application/json',
44
+ 'Authorization' => "Bearer #{Yammer.access_token}",
45
+ 'Content-Type' => 'application/x-www-form-urlencoded',
46
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
47
+ }
48
+ ).to_return(
49
+ :status => 201,
50
+ :body => '',
51
+ :headers => {}
52
+ )
53
+ subject.create(6)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,73 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+
22
+ describe Yammer::Group do
23
+ context 'class methods' do
24
+
25
+ before :all do
26
+ Yammer.configure do |conf|
27
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
28
+ end
29
+ end
30
+
31
+ after :all do
32
+ Yammer.reset!
33
+ end
34
+
35
+ subject { Yammer::Group }
36
+
37
+ describe '#create' do
38
+ it 'creates a new group' do
39
+ stub_request(:post, "https://www.yammer.com/api/v1/groups").with(
40
+ :body => { :name => 'rails team', :privacy => 'public' },
41
+ :headers => {
42
+ 'Accept' => 'application/json',
43
+ 'Authorization' => "Bearer #{Yammer.access_token}",
44
+ 'Content-Type' => 'application/x-www-form-urlencoded',
45
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
46
+ }
47
+ ).to_return(
48
+ :status => 201,
49
+ :body => '',
50
+ :headers => {'Location' => 'https://www.yammer.com/api/v1/groups/2'}
51
+ )
52
+ subject.create(:name => 'rails team', :privacy => 'public')
53
+ end
54
+ end
55
+
56
+ describe '#get' do
57
+ it 'returns group response' do
58
+ stub_request(:get, "https://www.yammer.com/api/v1/groups/1").with(
59
+ :headers => {
60
+ 'Accept' => 'application/json',
61
+ 'Authorization' => "Bearer #{Yammer.access_token}",
62
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
63
+ }
64
+ ).to_return(
65
+ :status => 200,
66
+ :body => fixture('group.json'),
67
+ :headers => {}
68
+ )
69
+ subject.get(1)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,74 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+
22
+ describe Yammer::Message do
23
+
24
+ before :all do
25
+ Yammer.configure do |conf|
26
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
27
+ end
28
+ end
29
+
30
+ after :all do
31
+ Yammer.reset!
32
+ end
33
+
34
+ context 'class methods' do
35
+
36
+ subject { Yammer::Message }
37
+
38
+ describe '#create' do
39
+ it 'creates a new group' do
40
+ stub_request(:post, "https://www.yammer.com/api/v1/messages").with(
41
+ :body => { :body => 'python not ruby', :privacy => 'public' },
42
+ :headers => {
43
+ 'Accept' => 'application/json',
44
+ 'Authorization' => "Bearer #{Yammer.access_token}",
45
+ 'Content-Type' => 'application/x-www-form-urlencoded',
46
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
47
+ }
48
+ ).to_return(
49
+ :status => 201,
50
+ :body => '',
51
+ :headers => {'Location' => 'https://www.yammer.com/api/v1/messages/2'}
52
+ )
53
+ subject.create('python not ruby', :privacy => 'public')
54
+ end
55
+ end
56
+
57
+ describe '#get' do
58
+ it 'returns message response' do
59
+ stub_request(:get, "https://www.yammer.com/api/v1/messages/1").with(
60
+ :headers => {
61
+ 'Accept' => 'application/json',
62
+ 'Authorization' => "Bearer #{Yammer.access_token}",
63
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
64
+ }
65
+ ).to_return(
66
+ :status => 200,
67
+ :body => fixture('message.json'),
68
+ :headers => {}
69
+ )
70
+ subject.get(1)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,91 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+
22
+ describe Yammer::Thread do
23
+
24
+ before :all do
25
+ Yammer.configure do |conf|
26
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
27
+ end
28
+ end
29
+
30
+ after :all do
31
+ Yammer.reset!
32
+ end
33
+
34
+ subject { Yammer::GroupMembership }
35
+
36
+ context 'existing public thread' do
37
+ subject { Yammer::Thread.new(MultiJson.load(fixture("public_thread.json"), :symbolize_keys => true)) }
38
+
39
+ describe "#id" do
40
+ it 'returns id' do
41
+ expect(subject.id).to eq 11
42
+ end
43
+ end
44
+
45
+ describe "#first_reply" do
46
+ it 'returns first_reply' do
47
+ expect(subject.first_reply).to be_instance_of(Yammer::Message)
48
+ expect(subject.first_reply.id).to eq 11
49
+ end
50
+ end
51
+
52
+ describe "#last_reply" do
53
+ it 'returns last_reply' do
54
+ expect(subject.last_reply).to be_instance_of(Yammer::Message)
55
+ expect(subject.last_reply.id).to eq 13
56
+ end
57
+ end
58
+
59
+ describe "messages" do
60
+ it 'makes an http request and hydrates object' do
61
+ stub_request(:get, "https://www.yammer.com/api/v1/messages/in_thread/11").with(
62
+ :headers => {
63
+ 'Accept' => 'application/json',
64
+ 'Authorization' => "Bearer #{Yammer.access_token}",
65
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
66
+ }
67
+ ).to_return(
68
+ :status => 200,
69
+ :body => fixture("messages_in_thread.json"),
70
+ :headers => {:content_type => "application/json; charset=utf-8"}
71
+ )
72
+
73
+ stub_request(:get, "https://www.yammer.com/api/v1/messages/in_thread/11").
74
+ with(:headers => {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer', 'User-Agent'=>'Yammer Ruby Gem 0.1.5'}).
75
+ to_return(:status => 200, :body => "", :headers => {})
76
+ subject.messages
77
+ end
78
+ end
79
+ end
80
+
81
+ context 'existing private thread' do
82
+ subject { Yammer::Thread.new(MultiJson.load(fixture("private_thread.json"), :symbolize_keys => true)) }
83
+ describe "people" do
84
+ it 'makes an http request and hydrates object' do
85
+ subject.people.each do |person|
86
+ expect(person).to be_instance_of(Yammer::User)
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,222 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright (c) Microsoft Corporation
4
+ # All rights reserved.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13
+ # ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
14
+ # IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
15
+ # PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
16
+ #
17
+ # See the Apache Version 2.0 License for specific language governing
18
+ # permissions and limitations under the License.
19
+
20
+ require File.expand_path('../../spec_helper', __FILE__)
21
+
22
+ describe Yammer::User do
23
+
24
+ before :all do
25
+ Yammer.configure do |conf|
26
+ conf.access_token = 'TolNOFka9Uls2DxahNi78A'
27
+ end
28
+ end
29
+
30
+ after :all do
31
+ Yammer.reset!
32
+ end
33
+
34
+ context 'class methods' do
35
+
36
+ subject { Yammer::User }
37
+
38
+ describe '#create' do
39
+ it 'creates a new user' do
40
+ stub_request(:post, "https://www.yammer.com/api/v1/users").with(
41
+ :body => { :email => 'hacker@yammer-inc.com' },
42
+ :headers => {
43
+ 'Accept' => 'application/json',
44
+ 'Authorization' => "Bearer #{Yammer.access_token}",
45
+ 'Content-Type' => 'application/x-www-form-urlencoded',
46
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
47
+ }
48
+ ).to_return(
49
+ :status => 201,
50
+ :body => '',
51
+ :headers => { 'Location' => 'https://www.yammer.com/api/v1/users/364'}
52
+ )
53
+ subject.create('hacker@yammer-inc.com')
54
+ end
55
+ end
56
+
57
+ describe '#current' do
58
+ it "should fetch authenticated user's data" do
59
+ stub_request(:get, "https://www.yammer.com/api/v1/users/current").with(
60
+ :headers => {
61
+ 'Accept' => 'application/json',
62
+ 'Authorization' => "Bearer #{Yammer.access_token}",
63
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
64
+ }
65
+ ).to_return(
66
+ :status => 200,
67
+ :body => fixture('user.json'),
68
+ :headers => {}
69
+ )
70
+ subject.current
71
+ end
72
+ end
73
+ end
74
+
75
+ context 'new user object with id' do
76
+
77
+ before :each do
78
+ Yammer::User.identity_map.purge!
79
+ end
80
+
81
+ subject { Yammer::User.new(:id => 1) }
82
+
83
+ describe "#id" do
84
+ it 'returns id' do
85
+ expect(subject.id).to eq 1
86
+ end
87
+ end
88
+
89
+ describe "calling getter method" do
90
+ it 'makes an http request and hydrates object' do
91
+ stub_request(:get, "https://www.yammer.com/api/v1/users/1").with(
92
+ :headers => {
93
+ 'Accept' => 'application/json',
94
+ 'Authorization' => "Bearer #{Yammer.access_token}",
95
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
96
+ }
97
+ ).to_return(
98
+ :status => 200,
99
+ :body => fixture('user.json'),
100
+ :headers => {}
101
+ )
102
+ subject.full_name
103
+ end
104
+ end
105
+
106
+ describe "creating duplicate object" do
107
+ it 'retrieves data from identitymap' do
108
+ user = Yammer::User.new(:id => 1)
109
+ stub_request(:get, "https://www.yammer.com/api/v1/users/1").with(
110
+ :headers => {
111
+ 'Accept' => 'application/json',
112
+ 'Authorization' => "Bearer #{Yammer.access_token}",
113
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
114
+ }
115
+ ).to_return(
116
+ :status => 200,
117
+ :body => fixture('user.json'),
118
+ :headers => {}
119
+ )
120
+ expect(user.full_name).to eq 'John Smith'
121
+
122
+ duplicate = Yammer::User.new(:id => 1)
123
+ expect(duplicate.full_name).to eq 'John Smith'
124
+ end
125
+ end
126
+ end
127
+
128
+ context 'hydrated user object' do
129
+ subject { Yammer::User.new(MultiJson.load(fixture('user.json'), :symbolize_keys => true)) }
130
+
131
+ describe "#id" do
132
+ it 'returns id' do
133
+ expect(subject.id).to eq 2
134
+ end
135
+ end
136
+
137
+ describe "#email" do
138
+ it 'returns email addresses' do
139
+ stub_request(:get, "https://www.yammer.com/api/v1/users/2").
140
+ with(:headers => {
141
+ 'Accept'=>'application/json',
142
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
143
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
144
+ }).to_return(
145
+ :status => 200,
146
+ :body => fixture('user.json'),
147
+ :headers => {}
148
+ )
149
+ expect(subject.email).to eq 'jsmith@yammer-inc.com'
150
+ end
151
+ end
152
+
153
+ describe "#followers" do
154
+ it 'returns users following user' do
155
+ stub_request(:get, "https://www.yammer.com/api/v1/users/following/2").
156
+ with(:headers => {
157
+ 'Accept'=>'application/json',
158
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
159
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
160
+ }).to_return(
161
+ :status => 200,
162
+ :body => fixture('users_following.json'),
163
+ :headers => {}
164
+ )
165
+ subject.followers
166
+ end
167
+ end
168
+
169
+ describe "#following" do
170
+ it 'returns users followed by user' do
171
+ stub_request(:get, "https://www.yammer.com/api/v1/users/followed_by/2").
172
+ with(:headers => {
173
+ 'Accept'=>'application/json',
174
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
175
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
176
+ }).to_return(
177
+ :status => 200,
178
+ :body => fixture('users_followed.json'),
179
+ :headers => {}
180
+ )
181
+ subject.following
182
+ end
183
+ end
184
+
185
+ describe "#delete" do
186
+ it 'deletes user' do
187
+ stub_request(:delete, "https://www.yammer.com/api/v1/users/2").
188
+ with(:headers => {
189
+ 'Accept'=>'application/json',
190
+ 'Authorization'=>"Bearer #{Yammer.access_token}",
191
+ 'User-Agent'=>"Yammer Ruby Gem #{Yammer::Version}"
192
+ }).to_return(
193
+ :status => 200,
194
+ :body => '',
195
+ :headers => {}
196
+ )
197
+ subject.delete!
198
+ end
199
+ end
200
+
201
+ describe '#update' do
202
+ context 'with id as an integer' do
203
+ it 'updates user' do
204
+ stub_request(:put, "https://www.yammer.com/api/v1/users/2").with(
205
+ :body => { :last_name => 'tiabas' },
206
+ :headers => {
207
+ 'Accept' => 'application/json',
208
+ 'Authorization' => "Bearer #{Yammer.access_token}",
209
+ 'Content-Type' => 'application/x-www-form-urlencoded',
210
+ 'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
211
+ }
212
+ ).to_return(
213
+ :status => 200,
214
+ :body => '',
215
+ :headers => { 'Location' => 'https://www.yammer.com/api/v1/users/2'}
216
+ )
217
+ subject.update!(:last_name => 'tiabas')
218
+ end
219
+ end
220
+ end
221
+ end
222
+ end