fastly_nsq 1.17.0 → 1.17.1

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.
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 -2
  5. data/ChangeLog.md +8 -1
  6. data/Gemfile +8 -8
  7. data/README.md +1 -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 +16 -16
  18. data/lib/fastly_nsq/manager.rb +13 -12
  19. data/lib/fastly_nsq/message.rb +4 -4
  20. data/lib/fastly_nsq/messenger.rb +7 -7
  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 +4 -3
  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 +19 -19
  43. data/spec/messenger_spec.rb +63 -64
  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 +7 -8
  53. data/.rubocop.yml +0 -68
@@ -1,23 +1,22 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
- require 'spec_helper'
5
- require 'json'
3
+ require "spec_helper"
4
+ require "json"
6
5
 
7
6
  RSpec.describe FastlyNsq::Messenger do
8
- let(:message) { { sample: 'sample', message: 'message' } }
9
- let(:message2) { { sample: 'elpmas', message: 'egassem' } }
10
- let(:producer) { double 'FastlyNsq::Producer', write: nil, terminate: :terminated }
11
- let(:origin) { 'originating_service' }
12
- let(:sent_at) { Time.now.iso8601(5) }
7
+ let(:message) { {sample: "sample", message: "message"} }
8
+ let(:message2) { {sample: "elpmas", message: "egassem"} }
9
+ let(:producer) { double "FastlyNsq::Producer", write: nil, terminate: :terminated }
10
+ let(:origin) { "originating_service" }
11
+ let(:sent_at) { Time.now.iso8601(5) }
13
12
 
14
13
  let(:expected_attributes) do
15
14
  {
16
15
  data: message,
17
16
  meta: {
18
- originating_service: 'originating_service',
19
- sent_at: sent_at,
20
- },
17
+ originating_service: "originating_service",
18
+ sent_at: sent_at
19
+ }
21
20
  }
22
21
  end
23
22
 
@@ -27,100 +26,100 @@ RSpec.describe FastlyNsq::Messenger do
27
26
  FastlyNsq::Messenger.instance_variable_set(:@producers, nil)
28
27
  end
29
28
 
30
- describe '#deliver' do
29
+ describe "#deliver" do
31
30
  before { Timecop.freeze(sent_at) }
32
31
 
33
- it 'writes a single message on a producer' do
34
- subject.producers['topic'] = producer
32
+ it "writes a single message on a producer" do
33
+ subject.producers["topic"] = producer
35
34
 
36
- subject.deliver message: message, topic: 'topic', originating_service: origin
35
+ subject.deliver message: message, topic: "topic", originating_service: origin
37
36
 
38
37
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
39
38
  end
40
39
 
41
- it 'uses a Unknown for the default originating_service' do
42
- subject.producers['topic'] = producer
43
- expected_attributes[:meta][:originating_service] = 'Unknown'
40
+ it "uses a Unknown for the default originating_service" do
41
+ subject.producers["topic"] = producer
42
+ expected_attributes[:meta][:originating_service] = "Unknown"
44
43
 
45
- subject.deliver message: message, topic: 'topic'
44
+ subject.deliver message: message, topic: "topic"
46
45
 
47
46
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
48
47
  end
49
48
 
50
- it 'allows setting arbitrary metadata' do
51
- meta = { test: 'test' }
49
+ it "allows setting arbitrary metadata" do
50
+ meta = {test: "test"}
52
51
 
53
- expected_attributes = { data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at) }
52
+ expected_attributes = {data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at)}
54
53
 
55
- subject.producers['topic'] = producer
54
+ subject.producers["topic"] = producer
56
55
 
57
- subject.deliver message: message, topic: 'topic', meta: meta, originating_service: origin
56
+ subject.deliver message: message, topic: "topic", meta: meta, originating_service: origin
58
57
 
59
58
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
60
59
  end
61
60
 
62
- it 'prevents originating_service from being overwritten by meta' do
63
- meta = { test: 'test' }
61
+ it "prevents originating_service from being overwritten by meta" do
62
+ meta = {test: "test"}
64
63
 
65
- expected_attributes = { data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at) }
64
+ expected_attributes = {data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at)}
66
65
 
67
- meta[:originating_service] = 'other_service'
66
+ meta[:originating_service] = "other_service"
68
67
 
69
- subject.producers['topic'] = producer
68
+ subject.producers["topic"] = producer
70
69
 
71
- subject.deliver message: message, topic: 'topic', meta: meta, originating_service: origin
70
+ subject.deliver message: message, topic: "topic", meta: meta, originating_service: origin
72
71
 
73
72
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
74
73
  end
75
74
 
76
- it 'can set the sent_at in the metadata' do
77
- sent_at = Time.parse('2020-06-08 23:42:42')
75
+ it "can set the sent_at in the metadata" do
76
+ sent_at = Time.parse("2020-06-08 23:42:42")
78
77
  meta = {}
79
78
 
80
- expected_attributes = { data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at.iso8601(5)) }
79
+ expected_attributes = {data: message, meta: meta.merge(originating_service: origin, sent_at: sent_at.iso8601(5))}
81
80
 
82
- subject.producers['topic'] = producer
81
+ subject.producers["topic"] = producer
83
82
 
84
- subject.deliver message: message, topic: 'topic', sent_at: sent_at, meta: meta, originating_service: origin
83
+ subject.deliver message: message, topic: "topic", sent_at: sent_at, meta: meta, originating_service: origin
85
84
 
86
85
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
87
86
  end
88
87
  end
89
88
 
90
- describe '#deliver_multi' do
89
+ describe "#deliver_multi" do
91
90
  let(:expected_attributes_multi) do
92
91
  [
93
92
  expected_attributes.to_json,
94
93
  {
95
94
  data: message2,
96
95
  meta: {
97
- originating_service: 'originating_service',
98
- sent_at: sent_at,
99
- },
100
- }.to_json,
96
+ originating_service: "originating_service",
97
+ sent_at: sent_at
98
+ }
99
+ }.to_json
101
100
  ]
102
101
  end
103
102
  before { Timecop.freeze(sent_at) }
104
103
 
105
- it 'writes an array of messages on a producer' do
106
- subject.producers['topic'] = producer
104
+ it "writes an array of messages on a producer" do
105
+ subject.producers["topic"] = producer
107
106
 
108
- subject.deliver_multi messages: [message, message2], topic: 'topic', originating_service: origin
107
+ subject.deliver_multi messages: [message, message2], topic: "topic", originating_service: origin
109
108
 
110
109
  expect(producer).to have_received(:write).with(expected_attributes_multi)
111
110
  end
112
111
  end
113
112
 
114
- describe '#originating_service=' do
113
+ describe "#originating_service=" do
115
114
  before { Timecop.freeze(sent_at) }
116
115
 
117
116
  it "set's the default originating service" do
118
- subject.producers['nanotopic'] = producer
119
- service = 'nano service'
117
+ subject.producers["nanotopic"] = producer
118
+ service = "nano service"
120
119
  subject.originating_service = service
121
120
  expected_attributes[:meta][:originating_service] = service
122
121
 
123
- subject.deliver message: message, topic: 'nanotopic'
122
+ subject.deliver message: message, topic: "nanotopic"
124
123
 
125
124
  expect(producer).to have_received(:write).with(expected_attributes.to_json)
126
125
 
@@ -129,42 +128,42 @@ RSpec.describe FastlyNsq::Messenger do
129
128
  end
130
129
  end
131
130
 
132
- describe '#producer_for' do
133
- it 'returns an FastlyNsq::Producer for the given topic' do
134
- my_producer = subject.producer_for(topic: 'my_topic')
131
+ describe "#producer_for" do
132
+ it "returns an FastlyNsq::Producer for the given topic" do
133
+ my_producer = subject.producer_for(topic: "my_topic")
135
134
  expect(my_producer).to be_a(FastlyNsq::Producer)
136
135
  end
137
136
 
138
- it 'persists producers' do
139
- subject.producers['topic'] = producer
137
+ it "persists producers" do
138
+ subject.producers["topic"] = producer
140
139
 
141
- my_producer = subject.producer_for(topic: 'topic')
140
+ my_producer = subject.producer_for(topic: "topic")
142
141
 
143
142
  expect(my_producer).to eq(producer)
144
143
  end
145
144
  end
146
145
 
147
- describe '#terminate_producer' do
146
+ describe "#terminate_producer" do
148
147
  before do
149
- subject.producers['topic'] = producer
150
- subject.terminate_producer(topic: 'topic')
148
+ subject.producers["topic"] = producer
149
+ subject.terminate_producer(topic: "topic")
151
150
  end
152
151
 
153
- it 'terminates a producer' do
152
+ it "terminates a producer" do
154
153
  expect(producer).to have_received(:terminate)
155
154
  end
156
155
 
157
- it 'removes the producer from the persisted producers' do
158
- expect(subject.producers.key?('topic')).to be(false)
156
+ it "removes the producer from the persisted producers" do
157
+ expect(subject.producers.key?("topic")).to be(false)
159
158
  end
160
159
  end
161
160
 
162
- describe '#terminate_all_producers' do
163
- let(:producer_2) { double 'FastlyNsq::Producer', write: nil, terminate: :terminated }
161
+ describe "#terminate_all_producers" do
162
+ let(:producer_2) { double "FastlyNsq::Producer", write: nil, terminate: :terminated }
164
163
 
165
- it 'terminates all the producers and resets the hash or producers' do
166
- subject.producers['topic'] = producer
167
- subject.producers['topic_2'] = producer_2
164
+ it "terminates all the producers and resets the hash or producers" do
165
+ subject.producers["topic"] = producer
166
+ subject.producers["topic_2"] = producer_2
168
167
 
169
168
  subject.terminate_all_producers
170
169
 
data/spec/new_relic.rb CHANGED
@@ -1,29 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe FastlyNsq::NewRelic do
6
- let(:agent) { double 'NewRelic::Agent', notice_error: true }
6
+ let(:agent) { double "NewRelic::Agent", notice_error: true }
7
7
  let(:tracer) { FastlyNsq::NewRelic.new(agent) }
8
8
 
9
- describe '#enabled?' do
10
- it 'returns false unless NewRelic is loaded' do
11
- allow(Object).to receive(:const_defined?).with('NewRelic').and_return(false)
9
+ describe "#enabled?" do
10
+ it "returns false unless NewRelic is loaded" do
11
+ allow(Object).to receive(:const_defined?).with("NewRelic").and_return(false)
12
12
  expect(tracer.enabled?).to be false
13
13
  end
14
14
 
15
- it 'returns true id NewRelic is loaded' do
15
+ it "returns true id NewRelic is loaded" do
16
16
  expect(tracer.enabled?).to be true
17
17
  end
18
18
  end
19
19
 
20
- context 'enabled' do
20
+ context "enabled" do
21
21
  before do
22
- allow(Object).to receive(:const_defined?).with('NewRelic').and_return(true)
22
+ allow(Object).to receive(:const_defined?).with("NewRelic").and_return(true)
23
23
  end
24
24
 
25
- describe '#notice_error' do
26
- it 'call agent.notice_error' do
25
+ describe "#notice_error" do
26
+ it "call agent.notice_error" do
27
27
  ex = Exception.new
28
28
 
29
29
  tracer.notice_error(ex)
@@ -31,34 +31,34 @@ RSpec.describe FastlyNsq::NewRelic do
31
31
  end
32
32
  end
33
33
 
34
- describe '#trace_with_newrelic' do
35
- it 'calls perform_action_with_newrelic_trace and yields' do
34
+ describe "#trace_with_newrelic" do
35
+ it "calls perform_action_with_newrelic_trace and yields" do
36
36
  allow(tracer).to receive(:perform_action_with_newrelic_trace).and_yield
37
37
 
38
38
  expect { |b| tracer.trace_with_newrelic({}, &b) }.to yield_control
39
39
  expect(tracer).to have_received(:perform_action_with_newrelic_trace)
40
40
  end
41
41
 
42
- it 'calls perform_action_with_newrelic_trace with trace_args' do
43
- params = { id: 1, vp: 'joe biden' }
42
+ it "calls perform_action_with_newrelic_trace with trace_args" do
43
+ params = {id: 1, vp: "joe biden"}
44
44
 
45
45
  expected = {
46
- name: 'call',
46
+ name: "call",
47
47
  category: FastlyNsq::NewRelic::CATEGORY,
48
48
  params: params,
49
- class_name: 'SomeClass',
49
+ class_name: "SomeClass"
50
50
  }
51
51
 
52
52
  allow(tracer).to receive(:perform_action_with_newrelic_trace).and_yield
53
- expect { |b| tracer.trace_with_newrelic(params: params, class_name: 'SomeClass', &b) }.to yield_control
53
+ expect { |b| tracer.trace_with_newrelic(params: params, class_name: "SomeClass", &b) }.to yield_control
54
54
 
55
55
  expect(tracer).to have_received(:perform_action_with_newrelic_trace).with(expected)
56
56
  end
57
57
 
58
- it 'always sends the default trace args' do
58
+ it "always sends the default trace args" do
59
59
  expected = {
60
- name: 'call',
61
- category: FastlyNsq::NewRelic::CATEGORY,
60
+ name: "call",
61
+ category: FastlyNsq::NewRelic::CATEGORY
62
62
  }
63
63
  allow(tracer).to receive(:perform_action_with_newrelic_trace).and_yield
64
64
 
@@ -69,19 +69,19 @@ RSpec.describe FastlyNsq::NewRelic do
69
69
  end
70
70
  end
71
71
 
72
- context 'disabled' do
72
+ context "disabled" do
73
73
  before do
74
- allow(Object).to receive(:const_defined?).with('NewRelic').and_return(false)
74
+ allow(Object).to receive(:const_defined?).with("NewRelic").and_return(false)
75
75
  end
76
76
 
77
- describe '#notice_error' do
78
- it 'returns nil' do
79
- expect(tracer.notice_error('ex')).to be nil
77
+ describe "#notice_error" do
78
+ it "returns nil" do
79
+ expect(tracer.notice_error("ex")).to be nil
80
80
  end
81
81
  end
82
82
 
83
- describe '#trace_with_newrelic' do
84
- it 'yields' do
83
+ describe "#trace_with_newrelic" do
84
+ it "yields" do
85
85
  allow(tracer).to receive(:perform_action_with_newrelic_trace)
86
86
 
87
87
  expect { |b| tracer.trace_with_newrelic({}, &b) }.to yield_control
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe FastlyNsq::PriorityThreadPool do
6
6
  let!(:pool) { described_class.new(max_threads: 1) }
7
7
 
8
8
  after { pool.shutdown || pool.wait_for_termination }
9
9
 
10
- it 'executes work based on supplied priority' do
10
+ it "executes work based on supplied priority" do
11
11
  actual = []
12
12
  count = 10
13
13
  count.times { |i| pool.post(i) { actual << i } }
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe FastlyNsq::Producer do
6
- let!(:topic) { 'fnsq' }
6
+ let!(:topic) { "fnsq" }
7
7
  subject { FastlyNsq::Producer.new(topic: topic) }
8
8
 
9
9
  before { reset_topic(topic) }
@@ -12,86 +12,86 @@ RSpec.describe FastlyNsq::Producer do
12
12
 
13
13
  it { should be_connected }
14
14
 
15
- it 'writes a message' do
16
- subject.write 'foo'
15
+ it "writes a message" do
16
+ subject.write "foo"
17
17
  expect { message_count(topic) }.to eventually(eq(1)).within(5)
18
18
  end
19
19
 
20
- it 'writes multiple messages' do
20
+ it "writes multiple messages" do
21
21
  subject.write %w[foo bar]
22
22
  expect { message_count(topic) }.to eventually(eq(2)).within(5)
23
23
  end
24
24
 
25
- it 'should terminate' do
25
+ it "should terminate" do
26
26
  expect { subject.terminate }.to change(subject, :connected?).to(false)
27
27
  expect(subject.connection).to eq(nil)
28
28
  end
29
29
 
30
- it 'does not write after termination' do
30
+ it "does not write after termination" do
31
31
  subject.terminate
32
- expect { subject.write 'foo' }.to raise_error(FastlyNsq::NotConnectedError)
32
+ expect { subject.write "foo" }.to raise_error(FastlyNsq::NotConnectedError)
33
33
  end
34
34
 
35
- it 'can connect after termination' do
35
+ it "can connect after termination" do
36
36
  subject.terminate
37
37
  expect { subject.connect }.to change(subject, :connected?).to(true)
38
38
  end
39
39
 
40
- it 'raises when connection fails within the specified timeframe' do
40
+ it "raises when connection fails within the specified timeframe" do
41
41
  allow_any_instance_of(Nsq::Producer).to receive(:connected?).and_return(false)
42
- logger = spy('logger')
42
+ logger = spy("logger")
43
43
  expect(logger).to receive(:error).and_return("Producer for #{topic} failed to connect!")
44
44
 
45
- if RUBY_VERSION > '2.4.0'
46
- expect { FastlyNsq::Producer.new(topic: topic, logger: logger, connect_timeout: 0.2) }.
47
- to raise_error(FastlyNsq::ConnectionFailed, match(FastlyNsq.lookupd_http_addresses.inspect))
45
+ if RUBY_VERSION > "2.4.0"
46
+ expect { FastlyNsq::Producer.new(topic: topic, logger: logger, connect_timeout: 0.2) }
47
+ .to raise_error(FastlyNsq::ConnectionFailed, match(FastlyNsq.lookupd_http_addresses.inspect))
48
48
  else
49
- expect { FastlyNsq::Producer.new(topic: topic, logger: logger, connect_timeout: 0.2) }.
50
- to raise_error(FastlyNsq::ConnectionFailed)
49
+ expect { FastlyNsq::Producer.new(topic: topic, logger: logger, connect_timeout: 0.2) }
50
+ .to raise_error(FastlyNsq::ConnectionFailed)
51
51
  end
52
52
  end
53
53
 
54
- describe 'faking', :fake do
54
+ describe "faking", :fake do
55
55
  it { should be_connected }
56
56
 
57
- it 'should terminate' do
57
+ it "should terminate" do
58
58
  expect { subject.terminate }.to change(subject, :connected?).to(false)
59
59
  expect(subject.connection).to eq(nil)
60
60
  end
61
61
 
62
- it 'writes a message' do
63
- expect { subject.write 'foo' }.to change { subject.messages.size }.by(1)
62
+ it "writes a message" do
63
+ expect { subject.write "foo" }.to change { subject.messages.size }.by(1)
64
64
  end
65
65
 
66
- it 'does not write after termination' do
66
+ it "does not write after termination" do
67
67
  subject.terminate
68
- expect { subject.write 'foo' }.to raise_error(FastlyNsq::NotConnectedError)
68
+ expect { subject.write "foo" }.to raise_error(FastlyNsq::NotConnectedError)
69
69
  end
70
70
 
71
- it 'can connect after termination' do
71
+ it "can connect after termination" do
72
72
  subject.terminate
73
73
  expect { subject.connect }.to change(subject, :connected?).to(true)
74
74
  end
75
75
  end
76
76
 
77
- describe 'inline', :inline do
77
+ describe "inline", :inline do
78
78
  it { should be_connected }
79
79
 
80
- it 'should terminate' do
80
+ it "should terminate" do
81
81
  expect { subject.terminate }.to change(subject, :connected?).to(false)
82
82
  expect(subject.connection).to eq(nil)
83
83
  end
84
84
 
85
- it 'writes a message' do
86
- expect { subject.write 'foo' }.to change { subject.messages.size }.by(1)
85
+ it "writes a message" do
86
+ expect { subject.write "foo" }.to change { subject.messages.size }.by(1)
87
87
  end
88
88
 
89
- it 'does not write after termination' do
89
+ it "does not write after termination" do
90
90
  subject.terminate
91
- expect { subject.write 'foo' }.to raise_error(FastlyNsq::NotConnectedError)
91
+ expect { subject.write "foo" }.to raise_error(FastlyNsq::NotConnectedError)
92
92
  end
93
93
 
94
- it 'can connect after termination' do
94
+ it "can connect after termination" do
95
95
  subject.terminate
96
96
  expect { subject.connect }.to change(subject, :connected?).to(true)
97
97
  end
data/spec/spec_helper.rb CHANGED
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dotenv'
3
+ require "dotenv"
4
4
  Dotenv.load
5
5
 
6
- require 'bundler/setup'
6
+ require "bundler/setup"
7
7
 
8
8
  Bundler.require(:development)
9
9
 
10
- require 'fastly_nsq'
11
- require 'fastly_nsq/http'
12
- require 'fastly_nsq/testing'
10
+ require "fastly_nsq"
11
+ require "fastly_nsq/http"
12
+ require "fastly_nsq/testing"
13
13
 
14
- Dir[File.expand_path('../{support,shared,matchers}/**/*.rb', __FILE__)].each { |f| require(f) }
14
+ Dir[File.expand_path("../{support,shared,matchers}/**/*.rb", __FILE__)].sort.each { |f| require(f) }
15
15
 
16
16
  FastlyNsq::Testing.disable!
17
17
 
18
- if ENV['DEBUG']
18
+ if ENV["DEBUG"]
19
19
  Concurrent.use_stdlib_logger(Logger::DEBUG)
20
- FastlyNsq.logger = Logger.new(STDOUT)
20
+ FastlyNsq.logger = Logger.new($stdout)
21
21
  else
22
22
  Concurrent.use_stdlib_logger(Logger::ERROR)
23
- FastlyNsq.logger = Logger.new('/dev/null').tap { |l| l.level = Logger::DEBUG }
23
+ FastlyNsq.logger = Logger.new("/dev/null").tap { |l| l.level = Logger::DEBUG }
24
24
  end
25
25
 
26
26
  RSpec.configure do |config|
@@ -32,15 +32,15 @@ RSpec.configure do |config|
32
32
  mocks.verify_partial_doubles = true
33
33
  end
34
34
 
35
- config.default_formatter = 'progress'
35
+ config.default_formatter = "progress"
36
36
  config.disable_monkey_patching!
37
- config.example_status_persistence_file_path = 'spec/examples.txt'
37
+ config.example_status_persistence_file_path = "spec/examples.txt"
38
38
  config.filter_run :focus
39
39
  config.order = :random
40
40
  config.profile_examples = 1
41
41
  config.run_all_when_everything_filtered = true
42
42
  Kernel.srand config.seed
43
- config.default_formatter = 'doc' if config.files_to_run.one?
43
+ config.default_formatter = "doc" if config.files_to_run.one?
44
44
 
45
45
  config.around(:each, fake: true) do |example|
46
46
  RSpec::Mocks.with_temporary_scope do
data/spec/support/http.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  module SupportHttp
4
4
  def message_count(topic)
5
- topic_stats = JSON.parse(FastlyNsq::Http::Nsqd.stats(topic: topic).body)['topics'].first || {}
6
- topic_stats['message_count']
5
+ topic_stats = JSON.parse(FastlyNsq::Http::Nsqd.stats(topic: topic).body)["topics"].first || {}
6
+ topic_stats["message_count"]
7
7
  end
8
8
 
9
9
  def create_topic(topic)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'webmock/rspec/matchers'
3
+ require "webmock/rspec/matchers"
4
4
 
5
5
  RSpec.configure do |config|
6
6
  config.include WebMock::API, :webmock
data/spec/testing_spec.rb CHANGED
@@ -1,29 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  RSpec.describe FastlyNsq::Testing do
6
- describe '.message' do
7
- it 'returns a FastlyNsq::Message' do
8
- data = { 'foo' => 'bar' }
6
+ describe ".message" do
7
+ it "returns a FastlyNsq::Message" do
8
+ data = {"foo" => "bar"}
9
9
  message = FastlyNsq::Testing.message(data: data)
10
10
 
11
- expect(message.body).to eq('data' => data, 'meta' => nil)
11
+ expect(message.body).to eq("data" => data, "meta" => nil)
12
12
  end
13
13
 
14
- it 'returns a FastlyNsq::Message with meta' do
15
- data = { 'foo' => 'bar' }
16
- meta = 'foo'
14
+ it "returns a FastlyNsq::Message with meta" do
15
+ data = {"foo" => "bar"}
16
+ meta = "foo"
17
17
  message = FastlyNsq::Testing.message(data: data, meta: meta)
18
18
 
19
- expect(message.body).to eq('data' => data, 'meta' => meta)
19
+ expect(message.body).to eq("data" => data, "meta" => meta)
20
20
  end
21
21
 
22
- it 'wraps a FastlyNsq::TestMessage' do
23
- data = 'bar'
22
+ it "wraps a FastlyNsq::TestMessage" do
23
+ data = "bar"
24
24
  message = FastlyNsq::Testing.message(data: data)
25
25
  expect(message.nsq_message).to be_a(FastlyNsq::TestMessage)
26
- expect(message.nsq_message.body).to eq(JSON.dump('data' => data, 'meta' => nil))
26
+ expect(message.nsq_message.body).to eq(JSON.dump("data" => data, "meta" => nil))
27
27
  end
28
28
  end
29
29
  end