pusher 0.4.0.beta.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/pusher.gemspec +3 -3
- data/spec/pusher_spec.rb +25 -11
- metadata +6 -10
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.0
|
1
|
+
0.4.0
|
data/pusher.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pusher}
|
8
|
-
s.version = "0.4.0
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["New Bamboo"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-27}
|
13
13
|
s.description = %q{Wrapper for pusherapp.com REST api}
|
14
14
|
s.email = %q{support@pusherapp.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/pusher_spec.rb
CHANGED
@@ -60,7 +60,9 @@ describe Pusher do
|
|
60
60
|
|
61
61
|
describe 'Channel#trigger!' do
|
62
62
|
before :each do
|
63
|
-
WebMock.stub_request(
|
63
|
+
WebMock.stub_request(
|
64
|
+
:post, %r{/apps/20/channels/test_channel/events}
|
65
|
+
).to_return(:status => 202)
|
64
66
|
@channel = Pusher['test_channel']
|
65
67
|
end
|
66
68
|
|
@@ -74,7 +76,7 @@ describe Pusher do
|
|
74
76
|
:name => 'Pusher',
|
75
77
|
:last_name => 'App'
|
76
78
|
})
|
77
|
-
WebMock.request(:post, %r{/
|
79
|
+
WebMock.request(:post, %r{/apps/20/channels/test_channel/events}).
|
78
80
|
with do |req|
|
79
81
|
|
80
82
|
query_hash = req.uri.query_values
|
@@ -95,7 +97,7 @@ describe Pusher do
|
|
95
97
|
it "should handle string data by sending unmodified in body" do
|
96
98
|
string = "foo\nbar\""
|
97
99
|
@channel.trigger!('new_event', string)
|
98
|
-
WebMock.request(:post, %r{/
|
100
|
+
WebMock.request(:post, %r{/apps/20/channels/test_channel/events}).with do |req|
|
99
101
|
req.body.should == "foo\nbar\""
|
100
102
|
end.should have_been_made
|
101
103
|
end
|
@@ -107,32 +109,37 @@ describe Pusher do
|
|
107
109
|
end
|
108
110
|
|
109
111
|
it "should propagate exception if exception raised" do
|
110
|
-
WebMock.stub_request(
|
111
|
-
|
112
|
+
WebMock.stub_request(
|
113
|
+
:post, %r{/apps/20/channels/test_channel/events}
|
114
|
+
).to_raise(RuntimeError)
|
112
115
|
lambda {
|
113
116
|
Pusher['test_channel'].trigger!('new_event', 'Some data')
|
114
117
|
}.should raise_error(RuntimeError)
|
115
118
|
end
|
116
119
|
|
117
120
|
it "should raise AuthenticationError if pusher returns 401" do
|
118
|
-
WebMock.stub_request(
|
119
|
-
|
121
|
+
WebMock.stub_request(
|
122
|
+
:post,
|
123
|
+
%r{/apps/20/channels/test_channel/events}
|
124
|
+
).to_return(:status => 401)
|
120
125
|
lambda {
|
121
126
|
Pusher['test_channel'].trigger!('new_event', 'Some data')
|
122
127
|
}.should raise_error(Pusher::AuthenticationError)
|
123
128
|
end
|
124
129
|
|
125
130
|
it "should raise Pusher::Error if pusher returns 404" do
|
126
|
-
WebMock.stub_request(
|
127
|
-
|
131
|
+
WebMock.stub_request(
|
132
|
+
:post, %r{/apps/20/channels/test_channel/events}
|
133
|
+
).to_return(:status => 404)
|
128
134
|
lambda {
|
129
135
|
Pusher['test_channel'].trigger!('new_event', 'Some data')
|
130
136
|
}.should raise_error(Pusher::Error, 'Resource not found: app_id is probably invalid')
|
131
137
|
end
|
132
138
|
|
133
139
|
it "should raise Pusher::Error if pusher returns 500" do
|
134
|
-
WebMock.stub_request(
|
135
|
-
|
140
|
+
WebMock.stub_request(
|
141
|
+
:post, %r{/apps/20/channels/test_channel/events}
|
142
|
+
).to_return(:status => 500, :body => "some error")
|
136
143
|
lambda {
|
137
144
|
Pusher['test_channel'].trigger!('new_event', 'Some data')
|
138
145
|
}.should raise_error(Pusher::Error, 'Unknown error in Pusher: some error')
|
@@ -151,6 +158,13 @@ describe Pusher do
|
|
151
158
|
Pusher.logger.should_receive(:debug) #backtrace
|
152
159
|
Pusher['test_channel'].trigger('new_event', 'Some data')
|
153
160
|
end
|
161
|
+
|
162
|
+
it "should log failure if exception raised" do
|
163
|
+
@http.should_receive(:post).and_raise("Fail")
|
164
|
+
Pusher.logger.should_receive(:error).with("Fail (RuntimeError)")
|
165
|
+
Pusher.logger.should_receive(:debug) #backtrace
|
166
|
+
Pusher['test_channel'].trigger('new_event', 'Some data')
|
167
|
+
end
|
154
168
|
end
|
155
169
|
end
|
156
170
|
end
|
metadata
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
8
|
- 0
|
9
|
-
|
10
|
-
- 2
|
11
|
-
version: 0.4.0.beta.2
|
9
|
+
version: 0.4.0
|
12
10
|
platform: ruby
|
13
11
|
authors:
|
14
12
|
- New Bamboo
|
@@ -16,7 +14,7 @@ autorequire:
|
|
16
14
|
bindir: bin
|
17
15
|
cert_chain: []
|
18
16
|
|
19
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-27 00:00:00 +02:00
|
20
18
|
default_executable:
|
21
19
|
dependencies:
|
22
20
|
- !ruby/object:Gem::Dependency
|
@@ -123,13 +121,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
121
|
version: "0"
|
124
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
123
|
requirements:
|
126
|
-
- - "
|
124
|
+
- - ">="
|
127
125
|
- !ruby/object:Gem::Version
|
128
126
|
segments:
|
129
|
-
-
|
130
|
-
|
131
|
-
- 1
|
132
|
-
version: 1.3.1
|
127
|
+
- 0
|
128
|
+
version: "0"
|
133
129
|
requirements: []
|
134
130
|
|
135
131
|
rubyforge_project:
|