shoutbox-client 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,9 +10,6 @@ module Shoutbox
10
10
 
11
11
 
12
12
  def parse_options
13
-
14
- sub_commands = %w(red green destroy)
15
-
16
13
  @conf = Trollop::options do
17
14
  banner <<-EOS
18
15
  usage: shout <subcommand> <statusId>
@@ -39,6 +36,8 @@ EOS
39
36
  Trollop::die "provide <statusId> and <message> when shouting red" if @conf[:message].to_s.empty?
40
37
  when "green"
41
38
  # noop
39
+ when "yellow"
40
+ # noop
42
41
  when "remove"
43
42
  # noop
44
43
  else
@@ -6,6 +6,7 @@ require 'yaml'
6
6
 
7
7
  class ShoutboxClient
8
8
  VALID_STATUS = { 'red' => :update,
9
+ 'yellow' => :update,
9
10
  'green' => :update,
10
11
  'destroy' => :delete }
11
12
 
@@ -27,7 +28,7 @@ class ShoutboxClient
27
28
  req = Net::HTTP::Put.new( request_url(options) )
28
29
  default_headers(req)
29
30
  body_data = { :statusId => options[:statusId], :group => (options[:group] || 'default'), :status => options[:status].to_s }
30
- body_data[:message] = options[:message] if options[:status].to_s == 'red'
31
+ body_data[:message] = options[:message] if options[:status].to_s == 'red' or (options[:status].to_s == 'yellow' and options[:message])
31
32
  raise ArgumentError if (options[:status] == :red) and body_data[:message].to_s.empty?
32
33
  req.body = body_data.to_json
33
34
  http.request(req)
@@ -39,6 +39,24 @@ describe "ShoutboxClient" do
39
39
 
40
40
  ShoutboxClient.shout( :statusId => "test_status", :status => :green ).should == true
41
41
  end
42
+
43
+ it 'should not include a message when status is yellow and no message given' do
44
+ stub_request(:put, "http://localhost:3000/status").
45
+ with(:body => "{\"statusId\":\"test_status\",\"group\":\"default\",\"status\":\"yellow\"}",
46
+ :headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby shoutbox-client'}).
47
+ to_return(:status => 200, :body => "OK", :headers => {})
48
+
49
+ ShoutboxClient.shout( :statusId => "test_status", :status => :yellow ).should == true
50
+ end
51
+
52
+ it 'should include a message when status is yellow and message is given' do
53
+ stub_request(:put, "http://localhost:3000/status").
54
+ with(:body => "{\"statusId\":\"test_status\",\"group\":\"default\",\"status\":\"yellow\",\"message\":\"This is what you should do now..\"}",
55
+ :headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby shoutbox-client'}).
56
+ to_return(:status => 200, :body => "OK", :headers => {})
57
+
58
+ ShoutboxClient.shout( :statusId => "test_status", :status => :yellow, :message => "This is what you should do now.." ).should == true
59
+ end
42
60
 
43
61
  it 'should include a message when status is red' do
44
62
  stub_request(:put, "http://localhost:3000/status").
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Benjamin Krause
@@ -134,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- hash: 3514835620310691199
137
+ hash: 1158908200310400392
138
138
  segments:
139
139
  - 0
140
140
  version: "0"