shoutbox-client 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shoutbox_client.rb +5 -1
- data/spec/shoutbox_client_spec.rb +11 -2
- metadata +3 -3
data/lib/shoutbox_client.rb
CHANGED
@@ -17,7 +17,11 @@ class ShoutboxClient
|
|
17
17
|
|
18
18
|
def self.shout( options )
|
19
19
|
if valid_status?( options[:status] )
|
20
|
-
|
20
|
+
begin
|
21
|
+
VALID_STATUS[options[:status].to_s] == :update ? update_status( options ) : delete_status( options )
|
22
|
+
rescue Errno::ECONNREFUSED
|
23
|
+
false
|
24
|
+
end
|
21
25
|
else
|
22
26
|
false
|
23
27
|
end
|
@@ -3,6 +3,10 @@ require 'tempfile'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
describe "ShoutboxClient" do
|
6
|
+
before(:each) do
|
7
|
+
ShoutboxClient.configuration.config_file = '/dont/exists'
|
8
|
+
end
|
9
|
+
|
6
10
|
context 'configuration' do
|
7
11
|
it 'should use the default configuration' do
|
8
12
|
ShoutboxClient.configuration.config_file = '/i/dont/exist'
|
@@ -20,7 +24,6 @@ describe "ShoutboxClient" do
|
|
20
24
|
ShoutboxClient.configuration.proxy_host.should == "prx"
|
21
25
|
ShoutboxClient.configuration.proxy_port.should == 8080
|
22
26
|
ShoutboxClient.configuration.default_group.should == 'default group'
|
23
|
-
ShoutboxClient.configuration.config_file = nil
|
24
27
|
end
|
25
28
|
|
26
29
|
it 'should use the configured default group' do
|
@@ -29,11 +32,17 @@ describe "ShoutboxClient" do
|
|
29
32
|
tempfile.close
|
30
33
|
ShoutboxClient.configuration.config_file = tempfile.path
|
31
34
|
ShoutboxClient.configuration.default_group.should == 'some group'
|
32
|
-
ShoutboxClient.configuration.config_file = nil
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
context 'http communication' do
|
39
|
+
|
40
|
+
it 'should return false when it cant connect to the host' do
|
41
|
+
ShoutboxClient.should_receive(:update_status).and_raise(Errno::ECONNREFUSED)
|
42
|
+
ShoutboxClient.shout( :group => "my_group", :statusId => "test_status", :status => :green ).should == false
|
43
|
+
end
|
44
|
+
|
45
|
+
|
37
46
|
it 'should create a valid PUT request to the shoutbox' do
|
38
47
|
stub_request(:put, "http://localhost:3000/status").
|
39
48
|
with(:body => "{\"statusId\":\"test_status\",\"group\":\"my_group\",\"status\":\"green\"}",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: shoutbox-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.15
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Benjamin Krause
|
@@ -10,7 +10,7 @@ autorequire: shoutbox_client
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-15 00:00:00 +01:00
|
14
14
|
default_executable: shout
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
requirements:
|
112
112
|
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
hash: -
|
114
|
+
hash: -225320292966696977
|
115
115
|
segments:
|
116
116
|
- 0
|
117
117
|
version: "0"
|