dispatch-rider 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +21 -0
  3. data/.rubocop_todo.yml +17 -300
  4. data/Rakefile +2 -1
  5. data/dispatch-rider.gemspec +2 -2
  6. data/lib/dispatch-rider/callbacks/access.rb +2 -0
  7. data/lib/dispatch-rider/callbacks/storage.rb +7 -5
  8. data/lib/dispatch-rider/callbacks/support.rb +2 -0
  9. data/lib/dispatch-rider/callbacks.rb +2 -0
  10. data/lib/dispatch-rider/command.rb +3 -3
  11. data/lib/dispatch-rider/configuration.rb +3 -1
  12. data/lib/dispatch-rider/debug.rb +3 -1
  13. data/lib/dispatch-rider/demultiplexer.rb +17 -19
  14. data/lib/dispatch-rider/dispatcher.rb +2 -0
  15. data/lib/dispatch-rider/error_handlers.rb +3 -1
  16. data/lib/dispatch-rider/errors.rb +2 -0
  17. data/lib/dispatch-rider/handlers/base.rb +12 -10
  18. data/lib/dispatch-rider/handlers/inheritance_tracking.rb +2 -0
  19. data/lib/dispatch-rider/handlers/named_process.rb +2 -0
  20. data/lib/dispatch-rider/handlers.rb +2 -0
  21. data/lib/dispatch-rider/integrations/appsignal.rb +3 -1
  22. data/lib/dispatch-rider/logging/json_formatter.rb +2 -0
  23. data/lib/dispatch-rider/logging/lifecycle_logger.rb +2 -0
  24. data/lib/dispatch-rider/logging/text_formatter.rb +2 -0
  25. data/lib/dispatch-rider/logging/translator/base_translator.rb +2 -0
  26. data/lib/dispatch-rider/logging/translator/complete_translator.rb +2 -0
  27. data/lib/dispatch-rider/logging/translator/error_handler_fail_translator.rb +2 -0
  28. data/lib/dispatch-rider/logging/translator/fail_translator.rb +2 -0
  29. data/lib/dispatch-rider/logging/translator/start_translator.rb +2 -0
  30. data/lib/dispatch-rider/logging/translator/stop_translator.rb +2 -0
  31. data/lib/dispatch-rider/logging/translator/success_translator.rb +2 -0
  32. data/lib/dispatch-rider/logging/translator.rb +2 -0
  33. data/lib/dispatch-rider/logging.rb +2 -0
  34. data/lib/dispatch-rider/message.rb +3 -0
  35. data/lib/dispatch-rider/notification_services/aws_sns.rb +5 -3
  36. data/lib/dispatch-rider/notification_services/base.rb +2 -0
  37. data/lib/dispatch-rider/notification_services/file_system/channel.rb +2 -0
  38. data/lib/dispatch-rider/notification_services/file_system/notifier.rb +2 -0
  39. data/lib/dispatch-rider/notification_services/file_system.rb +3 -1
  40. data/lib/dispatch-rider/notification_services.rb +2 -0
  41. data/lib/dispatch-rider/publisher/base.rb +2 -0
  42. data/lib/dispatch-rider/publisher/configuration/destination.rb +6 -4
  43. data/lib/dispatch-rider/publisher/configuration/notification_service.rb +4 -2
  44. data/lib/dispatch-rider/publisher/configuration.rb +2 -0
  45. data/lib/dispatch-rider/publisher/configuration_reader.rb +2 -0
  46. data/lib/dispatch-rider/publisher/configuration_support.rb +3 -1
  47. data/lib/dispatch-rider/publisher.rb +3 -2
  48. data/lib/dispatch-rider/queue_services/aws_sqs/message_body_extractor.rb +2 -0
  49. data/lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb +6 -4
  50. data/lib/dispatch-rider/queue_services/aws_sqs.rb +5 -2
  51. data/lib/dispatch-rider/queue_services/base.rb +5 -4
  52. data/lib/dispatch-rider/queue_services/file_system/fs_received_message.rb +5 -3
  53. data/lib/dispatch-rider/queue_services/file_system/queue.rb +5 -4
  54. data/lib/dispatch-rider/queue_services/file_system.rb +7 -11
  55. data/lib/dispatch-rider/queue_services/received_message.rb +3 -1
  56. data/lib/dispatch-rider/queue_services/simple.rb +5 -7
  57. data/lib/dispatch-rider/queue_services.rb +2 -0
  58. data/lib/dispatch-rider/registrars/base.rb +5 -5
  59. data/lib/dispatch-rider/registrars/file_system_channel.rb +3 -1
  60. data/lib/dispatch-rider/registrars/handler.rb +3 -1
  61. data/lib/dispatch-rider/registrars/notification_service.rb +2 -0
  62. data/lib/dispatch-rider/registrars/publishing_destination.rb +3 -1
  63. data/lib/dispatch-rider/registrars/queue_service.rb +2 -0
  64. data/lib/dispatch-rider/registrars/sns_channel.rb +3 -1
  65. data/lib/dispatch-rider/registrars.rb +2 -0
  66. data/lib/dispatch-rider/runner.rb +2 -0
  67. data/lib/dispatch-rider/scheduled_job/migration.rb +2 -0
  68. data/lib/dispatch-rider/scheduled_job.rb +3 -3
  69. data/lib/dispatch-rider/subscriber.rb +2 -0
  70. data/lib/dispatch-rider/version.rb +3 -1
  71. data/lib/dispatch-rider.rb +3 -1
  72. data/lib/generators/dispatch_rider/install/install_generator.rb +2 -0
  73. data/lib/generators/dispatch_rider/install/templates/script/dispatch_rider +1 -0
  74. data/lib/generators/dispatch_rider/job/dispatch_job_generator.rb +2 -0
  75. data/spec/factories/messages.rb +4 -1
  76. data/spec/fixtures/handlers/another_test_handler.rb +2 -0
  77. data/spec/fixtures/handlers/test_handler.rb +2 -0
  78. data/spec/integration/logging_spec.rb +2 -0
  79. data/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb +3 -1
  80. data/spec/lib/dispatch-rider/callbacks/access_spec.rb +2 -0
  81. data/spec/lib/dispatch-rider/callbacks/storage_spec.rb +2 -0
  82. data/spec/lib/dispatch-rider/configuration_spec.rb +3 -1
  83. data/spec/lib/dispatch-rider/default_error_handler_spec.rb +2 -0
  84. data/spec/lib/dispatch-rider/demultiplexer_spec.rb +4 -2
  85. data/spec/lib/dispatch-rider/dispatcher_spec.rb +12 -9
  86. data/spec/lib/dispatch-rider/handlers/base_spec.rb +2 -0
  87. data/spec/lib/dispatch-rider/handlers/inheritance_tracking_spec.rb +2 -0
  88. data/spec/lib/dispatch-rider/logging/json_formatter_spec.rb +2 -0
  89. data/spec/lib/dispatch-rider/logging/lifecycle_logger_spec.rb +3 -1
  90. data/spec/lib/dispatch-rider/logging/text_formatter_spec.rb +2 -0
  91. data/spec/lib/dispatch-rider/logging/translator_spec.rb +2 -0
  92. data/spec/lib/dispatch-rider/message_spec.rb +7 -5
  93. data/spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb +2 -0
  94. data/spec/lib/dispatch-rider/notification_services/base_spec.rb +6 -4
  95. data/spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb +2 -0
  96. data/spec/lib/dispatch-rider/notification_services/file_system/notifier_spec.rb +2 -0
  97. data/spec/lib/dispatch-rider/notification_services/file_system_spec.rb +2 -0
  98. data/spec/lib/dispatch-rider/notification_services_spec.rb +2 -0
  99. data/spec/lib/dispatch-rider/publisher/base_spec.rb +2 -0
  100. data/spec/lib/dispatch-rider/publisher/configuration/destination_spec.rb +2 -0
  101. data/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb +2 -0
  102. data/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb +3 -1
  103. data/spec/lib/dispatch-rider/publisher/configuration_spec.rb +3 -1
  104. data/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb +4 -2
  105. data/spec/lib/dispatch-rider/publisher_spec.rb +11 -9
  106. data/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb +11 -4
  107. data/spec/lib/dispatch-rider/queue_services/base_spec.rb +10 -8
  108. data/spec/lib/dispatch-rider/queue_services/file_system_spec.rb +7 -5
  109. data/spec/lib/dispatch-rider/queue_services/received_message_spec.rb +2 -0
  110. data/spec/lib/dispatch-rider/queue_services/simple_spec.rb +6 -4
  111. data/spec/lib/dispatch-rider/registrars/base_spec.rb +4 -2
  112. data/spec/lib/dispatch-rider/registrars/file_system_channel_spec.rb +2 -0
  113. data/spec/lib/dispatch-rider/registrars/handler_spec.rb +2 -0
  114. data/spec/lib/dispatch-rider/registrars/notification_service_spec.rb +2 -0
  115. data/spec/lib/dispatch-rider/registrars/publishing_destination_spec.rb +2 -0
  116. data/spec/lib/dispatch-rider/registrars/queue_service_spec.rb +2 -0
  117. data/spec/lib/dispatch-rider/registrars/sns_channel_spec.rb +2 -0
  118. data/spec/lib/dispatch-rider/registrars_spec.rb +2 -0
  119. data/spec/lib/dispatch-rider/runner_spec.rb +3 -1
  120. data/spec/lib/dispatch-rider/scheduled_job_spec.rb +2 -0
  121. data/spec/lib/dispatch-rider/subscriber_spec.rb +6 -3
  122. data/spec/lib/dispatch-rider_spec.rb +2 -0
  123. data/spec/spec_helper.rb +1 -1
  124. data/spec/support/crashing_handler.rb +2 -0
  125. data/spec/support/integration_support.rb +2 -0
  126. data/spec/support/null_logger.rb +2 -0
  127. data/spec/support/sample_handler.rb +2 -0
  128. metadata +29 -29
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is a rudementary queue service that uses file system instead of
2
4
  # Aws::SQS or SimpleQueue. It addresses SimpleQueue's inability to be used
3
5
  # by only one application instance while avoiding the cost of setting up Aws::SQS.
@@ -8,12 +10,10 @@ module DispatchRider
8
10
  require "dispatch-rider/queue_services/file_system/fs_received_message"
9
11
  class FileSystem < Base
10
12
  def assign_storage(attrs)
11
- begin
12
13
  path = attrs.fetch(:path)
13
14
  Queue.new(path)
14
- rescue IndexError
15
+ rescue IndexError
15
16
  raise RecordInvalid.new(self, ["Path can not be blank"])
16
- end
17
17
  end
18
18
 
19
19
  def insert(item)
@@ -23,7 +23,7 @@ module DispatchRider
23
23
  def raw_head
24
24
  queue.pop
25
25
  end
26
-
26
+
27
27
  def received_message_for(raw_item)
28
28
  FsReceivedMessage.new(construct_message_from(raw_item), raw_item, queue)
29
29
  end
@@ -31,18 +31,14 @@ module DispatchRider
31
31
  def construct_message_from(item)
32
32
  deserialize(item.read)
33
33
  end
34
-
35
- def put_back(item)
36
- queue.put_back(item)
37
- end
34
+
35
+ delegate :put_back, to: :queue
38
36
 
39
37
  def delete(item)
40
38
  queue.remove item
41
39
  end
42
40
 
43
- def size
44
- queue.size
45
- end
41
+ delegate :size, to: :queue
46
42
  end
47
43
  end
48
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'delegate'
2
4
 
3
5
  module DispatchRider
@@ -13,7 +15,7 @@ module DispatchRider
13
15
  end
14
16
 
15
17
  def guid
16
- self.body['guid']
18
+ body['guid']
17
19
  end
18
20
 
19
21
  def extend_timeout(time)
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is a simple implementation of an in memory queue using an array.
2
4
  module DispatchRider
3
5
  module QueueServices
4
6
  class Simple < Base
5
- def assign_storage(attrs)
7
+ def assign_storage(_attrs)
6
8
  []
7
9
  end
8
10
 
@@ -18,13 +20,9 @@ module DispatchRider
18
20
  deserialize(item)
19
21
  end
20
22
 
21
- def delete(item)
22
- queue.delete(item)
23
- end
23
+ delegate :delete, to: :queue
24
24
 
25
- def size
26
- queue.size
27
- end
25
+ delegate :size, to: :queue
28
26
  end
29
27
  end
30
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The namespace that holds the queue services
2
4
  module DispatchRider
3
5
  module QueueServices
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is the base class for the registrars.
2
4
  # It defines the interface that other registrars inherit.
3
5
  # This is an abstract class.
@@ -28,11 +30,9 @@ module DispatchRider
28
30
  end
29
31
 
30
32
  def fetch(name)
31
- begin
32
- store.fetch(name.to_sym)
33
- rescue IndexError
34
- raise NotRegistered, name
35
- end
33
+ store.fetch(name.to_sym)
34
+ rescue IndexError
35
+ raise NotRegistered, name
36
36
  end
37
37
  end
38
38
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is the registrar for FileSystem channels, basically storing paths
2
4
 
3
5
  module DispatchRider
4
6
  module Registrars
5
7
  class FileSystemChannel < Base
6
- def value(name, options = {})
8
+ def value(_name, options = {})
7
9
  File.expand_path(options[:path])
8
10
  end
9
11
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is the registrar for the handlers.
2
4
  module DispatchRider
3
5
  module Registrars
4
6
  class Handler < Base
5
- def value(name, options = {})
7
+ def value(name, _options = {})
6
8
  name.to_s.camelize.constantize
7
9
  end
8
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This registrar handles the registration of various notification services.
2
4
  module DispatchRider
3
5
  module Registrars
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ostruct'
2
4
 
3
5
  module DispatchRider
4
6
  module Registrars
5
7
  class PublishingDestination < Base
6
- def value(name, options = {})
8
+ def value(_name, options = {})
7
9
  ::OpenStruct.new(:service => options[:service], :channel => options[:channel])
8
10
  end
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This si the registrar for queue services.
2
4
  module DispatchRider
3
5
  module Registrars
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is the registrar for the Aws SNS channels.
2
4
  module DispatchRider
3
5
  module Registrars
4
6
  class SnsChannel < Base
5
- def value(name, options = {})
7
+ def value(_name, options = {})
6
8
  "arn:aws:sns:#{options[:region]}:#{options[:account]}:#{options[:topic]}"
7
9
  end
8
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # The namespace that holds the registrars
2
4
  module DispatchRider
3
5
  module Registrars
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DispatchRider
2
4
  class Runner
3
5
  include Callbacks::Support
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DispatchRider
2
4
  module ScheduledJob::Migration
3
5
  def create_scheduled_jobs_table
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_record"
2
4
 
3
5
  # @note: Later this could be pulled out to its own gem and included depending on what ORM the user
@@ -50,9 +52,7 @@ module DispatchRider
50
52
  destroy # once published
51
53
  end
52
54
 
53
- private
54
-
55
- delegate :publisher, to: :"self.class"
55
+ delegate :publisher, to: :'self.class'
56
56
  end
57
57
  end
58
58
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This class takes care of the subscribing side of the messaging system.
2
4
  module DispatchRider
3
5
  class Subscriber
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file specifies the current version of the gem.
2
4
  module DispatchRider
3
- VERSION = '2.1.0'
5
+ VERSION = '2.2.0'
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Top level namespace of the gem
2
4
  require "dispatch-rider/version"
3
5
 
@@ -22,7 +24,7 @@ module DispatchRider
22
24
  def configuration
23
25
  @configuration ||= Configuration.new
24
26
  end
25
- alias_method :config, :configuration
27
+ alias config configuration
26
28
 
27
29
  def clear_configuration!
28
30
  @configuration = nil
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DispatchRider
2
4
  class InstallGenerator < ::Rails::Generators::Base
3
5
  source_root File.expand_path("../templates", __FILE__)
@@ -1,4 +1,5 @@
1
1
  #!env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  raise "this script is meant to be ran from inside of a Rails.root" unless File.exist?("config/environment.rb")
4
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DispatchJob < Rails::Generators::Base
2
4
  class Publisher < Rails::Generators::Base
3
5
  source_root File.expand_path('../templates/publisher', __FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryBot.define do
2
4
  factory :message, class: 'DispatchRider::Message' do
3
5
  subject { 'sample_handler' }
@@ -5,7 +7,8 @@ FactoryBot.define do
5
7
  {
6
8
  'key' => 'value',
7
9
  'guid' => DispatchRider::Debug::PUBLISHER_MESSAGE_GUID,
8
- }}
10
+ }
11
+ }
9
12
  initialize_with { DispatchRider::Message.new(attributes) }
10
13
  end
11
14
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AnotherTestHandler < DispatchRider::Handlers::Base
2
4
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class TestHandler < DispatchRider::Handlers::Base
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe "Logging" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe DispatchRider::AirbrakeErrorHandler do
@@ -12,7 +14,7 @@ describe DispatchRider::AirbrakeErrorHandler do
12
14
  controller: "DispatchRider",
13
15
  action: "TestMessage",
14
16
  parameters: { subject: "TestMessage", body: "foo" },
15
- cgi_data: anything,
17
+ cgi_data: anything
16
18
  ]
17
19
  expect(Airbrake).to receive(:notify).with(*args)
18
20
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Callbacks::Access do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Callbacks::Storage do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Configuration do
@@ -33,7 +35,7 @@ describe DispatchRider::Configuration do
33
35
  end
34
36
 
35
37
  describe "#handlers" do
36
- before :each do
38
+ before do
37
39
  subject.handler_path = "./spec/fixtures/handlers"
38
40
  end
39
41
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe DispatchRider::DefaultErrorHandler do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Demultiplexer, nodb: true do
@@ -7,7 +9,7 @@ describe DispatchRider::Demultiplexer, nodb: true do
7
9
  end
8
10
  end
9
11
 
10
- subject(:demultiplexer) { DispatchRider::Demultiplexer.new(queue, dispatcher, error_handler) }
12
+ subject(:demultiplexer) { described_class.new(queue, dispatcher, error_handler) }
11
13
 
12
14
  let(:dispatcher) do
13
15
  dispatcher = DispatchRider::Dispatcher.new
@@ -62,7 +64,7 @@ describe DispatchRider::Demultiplexer, nodb: true do
62
64
  # THIS ALSO TESTS THAT THE JOB IS NOT RUN MULTIPLE TIMES
63
65
  # IF THIS FAILS, BE CAREFUL NOT TO INTRODUCE BUGS
64
66
  it "should call the correct handler" do
65
- expect_any_instance_of(TestHandler).to receive(:process).with(message.body).at_least(1).times
67
+ expect_any_instance_of(TestHandler).to receive(:process).with(message.body).at_least(:once)
66
68
  demultiplexer_thread.run
67
69
  sleep 0.01 # give it a chance to process the job async before killing the demux
68
70
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Dispatcher, :nodb => true do
@@ -30,16 +32,17 @@ describe DispatchRider::Dispatcher, :nodb => true do
30
32
  before do
31
33
  allow(DispatchRider.config).to receive(:callbacks) { storage }
32
34
  storage.around(:dispatch_message) do |block, message|
33
- begin
34
- dummy.before
35
- dummy.log(message)
36
- block.call
37
- ensure
38
- dummy.after
39
- end
35
+
36
+ dummy.before
37
+ dummy.log(message)
38
+ block.call
39
+ ensure
40
+ dummy.after
41
+
40
42
  end
41
43
  subject.register('handle_something')
42
44
  end
45
+
43
46
  example do
44
47
  expect(dummy).to receive(:before).once
45
48
  expect(dummy).to receive(:after).once
@@ -51,7 +54,7 @@ describe DispatchRider::Dispatcher, :nodb => true do
51
54
  end
52
55
 
53
56
  context "when the handler provided in the message is present" do
54
- before :each do
57
+ before do
55
58
  subject.register('handle_something')
56
59
  end
57
60
 
@@ -63,7 +66,7 @@ describe DispatchRider::Dispatcher, :nodb => true do
63
66
  context "when the handler returns false" do
64
67
  let(:message_subject) { "handler_that_returns_false" }
65
68
 
66
- before :each do
69
+ before do
67
70
  subject.register('handler_that_returns_false')
68
71
  end
69
72
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Handlers::Base do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Handlers::InheritanceTracking do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Logging::JsonFormatter do
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Logging::LifecycleLogger, aggregrate_failures: true do
4
- subject { DispatchRider::Logging::LifecycleLogger }
6
+ subject { described_class }
5
7
 
6
8
  let(:queue) { double :queue }
7
9
  let(:item) { double :item }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Logging::TextFormatter do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Logging::Translator do
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Message do
4
- subject(:message) { DispatchRider::Message.new(subject: 'test', body: 'test_handler') }
6
+ subject(:message) { described_class.new(subject: 'test', body: 'test_handler') }
5
7
 
6
8
  describe "#initialize" do
7
9
  context "when all the required attributes are passed" do
8
10
  context "when the attributes hash has keys as strings" do
9
- subject(:message) { DispatchRider::Message.new('subject' => 'test', 'body' => 'test_handler') }
11
+ subject(:message) { described_class.new('subject' => 'test', 'body' => 'test_handler') }
10
12
 
11
13
  it "should initiate a new message" do
12
14
  expect(message.subject).to eq('test')
@@ -24,7 +26,7 @@ describe DispatchRider::Message do
24
26
 
25
27
  context "when all the required attributes are not passed" do
26
28
  it "should raise an exception" do
27
- expect { DispatchRider::Message.new({}) }.to raise_exception(DispatchRider::RecordInvalid)
29
+ expect { described_class.new({}) }.to raise_exception(DispatchRider::RecordInvalid)
28
30
  end
29
31
  end
30
32
  end
@@ -46,13 +48,13 @@ describe DispatchRider::Message do
46
48
  describe "#==" do
47
49
  context "when 2 messages have the same attribute values" do
48
50
  it "should return true" do
49
- expect(message).to eq(DispatchRider::Message.new(subject: 'test', body: 'test_handler'))
51
+ expect(message).to eq(described_class.new(subject: 'test', body: 'test_handler'))
50
52
  end
51
53
  end
52
54
 
53
55
  context "when 2 messages do not have same attribute values" do
54
56
  it "should return false" do
55
- expect(message).not_to eq(DispatchRider::Message.new(subject: 'random_test', body: 'test_handler'))
57
+ expect(message).not_to eq(described_class.new(subject: 'random_test', body: 'test_handler'))
56
58
  end
57
59
  end
58
60
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::NotificationServices::AwsSns do
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::NotificationServices::Base do
4
6
  subject do
5
- DispatchRider::NotificationServices::Base.new(topics: {})
7
+ described_class.new(topics: {})
6
8
  end
7
9
 
8
10
  let :channel do
@@ -15,7 +17,7 @@ describe DispatchRider::NotificationServices::Base do
15
17
  channel
16
18
  end
17
19
 
18
- before :each do
20
+ before do
19
21
  allow_any_instance_of(described_class).to receive(:notifier_builder).and_return(OpenStruct)
20
22
  channel = DispatchRider::Registrars::SnsChannel
21
23
  allow_any_instance_of(described_class).to receive(:channel_registrar_builder).and_return(channel)
@@ -35,7 +37,7 @@ describe DispatchRider::NotificationServices::Base do
35
37
  end
36
38
 
37
39
  describe "#publish" do
38
- before :each do
40
+ before do
39
41
  subject.register(:foo, account: 123, region: "us-east-1", topic: "PlanOfAttack")
40
42
  subject.notifier.topics['arn:aws:sns:us-east-1:123:PlanOfAttack'] = channel
41
43
  end
@@ -70,7 +72,7 @@ describe DispatchRider::NotificationServices::Base do
70
72
  end
71
73
 
72
74
  describe "#channels" do
73
- before :each do
75
+ before do
74
76
  subject.register(:foo, account: 123, region: "us-east-1", topic: "PlanOfAttack")
75
77
  subject.notifier.topics['arn:aws:sns:us-east-1:123:PlanOfAttack'] = channel
76
78
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::NotificationServices::FileSystem::Channel do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::NotificationServices::FileSystem::Notifier do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::NotificationServices::FileSystem do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::NotificationServices do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Publisher::Base do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Publisher::Configuration::Destination do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Publisher::Configuration::NotificationService do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe DispatchRider::Publisher::ConfigurationReader do
@@ -126,7 +128,7 @@ describe DispatchRider::Publisher::ConfigurationReader do
126
128
 
127
129
  it "should call register_destination with the right parameters" do
128
130
  params = ["out1", :file_system, :foo, "path" => "tmp/test/channel"]
129
- expect(publisher).to receive(:register_destination).exactly(1).times.with(*params)
131
+ expect(publisher).to receive(:register_destination).once.with(*params)
130
132
  subject.load_config(configuration, publisher)
131
133
  end
132
134