fastly_nsq 1.15.0 → 1.17.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.git-blame-ignore-revs +6 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +4 -3
  5. data/ChangeLog.md +24 -1
  6. data/Gemfile +8 -8
  7. data/README.md +5 -1
  8. data/Rakefile +10 -11
  9. data/fastly_nsq.gemspec +26 -26
  10. data/lib/fastly_nsq/cli.rb +43 -50
  11. data/lib/fastly_nsq/consumer.rb +6 -6
  12. data/lib/fastly_nsq/feeder.rb +5 -7
  13. data/lib/fastly_nsq/http/nsqd.rb +28 -28
  14. data/lib/fastly_nsq/http/nsqlookupd.rb +11 -11
  15. data/lib/fastly_nsq/http.rb +4 -4
  16. data/lib/fastly_nsq/launcher.rb +16 -16
  17. data/lib/fastly_nsq/listener.rb +17 -16
  18. data/lib/fastly_nsq/manager.rb +13 -12
  19. data/lib/fastly_nsq/message.rb +9 -5
  20. data/lib/fastly_nsq/messenger.rb +25 -15
  21. data/lib/fastly_nsq/new_relic.rb +8 -8
  22. data/lib/fastly_nsq/priority_queue.rb +2 -2
  23. data/lib/fastly_nsq/priority_thread_pool.rb +3 -3
  24. data/lib/fastly_nsq/producer.rb +7 -7
  25. data/lib/fastly_nsq/safe_thread.rb +1 -1
  26. data/lib/fastly_nsq/testing.rb +12 -2
  27. data/lib/fastly_nsq/tls_options.rb +6 -6
  28. data/lib/fastly_nsq/version.rb +1 -1
  29. data/lib/fastly_nsq.rb +27 -29
  30. data/spec/cli_spec.rb +2 -2
  31. data/spec/consumer_spec.rb +12 -12
  32. data/spec/fastly_nsq_spec.rb +31 -31
  33. data/spec/feeder_spec.rb +4 -4
  34. data/spec/http/nsqd_spec.rb +23 -23
  35. data/spec/http/nsqlookupd_spec.rb +19 -19
  36. data/spec/http_spec.rb +22 -22
  37. data/spec/integration_spec.rb +10 -10
  38. data/spec/launcher_spec.rb +21 -21
  39. data/spec/listener_spec.rb +50 -50
  40. data/spec/manager_spec.rb +27 -27
  41. data/spec/matchers/delegate.rb +4 -4
  42. data/spec/message_spec.rb +20 -20
  43. data/spec/messenger_spec.rb +71 -59
  44. data/spec/new_relic.rb +27 -27
  45. data/spec/priority_thread_pool_spec.rb +2 -2
  46. data/spec/producer_spec.rb +30 -30
  47. data/spec/spec_helper.rb +12 -12
  48. data/spec/support/http.rb +2 -2
  49. data/spec/support/webmock.rb +1 -1
  50. data/spec/testing_spec.rb +12 -12
  51. data/spec/tls_options_spec.rb +47 -47
  52. metadata +14 -15
  53. data/.rubocop.yml +0 -68
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'fastly_nsq/http/nsqlookupd'
3
+ require "spec_helper"
4
+ require "fastly_nsq/http/nsqlookupd"
5
5
 
6
6
  RSpec.describe FastlyNsq::Http::Nsqlookupd, :webmock do
7
- let(:base_uri) { 'http://example.com' }
7
+ let(:base_uri) { "http://example.com" }
8
8
 
9
- it 'makes simple get requests' do
9
+ it "makes simple get requests" do
10
10
  %w[topics nodes ping info].each do |api|
11
11
  url = "#{base_uri}/#{api}"
12
12
  stub_request(:get, url)
@@ -16,52 +16,52 @@ RSpec.describe FastlyNsq::Http::Nsqlookupd, :webmock do
16
16
  end
17
17
  end
18
18
 
19
- it 'can lookup producers for a topic' do
19
+ it "can lookup producers for a topic" do
20
20
  url = "#{base_uri}/lookup?topic=lol"
21
21
  stub_request(:get, url)
22
- data = { topic: 'lol' }
22
+ data = {topic: "lol"}
23
23
 
24
- FastlyNsq::Http::Nsqlookupd.lookup(topic: 'lol', base_uri: base_uri)
24
+ FastlyNsq::Http::Nsqlookupd.lookup(topic: "lol", base_uri: base_uri)
25
25
 
26
26
  expect(a_request(:get, url).with(query: data)).to have_been_requested
27
27
  end
28
28
 
29
- it 'can lookup channels for a topic' do
29
+ it "can lookup channels for a topic" do
30
30
  url = "#{base_uri}/channels?topic=lol"
31
31
  stub_request(:get, url)
32
- data = { topic: 'lol' }
32
+ data = {topic: "lol"}
33
33
 
34
- FastlyNsq::Http::Nsqlookupd.channels(topic: 'lol', base_uri: base_uri)
34
+ FastlyNsq::Http::Nsqlookupd.channels(topic: "lol", base_uri: base_uri)
35
35
 
36
36
  expect(a_request(:get, url).with(query: data)).to have_been_requested
37
37
  end
38
38
 
39
- it 'can delete a topic' do
39
+ it "can delete a topic" do
40
40
  url = "#{base_uri}/delete_topic?topic=lol"
41
41
  stub_request(:get, url)
42
- data = { topic: 'lol' }
42
+ data = {topic: "lol"}
43
43
 
44
- FastlyNsq::Http::Nsqlookupd.delete_topic(topic: 'lol', base_uri: base_uri)
44
+ FastlyNsq::Http::Nsqlookupd.delete_topic(topic: "lol", base_uri: base_uri)
45
45
 
46
46
  expect(a_request(:get, url).with(query: data)).to have_been_requested
47
47
  end
48
48
 
49
- it 'can delete a channel' do
49
+ it "can delete a channel" do
50
50
  url = "#{base_uri}/delete_channel?topic=lol&channel=foo"
51
51
  stub_request(:get, url)
52
- data = { topic: 'lol', channel: 'foo' }
52
+ data = {topic: "lol", channel: "foo"}
53
53
 
54
- FastlyNsq::Http::Nsqlookupd.delete_channel(topic: 'lol', channel: 'foo', base_uri: base_uri)
54
+ FastlyNsq::Http::Nsqlookupd.delete_channel(topic: "lol", channel: "foo", base_uri: base_uri)
55
55
 
56
56
  expect(a_request(:get, url).with(query: data)).to have_been_requested
57
57
  end
58
58
 
59
- it 'can tombstone a producer' do
59
+ it "can tombstone a producer" do
60
60
  url = "#{base_uri}/tombstone_topic_producer?topic=lol&node=localhost:8989"
61
61
  stub_request(:get, url)
62
- data = { topic: 'lol', node: 'localhost:8989' }
62
+ data = {topic: "lol", node: "localhost:8989"}
63
63
 
64
- FastlyNsq::Http::Nsqlookupd.tombstone_topic_producer(topic: 'lol', node: 'localhost:8989', base_uri: base_uri)
64
+ FastlyNsq::Http::Nsqlookupd.tombstone_topic_producer(topic: "lol", node: "localhost:8989", base_uri: base_uri)
65
65
 
66
66
  expect(a_request(:get, url).with(query: data)).to have_been_requested
67
67
  end
data/spec/http_spec.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'fastly_nsq/http'
3
+ require "spec_helper"
4
+ require "fastly_nsq/http"
5
5
 
6
6
  RSpec.describe FastlyNsq::Http, :webmock do
7
- let(:base_url) { 'http://example.com' }
8
- describe 'get' do
9
- it 'can make simple requests' do
7
+ let(:base_url) { "http://example.com" }
8
+ describe "get" do
9
+ it "can make simple requests" do
10
10
  url = "#{base_url}/boop"
11
11
  stub_request(:get, url)
12
12
 
@@ -16,9 +16,9 @@ RSpec.describe FastlyNsq::Http, :webmock do
16
16
  expect(a_request(:get, url)).to have_been_requested.twice
17
17
  end
18
18
 
19
- it 'can make requests with params' do
19
+ it "can make requests with params" do
20
20
  url = "#{base_url}/boop?sloop=noop"
21
- data = { sloop: 'noop' }
21
+ data = {sloop: "noop"}
22
22
  stub_request(:get, url)
23
23
 
24
24
  FastlyNsq::Http.new(uri: url).get(data)
@@ -27,11 +27,11 @@ RSpec.describe FastlyNsq::Http, :webmock do
27
27
  end
28
28
  end
29
29
 
30
- describe 'post' do
31
- it 'can make simple post requests' do
30
+ describe "post" do
31
+ it "can make simple post requests" do
32
32
  url = "#{base_url}/boop?sloop=noop"
33
33
  stub_request(:post, url)
34
- data = { sloop: 'noop' }
34
+ data = {sloop: "noop"}
35
35
 
36
36
  FastlyNsq::Http.new(uri: URI.parse(url)).post(data)
37
37
  FastlyNsq::Http.new(uri: url).post(data)
@@ -39,11 +39,11 @@ RSpec.describe FastlyNsq::Http, :webmock do
39
39
  expect(a_request(:post, url)).to have_been_requested.twice
40
40
  end
41
41
 
42
- it 'can make post requests with bodies' do
42
+ it "can make post requests with bodies" do
43
43
  url = "#{base_url}/boop?sloop=noop"
44
44
  stub_request(:post, url)
45
- data = { sloop: 'noop' }
46
- body = 'SOME MESSAGE'
45
+ data = {sloop: "noop"}
46
+ body = "SOME MESSAGE"
47
47
 
48
48
  FastlyNsq::Http.new(uri: url).post(data, body)
49
49
 
@@ -51,18 +51,18 @@ RSpec.describe FastlyNsq::Http, :webmock do
51
51
  end
52
52
  end
53
53
 
54
- describe 'SSL' do
55
- it 'can be asked to use SSL' do
56
- ssl_url = 'https://example.com:80/boop'
54
+ describe "SSL" do
55
+ it "can be asked to use SSL" do
56
+ ssl_url = "https://example.com:80/boop"
57
57
  stub_request(:get, ssl_url)
58
58
 
59
- cert_file = '/tmp/thing.cert'
60
- key_file = '/tmp/thing.key'
59
+ cert_file = "/tmp/thing.cert"
60
+ key_file = "/tmp/thing.key"
61
61
 
62
- allow(File).to receive(:read).with(cert_file).and_return('something')
63
- allow(File).to receive(:read).with(key_file).and_return('something')
64
- allow(OpenSSL::X509::Certificate).to receive(:new).with('something').and_return(true)
65
- allow(OpenSSL::PKey::RSA).to receive(:new).with('something').and_return(true)
62
+ allow(File).to receive(:read).with(cert_file).and_return("something")
63
+ allow(File).to receive(:read).with(key_file).and_return("something")
64
+ allow(OpenSSL::X509::Certificate).to receive(:new).with("something").and_return(true)
65
+ allow(OpenSSL::PKey::RSA).to receive(:new).with("something").and_return(true)
66
66
 
67
67
  url = "#{base_url}/boop"
68
68
  http = FastlyNsq::Http.new(uri: url, cert_filename: cert_file, key_filename: key_file)
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
- RSpec.describe 'integration' do
6
- let!(:topic) { 'fnsq-topic' }
7
- let!(:channel) { 'fnsq-channel' }
8
- let!(:message) { { 'foo' => 'bar' } }
5
+ RSpec.describe "integration" do
6
+ let!(:topic) { "fnsq-topic" }
7
+ let!(:channel) { "fnsq-channel" }
8
+ let!(:message) { {"foo" => "bar"} }
9
9
 
10
10
  before { reset_topic(topic, channel: channel) }
11
11
 
12
- it 'processes jobs' do
12
+ it "processes jobs" do
13
13
  received = nil
14
14
  producer = FastlyNsq::Producer.new(topic: topic)
15
15
  FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(m) { received = m })
@@ -18,8 +18,8 @@ RSpec.describe 'integration' do
18
18
  expect { received&.body }.to eventually(eq(message)).within(2)
19
19
  end
20
20
 
21
- describe 'inline', :inline do
22
- it 'processes job' do
21
+ describe "inline", :inline do
22
+ it "processes job" do
23
23
  received = nil
24
24
  producer = FastlyNsq::Producer.new(topic: topic)
25
25
  FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(m) { received = m })
@@ -29,8 +29,8 @@ RSpec.describe 'integration' do
29
29
  end
30
30
  end
31
31
 
32
- describe 'fake', :fake do
33
- it 'stores jobs' do
32
+ describe "fake", :fake do
33
+ it "stores jobs" do
34
34
  received = nil
35
35
  encoded_message = JSON.dump(message)
36
36
  producer = FastlyNsq::Producer.new(topic: topic)
@@ -1,40 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe FastlyNsq::Launcher do
6
- let!(:channel) { 'fnsq' }
7
- let!(:options) { { max_threads: 3, timeout: 9 } }
8
- let!(:topic) { 'fnsq' }
6
+ let!(:channel) { "fnsq" }
7
+ let!(:options) { {max_threads: 3, timeout: 9} }
8
+ let!(:topic) { "fnsq" }
9
9
 
10
- let(:launcher) { FastlyNsq::Launcher.new options }
11
- let(:listener) { FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(*) {}) }
10
+ let(:launcher) { FastlyNsq::Launcher.new(**options) }
11
+ let(:listener) { FastlyNsq::Listener.new(topic: topic, channel: channel, processor: ->(*) {}) }
12
12
  let(:manager) { launcher.manager }
13
13
 
14
14
  before { reset_topic(topic, channel: channel) }
15
15
  before { expect { listener }.to eventually(be_connected).within(5) }
16
- after { listener.terminate if listener.connected? }
16
+ after { listener.terminate if listener.connected? }
17
17
 
18
- it 'creates a manager with correct options' do
18
+ it "creates a manager with correct options" do
19
19
  launcher
20
20
 
21
21
  expect(FastlyNsq.manager.pool.max_threads).to eq(3)
22
22
  end
23
23
 
24
- describe '#beat' do
25
- let!(:logger) { Logger.new(nil).tap { |l| l.level = Logger::DEBUG } }
24
+ describe "#beat" do
25
+ let!(:logger) { Logger.new(nil).tap { |l| l.level = Logger::DEBUG } }
26
26
  let!(:launcher) { FastlyNsq::Launcher.new pulse: 0.01, logger: logger }
27
27
 
28
- it 'creates a heartbeat thread' do
28
+ it "creates a heartbeat thread" do
29
29
  expect(logger).not_to receive(:error)
30
- expect { launcher.beat }.to eventually_not(eq('dead')).pause_for(1)
30
+ expect { launcher.beat }.to eventually_not(eq("dead")).pause_for(1)
31
31
  end
32
32
  end
33
33
 
34
- describe '#stop_listeners' do
34
+ describe "#stop_listeners" do
35
35
  before { launcher }
36
36
 
37
- it 'stops listeners and sets done' do
37
+ it "stops listeners and sets done" do
38
38
  expect(launcher).not_to be_stopping
39
39
  expect(manager).to receive(:stop_listeners)
40
40
  expect(manager).not_to receive(:terminate)
@@ -45,20 +45,20 @@ RSpec.describe FastlyNsq::Launcher do
45
45
  end
46
46
  end
47
47
 
48
- describe '#stop' do
48
+ describe "#stop" do
49
49
  before { launcher }
50
50
 
51
- it 'stops the manager within a deadline' do
51
+ it "stops the manager within a deadline" do
52
52
  expect(manager).to receive(:terminate).with(options[:timeout])
53
53
  launcher.stop
54
54
  end
55
55
  end
56
56
 
57
- describe 'callbacks' do
57
+ describe "callbacks" do
58
58
  before { FastlyNsq.events.each { |(_, v)| v.clear } }
59
- after { FastlyNsq.events.each { |(_, v)| v.clear } }
59
+ after { FastlyNsq.events.each { |(_, v)| v.clear } }
60
60
 
61
- it 'fires :startup event on initialization' do
61
+ it "fires :startup event on initialization" do
62
62
  obj = spy
63
63
  block = -> { obj.start }
64
64
  FastlyNsq.on(:startup, &block)
@@ -67,7 +67,7 @@ RSpec.describe FastlyNsq::Launcher do
67
67
  expect(obj).to have_received(:start)
68
68
  end
69
69
 
70
- it 'fires :shutdown event on #stop' do
70
+ it "fires :shutdown event on #stop" do
71
71
  launcher
72
72
 
73
73
  obj = spy
@@ -78,7 +78,7 @@ RSpec.describe FastlyNsq::Launcher do
78
78
  expect(obj).to have_received(:stop)
79
79
  end
80
80
 
81
- it 'fires :heartbeat event on #heartbeat' do
81
+ it "fires :heartbeat event on #heartbeat" do
82
82
  obj = spy
83
83
  block = -> { obj.beat }
84
84
  FastlyNsq.on(:heartbeat, &block)
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe FastlyNsq::Listener do
6
- let!(:topic) { 'fnsq' }
7
- let!(:channel) { 'fnsq' }
6
+ let!(:topic) { "fnsq" }
7
+ let!(:channel) { "fnsq" }
8
8
  let!(:messages) { [] }
9
9
  let(:processor) { ->(m) { messages << m.body } }
10
10
 
11
11
  before { reset_topic(topic, channel: channel) }
12
12
  before { expect { subject }.to eventually(be_connected).within(5) }
13
- after { subject.terminate if subject.connected? }
13
+ after { subject.terminate if subject.connected? }
14
14
 
15
15
  subject { described_class.new(topic: topic, channel: channel, processor: processor) }
16
16
 
17
- describe '#initialize' do
18
- describe 'with FastlyNsq.max_attempts set' do
17
+ describe "#initialize" do
18
+ describe "with FastlyNsq.max_attempts set" do
19
19
  let!(:default_max_attempts) { FastlyNsq.max_attempts }
20
20
  before { FastlyNsq.max_attempts = 19 }
21
21
  after { FastlyNsq.max_attempts = default_max_attempts }
22
22
 
23
- it 'defaults to FastlyNsq.max_attempts' do
23
+ it "defaults to FastlyNsq.max_attempts" do
24
24
  listener = described_class.new(topic: topic, processor: processor, channel: channel)
25
25
  expect(listener.max_attempts).to eq(FastlyNsq.max_attempts)
26
26
 
@@ -31,91 +31,91 @@ RSpec.describe FastlyNsq::Listener do
31
31
  end
32
32
  end
33
33
 
34
- describe 'with FastlyNsq.channel set' do
34
+ describe "with FastlyNsq.channel set" do
35
35
  let!(:default_channel) { FastlyNsq.channel }
36
- before { FastlyNsq.channel = 'fnsq' }
36
+ before { FastlyNsq.channel = "fnsq" }
37
37
  after { FastlyNsq.channel = default_channel }
38
38
 
39
- it 'defaults to FastlyNsq.channel' do
39
+ it "defaults to FastlyNsq.channel" do
40
40
  listener = described_class.new(topic: topic, processor: processor)
41
41
  expect(listener.channel).to eq(FastlyNsq.channel)
42
42
  end
43
43
  end
44
44
 
45
- describe 'with FastlyNsq.preprocessor set' do
45
+ describe "with FastlyNsq.preprocessor set" do
46
46
  let!(:default_preprocessor) { FastlyNsq.preprocessor }
47
- before { FastlyNsq.preprocessor = 'fnsq' }
47
+ before { FastlyNsq.preprocessor = "fnsq" }
48
48
  after { FastlyNsq.preprocessor = default_preprocessor }
49
49
 
50
- it 'defaults to FastlyNsq.preprocessor' do
50
+ it "defaults to FastlyNsq.preprocessor" do
51
51
  listener = described_class.new(topic: topic, processor: processor, channel: channel)
52
52
  expect(listener.preprocessor).to eq(FastlyNsq.preprocessor)
53
53
  end
54
54
  end
55
55
 
56
- describe 'with FastlyNsq.logger set' do
56
+ describe "with FastlyNsq.logger set" do
57
57
  let!(:default_logger) { FastlyNsq.logger }
58
58
  before { FastlyNsq.logger = Logger.new(nil) }
59
59
  after { FastlyNsq.logger = default_logger }
60
60
 
61
- it 'defaults to FastlyNsq.logger' do
61
+ it "defaults to FastlyNsq.logger" do
62
62
  listener = described_class.new(topic: topic, processor: processor, channel: channel)
63
63
  expect(listener.logger).to eq(FastlyNsq.logger)
64
64
  end
65
65
  end
66
66
 
67
- it 'warns when creating a listener for the same topic' do
67
+ it "warns when creating a listener for the same topic" do
68
68
  expect(FastlyNsq.manager.logger).to receive(:warn).and_yield.and_return(match("#{topic} was added more than once"))
69
69
 
70
70
  described_class.new(topic: topic, channel: channel, processor: processor)
71
71
  end
72
72
  end
73
73
 
74
- describe '#priority' do
74
+ describe "#priority" do
75
75
  specify { expect(subject.priority).to eq(described_class::DEFAULT_PRIORITY) }
76
76
  end
77
77
 
78
- describe '#consumer' do
78
+ describe "#consumer" do
79
79
  specify { expect(subject.consumer).to be_a(FastlyNsq::Consumer) }
80
80
  end
81
81
 
82
- describe 'connect_timeout' do
82
+ describe "connect_timeout" do
83
83
  specify { expect(subject.consumer.connect_timeout).to eq(described_class::DEFAULT_CONNECTION_TIMEOUT) }
84
84
  end
85
85
 
86
- it 'requires processor to respond_to #call' do
87
- expect { described_class.new(topic: topic, channel: channel, processor: 'foo') }.
88
- to raise_error(ArgumentError, match('#call'))
86
+ it "requires processor to respond_to #call" do
87
+ expect { described_class.new(topic: topic, channel: channel, processor: "foo") }
88
+ .to raise_error(ArgumentError, match("#call"))
89
89
  end
90
90
 
91
- it 'requires priority to be a Fixnum' do
92
- expect { described_class.new(topic: topic, channel: channel, processor: ->(*) {}, priority: 'foo') }.
93
- to raise_error(ArgumentError, match('Integer'))
91
+ it "requires priority to be a Fixnum" do
92
+ expect { described_class.new(topic: topic, channel: channel, processor: ->(*) {}, priority: "foo") }
93
+ .to raise_error(ArgumentError, match("Integer"))
94
94
  end
95
95
 
96
- describe '#call' do
97
- it 'processes a message' do
98
- body = { 'foo' => 'bar' }
99
- message = spy('message', body: JSON.dump(body))
96
+ describe "#call" do
97
+ it "processes a message" do
98
+ body = {"foo" => "bar"}
99
+ message = spy("message", body: JSON.dump(body))
100
100
  expect { subject.call(message) }.to change { messages }.to([body])
101
101
  end
102
102
 
103
- describe 'when the processor returns true' do
103
+ describe "when the processor returns true" do
104
104
  let(:processor) { ->(_) { true } }
105
105
 
106
- it 'finishes the message' do
107
- message = spy('message', body: '{}')
106
+ it "finishes the message" do
107
+ message = spy("message", body: "{}")
108
108
  subject.call(message)
109
109
 
110
110
  expect(message).to have_received(:finish)
111
111
  end
112
112
  end
113
113
 
114
- describe 'when the processor returns false' do
114
+ describe "when the processor returns false" do
115
115
  let(:processor) { ->(_) { false } }
116
116
 
117
- it 'finishes the message' do
118
- message = spy('message', body: '{}')
117
+ it "finishes the message" do
118
+ message = spy("message", body: "{}")
119
119
  subject.call(message)
120
120
 
121
121
  expect(message).not_to have_received(:finish)
@@ -125,18 +125,18 @@ RSpec.describe FastlyNsq::Listener do
125
125
 
126
126
  it { should be_connected }
127
127
 
128
- it 'should terminate' do
128
+ it "should terminate" do
129
129
  expect { subject.terminate }.to change(subject, :connected?).to(false)
130
130
  end
131
131
 
132
- describe 'faking', :fake do
133
- let!(:message) { JSON.dump('foo' => 'bar') }
132
+ describe "faking", :fake do
133
+ let!(:message) { JSON.dump("foo" => "bar") }
134
134
 
135
135
  before { subject }
136
136
 
137
137
  it { should be_connected }
138
138
 
139
- it 'should terminate' do
139
+ it "should terminate" do
140
140
  expect { subject.terminate }.to change(subject, :connected?).to(false)
141
141
  end
142
142
 
@@ -149,49 +149,49 @@ RSpec.describe FastlyNsq::Listener do
149
149
  expect(test_message.raw_body).to eq(message)
150
150
  end
151
151
 
152
- describe 'when the processor returns true' do
152
+ describe "when the processor returns true" do
153
153
  let(:processor) { ->(_) { true } }
154
154
 
155
- it 'drains queued messages' do
155
+ it "drains queued messages" do
156
156
  FastlyNsq::Producer.new(topic: topic).write(message)
157
157
  expect { subject.drain }.to change { subject.messages.size }.by(-1)
158
158
  end
159
159
  end
160
160
 
161
- describe 'when the processor returns false' do
161
+ describe "when the processor returns false" do
162
162
  let(:processor) { ->(_) { false } }
163
163
 
164
- it 'does not remove messages' do
164
+ it "does not remove messages" do
165
165
  FastlyNsq::Producer.new(topic: topic).write(message)
166
166
  expect { subject.drain }.not_to change { subject.messages.size }
167
167
  end
168
168
  end
169
169
  end
170
170
 
171
- describe 'inline', :inline do
172
- let!(:message) { JSON.dump('foo' => 'bar') }
171
+ describe "inline", :inline do
172
+ let!(:message) { JSON.dump("foo" => "bar") }
173
173
  let!(:processor) { ->(m) { messages << m.raw_body } }
174
174
 
175
175
  before { subject }
176
176
 
177
177
  it { should be_connected }
178
178
 
179
- it 'should terminate' do
179
+ it "should terminate" do
180
180
  expect { subject.terminate }.to change(subject, :connected?).to(false)
181
181
  end
182
182
 
183
- describe 'when the processor returns true' do
184
- it 'processes and removes messages' do
183
+ describe "when the processor returns true" do
184
+ it "processes and removes messages" do
185
185
  expect { FastlyNsq::Producer.new(topic: topic).write(message) }.to change { messages.size }.by(1)
186
186
  expect(messages).to contain_exactly(message)
187
187
  expect(subject.messages).to be_empty
188
188
  end
189
189
  end
190
190
 
191
- describe 'when the processor returns false' do
191
+ describe "when the processor returns false" do
192
192
  let(:processor) { ->(_) { false } }
193
193
 
194
- it 'does not remove messages' do
194
+ it "does not remove messages" do
195
195
  FastlyNsq::Producer.new(topic: topic).write(message)
196
196
  expect { subject.drain }.not_to change { subject.messages.size }
197
197
  end