nebulous_stomp 3.0.1 → 3.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53e2585b6b1424042306d69a871a38632257e79a
4
- data.tar.gz: 0f4c7affb0acf4b97838866a0a16420daf234814
3
+ metadata.gz: dd218829ddf19457d5aab68ef9a6539a2e68f2a8
4
+ data.tar.gz: ef55678e7921f2ed9d750b6a6aac5b2b9417e0cb
5
5
  SHA512:
6
- metadata.gz: 0ebec48ed70a194f814af1fc38382a9fd6b72b30b66212675ed75b6d8c70a321fd1c462660d60ca4ece99691778859fa4fcd24d6cc110e9776ea101ada50ae7f
7
- data.tar.gz: 1bf072025eb60e1e7da496ca5d399fd77f989140ba0d567c0e30bdb35ee861e6fd2096faa53586a92a7c4f22a784012b279253e0461b38b2e4b72ddace52ee44
6
+ metadata.gz: dff8f6526477cf458da01e58ffcac4b59f6ebfeddc7374887ae230f1c2ff7ea7cd25c3278889a6bfd813959450554c1fa00323cb610e2ee2239b6cb9a01a1798
7
+ data.tar.gz: 46520f833f856a807a135ff0035211ee1e12edf0ae2ae057c28bcac033525ba321cdb2174f0e7b949b4d5a904ad0f9e9b29b0b08e7378dcf6021f739fb4f387d
@@ -96,12 +96,19 @@ describe 'stomp use cases:' do
96
96
  end
97
97
 
98
98
  it "can respond to a message with a non-Protocol message" do
99
- message = NebulousStomp::Message.new(verb: 'gimmemessage', contentType: 'text')
99
+ message = NebulousStomp::Message.new(verb: 'gimmemessage', contentType: 'application/json')
100
100
  response = NebulousStomp::Request.new("featuretest", message).send_no_cache
101
101
 
102
102
  expect( response ).to be_kind_of(NebulousStomp::Message)
103
103
  expect( response.verb ).to be_nil
104
- expect( response.body ).to eq "weird message body"
104
+ expect( response.body ).to eq(["weird message body", 12])
105
+ end
106
+
107
+ it "can respond with an empty array as the message body" do
108
+ message = NebulousStomp::Message.new(verb: 'gimmeempty', contentType: 'application/json')
109
+ response = NebulousStomp::Request.new("featuretest", message).send_no_cache
110
+ expect( response ).to be_kind_of(NebulousStomp::Message)
111
+ expect( response.body ).to eq([])
105
112
  end
106
113
 
107
114
  it "can send a message >32k" do
data/feature/gimme.rb CHANGED
@@ -48,8 +48,11 @@ class Gimme
48
48
  when "gimmeprotocol"
49
49
  msg.respond_with_protocol("foo", "bar", "baz")
50
50
 
51
+ when "gimmeempty"
52
+ msg.respond([])
53
+
51
54
  when "gimmemessage"
52
- msg.respond("weird message body")
55
+ msg.respond(["weird message body", 12])
53
56
 
54
57
  when "gimmebigmessage"
55
58
  body = big_body msg.params
@@ -135,6 +135,9 @@ module NebulousStomp
135
135
  # * :stompHeaders -- for a message from Stomp, the raw Stomp Headers string
136
136
  # * :verb -- part of The Protocol
137
137
  #
138
+ # Note that body is taken to be a string if the content type is text, and is taken to be JSON
139
+ # if the content type is JSON.
140
+ #
138
141
  def initialize(hash)
139
142
  @header = Msg::Header.new(hash)
140
143
  @body = Msg::Body.new(content_is_json?, hash)
@@ -185,7 +188,8 @@ module NebulousStomp
185
188
  # :call-seq:
186
189
  # message.respond_with_protocol(body) -> queue, Message
187
190
  #
188
- # Repond with a message body (presumably a custom one that's non-Protocol).
191
+ # Repond with a message body (presumably a custom one that's non-Protocol). If the content type
192
+ # is JSON, this can be an array or a Hash. If the content type is text, it must be a String.
189
193
  #
190
194
  def respond(body)
191
195
  fail NebulousError, "Don't know which queue to reply to" unless reply_to
@@ -111,7 +111,8 @@ module NebulousStomp
111
111
  if @verb
112
112
  @body = protocol_hash
113
113
  elsif @body.nil? || @body.respond_to?(:empty?) && @body.empty?
114
- @body = parse_stomp_body
114
+ sb = parse_stomp_body
115
+ @body = sb if sb
115
116
  end
116
117
 
117
118
  parse_body
@@ -1,5 +1,5 @@
1
1
  module NebulousStomp
2
2
 
3
3
  # Nebulous version number
4
- VERSION = "3.0.1"
4
+ VERSION = "3.0.2"
5
5
  end
data/spec/message_spec.rb CHANGED
@@ -120,6 +120,12 @@ describe Message do
120
120
  expect( m.body ).to eq "wigi wigi"
121
121
  end
122
122
 
123
+ it "leaves body alone if it\'s an empty array and there is no protocol and no stompbody" do
124
+ # rather than processing a nil stompbody and ending up with nil/NULL
125
+ m = Message.new(body: [])
126
+ expect( m.body ).to eq([])
127
+ end
128
+
123
129
  it 'takes the content type from the input arguments' do
124
130
  msg = Message.new( new_hash.merge(contentType: 'foo') )
125
131
  expect( msg.content_type ).to eq "foo"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nebulous_stomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-28 00:00:00.000000000 Z
11
+ date: 2017-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler