shoutbox-client 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,8 +28,8 @@ class ShoutboxClient
28
28
  req = Net::HTTP::Put.new( request_url(options) )
29
29
  default_headers(req)
30
30
  body_data = { :statusId => options[:statusId], :group => (options[:group] || configuration.default_group), :status => options[:status].to_s }
31
- body_data[:message] = options[:message] if options[:status].to_s == 'red' or (options[:status].to_s == 'yellow' and options[:message])
32
- raise ArgumentError if (options[:status] == :red) and body_data[:message].to_s.empty?
31
+ body_data[:message] = options[:message] if options[:message]
32
+ raise ArgumentError if (options[:status] == :red or options[:status] == :yellow) and body_data[:message].to_s.empty?
33
33
  req.body = body_data.to_json
34
34
  http.request(req)
35
35
  end
@@ -52,15 +52,6 @@ describe "ShoutboxClient" do
52
52
  ShoutboxClient.shout( :statusId => "test_status", :status => :green ).should == true
53
53
  end
54
54
 
55
- it 'should not include a message when status is yellow and no message given' do
56
- stub_request(:put, "http://localhost:3000/status").
57
- with(:body => "{\"statusId\":\"test_status\",\"group\":\"default group\",\"status\":\"yellow\"}",
58
- :headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby shoutbox-client'}).
59
- to_return(:status => 200, :body => "OK", :headers => {})
60
-
61
- ShoutboxClient.shout( :statusId => "test_status", :status => :yellow ).should == true
62
- end
63
-
64
55
  it 'should include a message when status is yellow and message is given' do
65
56
  stub_request(:put, "http://localhost:3000/status").
66
57
  with(:body => "{\"statusId\":\"test_status\",\"group\":\"default group\",\"status\":\"yellow\",\"message\":\"This is what you should do now..\"}",
@@ -79,19 +70,26 @@ describe "ShoutboxClient" do
79
70
  ShoutboxClient.shout( :statusId => "test_status", :status => :red, :message => "This is what you should do now.." ).should == true
80
71
  end
81
72
 
82
- it 'should not include a message when status is green' do
73
+ it 'should deny red update if message is missing' do
74
+ lambda {
75
+ ShoutboxClient.shout( :statusId => "test_status", :status => :red )
76
+ }.should raise_error(ArgumentError)
77
+ end
78
+
79
+ it 'should deny yellow update if message is missing' do
80
+ lambda {
81
+ ShoutboxClient.shout( :statusId => "test_status", :status => :yellow )
82
+ }.should raise_error(ArgumentError)
83
+ end
84
+
85
+ it 'should send optional status on green update' do
83
86
  stub_request(:put, "http://localhost:3000/status").
84
- with(:body => "{\"statusId\":\"test_status\",\"group\":\"default group\",\"status\":\"green\"}",
87
+ with(:body => "{\"statusId\":\"test_status\",\"group\":\"default group\",\"status\":\"green\",\"message\":\"everything's ok!\"}",
85
88
  :headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby shoutbox-client'}).
86
89
  to_return(:status => 200, :body => "OK", :headers => {})
87
-
88
- ShoutboxClient.shout( :statusId => "test_status", :status => :green, :message => "This is what you should do now.." ).should == true
89
- end
90
-
91
- it 'should deny red update if message is missin' do
92
90
  lambda {
93
- ShoutboxClient.shout( :statusId => "test_status", :status => :red )
94
- }.should raise_error(ArgumentError)
91
+ ShoutboxClient.shout( :statusId => "test_status", :status => :green, :message => "everything's ok!" )
92
+ }.should_not raise_error(ArgumentError)
95
93
  end
96
94
 
97
95
  it 'should delete a status' do
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.13
5
+ version: 0.0.14
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-10 00:00:00 +01:00
13
+ date: 2011-03-11 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: -4318415923322988878
114
+ hash: -3529820727078864145
115
115
  segments:
116
116
  - 0
117
117
  version: "0"