hipchat 1.0.1 → 1.1.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.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/README.textile +25 -1
- data/lib/hipchat.rb +4 -206
- data/lib/hipchat/api_version.rb +80 -14
- data/lib/hipchat/capistrano2.rb +41 -1
- data/lib/hipchat/client.rb +111 -0
- data/lib/hipchat/errors.rb +10 -0
- data/lib/hipchat/rails3_tasks.rb +2 -1
- data/lib/hipchat/room.rb +193 -0
- data/lib/hipchat/user.rb +62 -0
- data/lib/hipchat/version.rb +1 -1
- data/spec/hipchat_api_v1_spec.rb +172 -0
- data/spec/hipchat_api_v2_spec.rb +217 -0
- data/spec/hipchat_spec.rb +0 -271
- data/spec/spec_helper.rb +3 -0
- data/spec/{shared_hipchat.rb → support/shared_contexts_for_hipchat.rb} +58 -7
- metadata +15 -6
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,12 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
require 'hipchat'
|
4
4
|
require 'rspec'
|
5
5
|
require 'rspec/autorun'
|
6
|
+
require 'json'
|
6
7
|
require 'webmock/rspec'
|
7
8
|
require 'coveralls'
|
8
9
|
|
10
|
+
Dir["./spec/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
9
12
|
Coveralls.wear!
|
10
13
|
|
11
14
|
RSpec.configure do |config|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
HISTORY_JSON_PATH = File.expand_path(File.dirname(__FILE__) + '/../example/history.json')
|
2
|
+
|
1
3
|
shared_context "HipChatV1" do
|
2
4
|
before { @api_version = 'v1'}
|
3
5
|
# Helper for mocking room message post requests
|
@@ -29,15 +31,25 @@ shared_context "HipChatV1" do
|
|
29
31
|
|
30
32
|
def mock_successful_history(options={})
|
31
33
|
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
|
32
|
-
canned_response = File.new
|
34
|
+
canned_response = File.new(HISTORY_JSON_PATH)
|
33
35
|
stub_request(:get, "https://api.hipchat.com/v1/rooms/history").with(:query => {:auth_token => "blah",
|
34
36
|
:room_id => "Hipchat",
|
35
37
|
:date => options[:date],
|
36
38
|
:timezone => options[:timezone],
|
37
39
|
:format => options[:format]}).to_return(canned_response)
|
38
40
|
end
|
39
|
-
|
40
|
-
|
41
|
+
|
42
|
+
def mock_successful_room_creation(name, options={})
|
43
|
+
options = {:name => "A Room"}.merge(options)
|
44
|
+
stub_request(:post, "https://api.hipchat.com/v1/rooms/create").with(
|
45
|
+
:query => {:auth_token => "blah"},
|
46
|
+
:body => { :name => name }.merge(options),
|
47
|
+
:headers => {'Accept' => 'application/json',
|
48
|
+
'Content-Type' => 'application/x-www-form-urlencoded'}).to_return(
|
49
|
+
:status => 200,
|
50
|
+
:body => '{"room": {"room_id": "1234", "name" : "A Room"}}',
|
51
|
+
:headers => {})
|
52
|
+
end
|
41
53
|
end
|
42
54
|
|
43
55
|
shared_context "HipChatV2" do
|
@@ -54,7 +66,7 @@ shared_context "HipChatV2" do
|
|
54
66
|
:color => options[:color],
|
55
67
|
:notify => options[:notify]}.to_json,
|
56
68
|
:headers => {'Accept' => 'application/json',
|
57
|
-
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
69
|
+
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
58
70
|
end
|
59
71
|
|
60
72
|
def mock_successful_topic_change(topic, options={})
|
@@ -70,13 +82,52 @@ shared_context "HipChatV2" do
|
|
70
82
|
|
71
83
|
def mock_successful_history(options={})
|
72
84
|
options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON' }.merge(options)
|
73
|
-
canned_response = File.new
|
85
|
+
canned_response = File.new(HISTORY_JSON_PATH)
|
74
86
|
stub_request(:get, "https://api.hipchat.com/v2/room/Hipchat/history").with(:query => {:auth_token => "blah",
|
75
87
|
:room_id => "Hipchat",
|
76
88
|
:date => options[:date],
|
77
89
|
:timezone => options[:timezone],
|
78
90
|
:format => options[:format]}).to_return(canned_response)
|
79
91
|
end
|
80
|
-
|
81
|
-
|
92
|
+
|
93
|
+
def mock_successful_room_creation(name, options={})
|
94
|
+
stub_request(:post, "https://api.hipchat.com/v2/room").with(
|
95
|
+
:query => {:auth_token => "blah"},
|
96
|
+
:body => { :name => name }.merge(options).to_json,
|
97
|
+
:headers => {'Accept' => 'application/json',
|
98
|
+
'Content-Type' => 'application/json'}).to_return(
|
99
|
+
:status => 201,
|
100
|
+
:body => '{"id": "12345", "links": {"self": "https://api.hipchat.com/v2/room/12345"}}',
|
101
|
+
:headers => {})
|
102
|
+
end
|
103
|
+
|
104
|
+
def mock_successful_get_room(room_id="1234")
|
105
|
+
stub_request(:get, "https://api.hipchat.com/v2/room/#{room_id}").with(
|
106
|
+
:query => {:auth_token => "blah"},
|
107
|
+
:body => "",
|
108
|
+
:headers => {'Accept' => 'application/json',
|
109
|
+
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "{\"id\":\"#{room_id}\"}", :headers => {})
|
110
|
+
end
|
111
|
+
|
112
|
+
def mock_successful_invite(options={})
|
113
|
+
options = {:user_id => "1234"}.merge(options)
|
114
|
+
stub_request(:post, "https://api.hipchat.com/v2/room/Hipchat/invite/#{options[:user_id]}").with(
|
115
|
+
:query => {:auth_token => "blah"},
|
116
|
+
:body => {
|
117
|
+
:reason => options[:reason]||""
|
118
|
+
}.to_json,
|
119
|
+
:headers => {'Accept' => 'application/json',
|
120
|
+
'Content-Type' => 'application/json'}).to_return(
|
121
|
+
:status => 204,
|
122
|
+
:body => "",
|
123
|
+
:headers => {})
|
124
|
+
end
|
125
|
+
|
126
|
+
def mock_successful_user_send(message)
|
127
|
+
stub_request(:post, "https://api.hipchat.com/v2/user/12345678/message").with(
|
128
|
+
:query => {:auth_token => "blah"},
|
129
|
+
:body => {:message => "Equal bytes for everyone"},
|
130
|
+
:headers => {'Accept' => 'application/json',
|
131
|
+
'Content-Type' => 'application/json'}).to_return(:status => 200, :body => "", :headers => {})
|
132
|
+
end
|
82
133
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HipChat/Atlassian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -131,6 +131,8 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".document"
|
133
133
|
- ".gitignore"
|
134
|
+
- ".ruby-gemset"
|
135
|
+
- ".ruby-version"
|
134
136
|
- ".travis.yml"
|
135
137
|
- Gemfile
|
136
138
|
- LICENSE
|
@@ -143,14 +145,20 @@ files:
|
|
143
145
|
- lib/hipchat/capistrano/tasks/hipchat.rake
|
144
146
|
- lib/hipchat/capistrano2.rb
|
145
147
|
- lib/hipchat/chef.rb
|
148
|
+
- lib/hipchat/client.rb
|
149
|
+
- lib/hipchat/errors.rb
|
146
150
|
- lib/hipchat/rails3_tasks.rb
|
147
151
|
- lib/hipchat/railtie.rb
|
152
|
+
- lib/hipchat/room.rb
|
153
|
+
- lib/hipchat/user.rb
|
148
154
|
- lib/hipchat/version.rb
|
149
155
|
- spec/example/history.json
|
156
|
+
- spec/hipchat_api_v1_spec.rb
|
157
|
+
- spec/hipchat_api_v2_spec.rb
|
150
158
|
- spec/hipchat_spec.rb
|
151
|
-
- spec/shared_hipchat.rb
|
152
159
|
- spec/spec.opts
|
153
160
|
- spec/spec_helper.rb
|
161
|
+
- spec/support/shared_contexts_for_hipchat.rb
|
154
162
|
homepage: https://github.com/hipchat/hipchat-rb
|
155
163
|
licenses:
|
156
164
|
- MIT
|
@@ -171,14 +179,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
179
|
version: '0'
|
172
180
|
requirements: []
|
173
181
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.2.1
|
175
183
|
signing_key:
|
176
184
|
specification_version: 4
|
177
185
|
summary: Ruby library to interact with HipChat
|
178
186
|
test_files:
|
179
187
|
- spec/example/history.json
|
188
|
+
- spec/hipchat_api_v1_spec.rb
|
189
|
+
- spec/hipchat_api_v2_spec.rb
|
180
190
|
- spec/hipchat_spec.rb
|
181
|
-
- spec/shared_hipchat.rb
|
182
191
|
- spec/spec.opts
|
183
192
|
- spec/spec_helper.rb
|
184
|
-
|
193
|
+
- spec/support/shared_contexts_for_hipchat.rb
|