message-driver 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -2
  3. data/.rubocop_todo.yml +15 -23
  4. data/.travis.yml +10 -22
  5. data/CHANGELOG.md +9 -0
  6. data/Gemfile +34 -24
  7. data/Guardfile +46 -29
  8. data/LICENSE +1 -1
  9. data/Rakefile +14 -6
  10. data/features/CHANGELOG.md +1 -0
  11. data/features/step_definitions/logging_steps.rb +3 -2
  12. data/features/support/firewall_helper.rb +2 -2
  13. data/features/support/no_error_matcher.rb +1 -1
  14. data/lib/message_driver/adapters/base.rb +115 -11
  15. data/lib/message_driver/adapters/bunny_adapter.rb +58 -46
  16. data/lib/message_driver/adapters/in_memory_adapter.rb +57 -35
  17. data/lib/message_driver/adapters/stomp_adapter.rb +10 -10
  18. data/lib/message_driver/broker.rb +16 -19
  19. data/lib/message_driver/client.rb +3 -7
  20. data/lib/message_driver/destination.rb +4 -4
  21. data/lib/message_driver/message.rb +3 -2
  22. data/lib/message_driver/middleware/block_middleware.rb +1 -1
  23. data/lib/message_driver/subscription.rb +1 -1
  24. data/lib/message_driver/version.rb +1 -1
  25. data/message-driver.gemspec +6 -6
  26. data/spec/integration/bunny/amqp_integration_spec.rb +6 -4
  27. data/spec/integration/bunny/bunny_adapter_spec.rb +1 -3
  28. data/spec/integration/in_memory/in_memory_adapter_spec.rb +46 -6
  29. data/spec/integration/stomp/stomp_adapter_spec.rb +0 -2
  30. data/spec/spec_helper.rb +6 -0
  31. data/spec/support/matchers/override_method_matcher.rb +7 -0
  32. data/spec/support/shared/adapter_examples.rb +3 -0
  33. data/spec/support/shared/client_ack_examples.rb +26 -4
  34. data/spec/support/shared/context_examples.rb +46 -0
  35. data/spec/support/shared/destination_examples.rb +28 -0
  36. data/spec/support/shared/subscription_examples.rb +6 -1
  37. data/spec/support/shared/transaction_examples.rb +35 -4
  38. data/spec/support/test_adapter.rb +19 -0
  39. data/spec/support/utils.rb +1 -5
  40. data/spec/units/message_driver/adapters/base_spec.rb +37 -31
  41. data/spec/units/message_driver/broker_spec.rb +1 -2
  42. data/spec/units/message_driver/client_spec.rb +3 -3
  43. data/spec/units/message_driver/destination_spec.rb +4 -2
  44. data/spec/units/message_driver/message_spec.rb +9 -3
  45. data/test_lib/broker_config.rb +0 -2
  46. data/test_lib/provider/base.rb +2 -6
  47. data/test_lib/provider/rabbitmq.rb +3 -3
  48. metadata +18 -16
  49. data/ci/travis_setup +0 -7
  50. data/features/CHANGELOG.md +0 -102
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb14ebba5623881502473a9a4b06dc0b1d863169
4
- data.tar.gz: ca2251f3c765cdb81ce9fe2b6114bdc2ca45331d
3
+ metadata.gz: d3bcb04e7ce78a6c1fa187b2c3a4c1bdecc74506
4
+ data.tar.gz: 87bde205475a8f149eb6d08b0520b24826316189
5
5
  SHA512:
6
- metadata.gz: 38f17b47d77f1fcdc2136d505a1a86220548ccf3363c354bea932615ddc42a2e9d8d9b15ac0d53c29fbef384cb5be4f5270d902f8e0a88c1855c0be8b0df1c15
7
- data.tar.gz: 3ba7521ab3f5abf49212ab0ff2fe54d0f604e80f265f0c360d66b6575c52af66d3e71e12efedf86477784269d1ed71b2d2e3474994dd7e91694dad3faa47b822
6
+ metadata.gz: e9f602d1836c47357d30d76c7c34e1e75a5ebad910f84fa6871960d4fdefc9913c30d612ae9c4b3d52b84368ef8046164d1bc0a922f62f4f8e965d5d8fabb0a2
7
+ data.tar.gz: cf87a47b64e7fd438c515c4abb5891f6f6c803190d2fa3e7b8e89f3722f20db0be9ef89dd5c14ffc8c85a4c0896945ae4dfcc9ebce1b84e2ea9e0321b04829dd
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  inherit_from: '.rubocop_todo.yml'
2
2
 
3
3
  AllCops:
4
+ TargetRubyVersion: 1.9
4
5
  Include:
5
6
  - 'message-driver.gemspec'
6
7
  - '**/Gemfile'
@@ -10,6 +11,9 @@ AllCops:
10
11
  - 'lib/vendor/**/*.rb'
11
12
  - 'vendor/**/*'
12
13
 
14
+ Bundler/OrderedGems:
15
+ Enabled: false
16
+
13
17
  Metrics/BlockNesting:
14
18
  Max: 4
15
19
 
@@ -19,6 +23,9 @@ Metrics/LineLength:
19
23
  Include:
20
24
  - 'lib/**/*.rb'
21
25
 
26
+ Metrics/ParameterLists:
27
+ Enabled: false
28
+
22
29
  Style/AccessorMethodName:
23
30
  Enabled: false
24
31
 
@@ -32,12 +39,23 @@ Style/FileName:
32
39
  Exclude:
33
40
  - 'lib/message-driver.rb'
34
41
 
42
+ Style/MultilineMethodCallBraceLayout:
43
+ EnforcedStyle: new_line
44
+
35
45
  Style/NumericLiterals:
36
46
  Enabled: false
37
47
 
48
+ Style/OptionalArguments:
49
+ Enabled: false
50
+
51
+ Style/RaiseArgs:
52
+ Enabled: false
53
+
38
54
  Style/RegexpLiteral:
39
- Exclude:
40
- - 'Guardfile'
55
+ EnforcedStyle: slashes
56
+
57
+ Style/RescueModifier:
58
+ Enabled: false
41
59
 
42
60
  Style/TrivialAccessors:
43
61
  ExactNameMatch: true
data/.rubocop_todo.yml CHANGED
@@ -1,14 +1,20 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2014-11-12 20:52:38 -0600 using RuboCop version 0.27.1.
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-12-06 13:04:29 -0600 using RuboCop version 0.46.0.
3
4
  # The point is for the user to remove these configuration records
4
5
  # one by one as the offenses are removed from the code base.
5
6
  # Note that changes in the inspected code, or installation of new
6
7
  # versions of RuboCop, may require this file to be generated again.
7
8
 
8
- # Offense count: 8
9
+ # Offense count: 9
9
10
  Metrics/AbcSize:
10
11
  Enabled: false
11
12
 
13
+ # Offense count: 1
14
+ # Configuration parameters: CountComments.
15
+ Metrics/BlockLength:
16
+ Enabled: false
17
+
12
18
  # Offense count: 2
13
19
  # Configuration parameters: CountComments.
14
20
  Metrics/ClassLength:
@@ -23,30 +29,16 @@ Metrics/CyclomaticComplexity:
23
29
  Metrics/MethodLength:
24
30
  Enabled: false
25
31
 
32
+ # Offense count: 7
33
+ # Configuration parameters: CountComments.
34
+ Metrics/ModuleLength:
35
+ Enabled: false
36
+
26
37
  # Offense count: 3
27
38
  Metrics/PerceivedComplexity:
28
39
  Enabled: false
29
40
 
30
- # Offense count: 10
41
+ # Offense count: 13
31
42
  # Configuration parameters: MinBodyLength.
32
43
  Style/GuardClause:
33
44
  Enabled: false
34
-
35
- # Offense count: 1
36
- Style/ModuleFunction:
37
- Enabled: false
38
-
39
- # Offense count: 1
40
- Style/MultilineBlockChain:
41
- Enabled: false
42
-
43
- # Offense count: 1
44
- # Configuration parameters: EnforcedStyle, SupportedStyles.
45
- Style/RaiseArgs:
46
- Enabled: false
47
-
48
- # Offense count: 3
49
- # Cop supports --auto-correct.
50
- # Configuration parameters: IgnoredMethods.
51
- Style/SymbolProc:
52
- Enabled: false
data/.travis.yml CHANGED
@@ -1,48 +1,36 @@
1
1
  language: ruby
2
- sudo: true
2
+ sudo: required
3
3
  before_install: gem install bundler
4
4
  bundler_args: --without tools darwin
5
5
  services:
6
6
  - rabbitmq
7
7
  before_script:
8
- - ci/travis_setup
8
+ - sudo rabbitmq-plugins enable rabbitmq_stomp
9
9
  script: bundle exec rake ci
10
10
  rvm:
11
+ - 2.3
11
12
  - 2.2
12
13
  - 2.0.0
13
14
  - 1.9.3
14
15
  - jruby-19mode
15
- - 1.9.2
16
16
  - rbx-2
17
17
  env:
18
18
  - ADAPTER=in_memory
19
19
  - ADAPTER=bunny:1.7.0
20
- - ADAPTER=bunny:2.0.1
21
- - ADAPTER=bunny:2.1.0
22
- - ADAPTER=bunny:2.2.0
23
- - ADAPTER=stomp
20
+ - ADAPTER=bunny:2.5.1
21
+ - ADAPTER=bunny:2.6.1
22
+ - ADAPTER=stomp:1.3.1
24
23
  matrix:
25
24
  fast_finish: true
26
25
  allow_failures:
27
26
  - rvm: rbx-2
28
27
  - rvm: jruby-19mode
29
- - rvm: 1.9.2
30
28
  exclude:
31
- - rvm: 1.9.2
32
- env: ADAPTER=bunny:2.0.1
33
29
  - rvm: 1.9.3
34
- env: ADAPTER=bunny:2.0.1
30
+ env: ADAPTER=bunny:2.5.1
35
31
  - rvm: jruby-19mode
36
- env: ADAPTER=bunny:2.0.1
37
- - rvm: 1.9.2
38
- env: ADAPTER=bunny:2.1.0
32
+ env: ADAPTER=bunny:2.5.1
39
33
  - rvm: 1.9.3
40
- env: ADAPTER=bunny:2.1.0
34
+ env: ADAPTER=bunny:2.6.1
41
35
  - rvm: jruby-19mode
42
- env: ADAPTER=bunny:2.1.0
43
- - rvm: 1.9.2
44
- env: ADAPTER=bunny:2.2.0
45
- - rvm: 1.9.3
46
- env: ADAPTER=bunny:2.2.0
47
- - rvm: jruby-19mode
48
- env: ADAPTER=bunny:2.2.0
36
+ env: ADAPTER=bunny:2.6.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 - 2016-12-19
4
+
5
+ * update test gems
6
+ * drop support for ruby 1.9.2
7
+ * test against newer versions of bunny
8
+ * Restructure internal API for adapter contexts to better facilitate instrumentation
9
+ * Make the in_memory adapter actually support multiple subscriptions per destination
10
+ * This is a breaking change if you depended on the old behavior!
11
+
3
12
  ## 0.6.1 - 2016-01-28
4
13
 
5
14
  * fix an issue that prevents gems built under ruby 2.3.0 to be installed
data/Gemfile CHANGED
@@ -7,21 +7,22 @@ platform :rbx do
7
7
  gem 'rubysl'
8
8
  end
9
9
 
10
- gem 'rubocop', platform: [:ruby_20, :ruby_21]
10
+ mri_2plus = [:mri_20, :mri_21, :mri_22, :mri_23]
11
+ ruby_2plus = [:ruby_20, :ruby_21, :ruby_22, :ruby_23]
11
12
 
12
13
  group :tools do
13
- gem 'guard', platform: [:mri_20, :mri_21]
14
- gem 'guard-bundler', platform: [:mri_20, :mri_21]
15
- gem 'guard-rspec', platform: [:mri_20, :mri_21]
16
- gem 'guard-cucumber', platform: [:mri_20, :mri_21]
17
- gem 'guard-rubocop', platform: [:mri_20, :mri_21]
14
+ gem 'guard', platform: mri_2plus
15
+ gem 'guard-bundler', platform: mri_2plus
16
+ gem 'guard-rspec', platform: mri_2plus
17
+ gem 'guard-cucumber', platform: mri_2plus
18
+ gem 'guard-rubocop', platform: mri_2plus
18
19
  gem 'pry'
19
- gem 'pry-byebug', platform: [:mri_20, :mri_21]
20
- gem 'pry-stack_explorer', platform: [:ruby_20, :ruby_21]
20
+ gem 'pry-byebug', platform: mri_2plus
21
+ gem 'pry-stack_explorer', platform: ruby_2plus
21
22
  group :darwin do
22
23
  gem 'ruby_gntp'
23
24
  gem 'rb-fsevent'
24
- gem 'relish'
25
+ gem 'relish', platform: mri_2plus
25
26
  gem 'lunchy'
26
27
  end
27
28
  gem 'yard'
@@ -29,7 +30,18 @@ group :tools do
29
30
  gem 'launchy'
30
31
  end
31
32
 
32
- gem 'thread_safe'
33
+ group :development do
34
+ gem 'thread_safe' # for the in_memory_adapter
35
+
36
+ # coveralls and it's dependencies need some management under ruby 1.9.3
37
+ gem 'coveralls', require: false
38
+ gem 'term-ansicolor', '~> 1.3.0' if RUBY_VERSION == '1.9.3'
39
+ platform :ruby_19 do
40
+ gem 'json', '< 2'
41
+ gem 'addressable', '< 2.5'
42
+ gem 'tins', '~> 1.6.0'
43
+ end
44
+ end
33
45
 
34
46
  require File.expand_path('../test_lib/broker_config', __FILE__)
35
47
 
@@ -37,20 +49,18 @@ adapter = BrokerConfig.current_adapter.to_s
37
49
  version = BrokerConfig.adapter_version
38
50
  provider = BrokerConfig.provider
39
51
 
40
- case adapter
41
- when 'in_memory'
42
- else
43
- case version
44
- when nil
45
- gem adapter
46
- else
47
- gem adapter.to_s, "~> #{version}"
52
+ group :development do
53
+ unless adapter == 'in_memory'
54
+ case version
55
+ when nil
56
+ gem adapter
57
+ else
58
+ gem adapter.to_s, "~> #{version}"
59
+ end
48
60
  end
49
- end
50
61
 
51
- case provider
52
- when :rabbitmq
53
- gem 'rabbitmq_http_api_client'
62
+ case provider
63
+ when :rabbitmq
64
+ gem 'rabbitmq_http_api_client'
65
+ end
54
66
  end
55
-
56
- gem 'coveralls', require: false
data/Guardfile CHANGED
@@ -8,43 +8,60 @@ guard 'bundler' do
8
8
  watch(/^.+\.gemspec/)
9
9
  end
10
10
 
11
- common_rspec_opts = { all_after_pass: true }
12
- unit_spec_opts = common_rspec_opts.merge(spec_paths: ['spec/units'], cmd: 'bundle exec rspec -f doc', run_all: { cmd: 'bundle exec rspec' })
11
+ common_rspec_opts = {
12
+ all_after_pass: false,
13
+ cmd: 'bundle exec rspec -f doc',
14
+ run_all: { cmd: 'bundle exec rspec' }
15
+ }
16
+ unit_spec_opts = common_rspec_opts.merge(
17
+ spec_paths: ['spec/units'],
18
+ results_file: File.join(File.dirname(__FILE__), "tmp/rspec_units_#{BrokerConfig.current_adapter}_guard_result")
19
+ )
13
20
  integration_spec_opts = common_rspec_opts.merge(
14
21
  spec_paths: ["spec/integration/#{BrokerConfig.current_adapter}"],
15
- cmd: 'bundle exec rspec -f doc -t all_adapters',
16
- run_all: { cmd: 'bundle exec rspec -t all_adapters' }
22
+ results_file: File.join(File.dirname(__FILE__), "tmp/rspec_integration_#{BrokerConfig.current_adapter}_guard_result"),
23
+ cmd_additional_args: '-t all_adapters'
17
24
  )
18
25
 
19
- group 'specs' do
20
- guard 'rspec', unit_spec_opts do
21
- watch(%r{^spec/units/.+_spec\.rb$})
22
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/units/#{m[1]}_spec.rb" }
23
- watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
24
- watch('spec/spec_helper.rb') { 'spec' }
26
+ group :tests_and_checks, halt_on_failure: true do
27
+ group 'specs' do
28
+ guard 'rspec', unit_spec_opts do
29
+ watch(%r{^spec/units/.+_spec\.rb$})
30
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/units/#{m[1]}_spec.rb" }
31
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec/units' }
32
+ watch('spec/spec_helper.rb') { 'spec/units' }
33
+ end
25
34
  end
26
- end
27
35
 
28
- group 'integration' do
29
- guard 'rspec', integration_spec_opts do
30
- watch(%r{^spec/integration/.+_spec\.rb$})
31
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/integration/#{m[1]}_spec.rb" }
32
- watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
33
- watch('spec/spec_helper.rb') { 'spec' }
36
+ group 'integration' do
37
+ guard 'rspec', integration_spec_opts do
38
+ watch(%r{^spec/integration/.+_spec\.rb$})
39
+ watch(%r{^lib/message_driver/adapters/(.+)\.rb$}) { |m| "spec/integration/#{BrokerConfig.current_adapter}/#{m[1]}_spec.rb" }
40
+ watch(%r{^spec/support/(.+)\.rb$}) { integration_spec_opts[:spec_paths] }
41
+ watch('spec/spec_helper.rb') { integration_spec_opts[:spec_paths] }
42
+ end
34
43
  end
35
- end
36
44
 
37
- group 'features' do
38
- cucumber_cli = "--no-profile --color --format progress --strict --tag @all_adapters,@#{BrokerConfig.current_adapter} --tag ~@wip"
39
- cucumber_run_all_cli = "#{cucumber_cli} --tag ~@slow"
40
- guard 'cucumber', change_format: 'pretty', all_on_start: false, cli: cucumber_cli, run_all: { cli: cucumber_run_all_cli } do
41
- watch(%r{^features/.+\.feature$})
42
- watch(%r{^features/support/.+$}) { 'features' }
43
- watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
45
+ group 'features' do
46
+ guard('cucumber',
47
+ all_on_start: false,
48
+ cmd: "bundle exec cucumber --no-profile --color --strict --tag @all_adapters,@#{BrokerConfig.current_adapter} --tag ~@wip",
49
+ cmd_additional_args: '--format pretty --tag ~@slow',
50
+ run_all: {
51
+ cmd_additional_args: '--format progress --tag ~@slow'
52
+ }
53
+ ) do
54
+ watch(%r{^features/.+\.feature$})
55
+ watch(%r{^features/support/.+$}) { 'features' }
56
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
57
+ end
44
58
  end
45
- end
46
59
 
47
- guard :rubocop do
48
- watch(/.+\.rb/)
49
- watch(%r{(?:.+/)?\.rubocop(?:_.+)*\.yml$}) { |m| File.dirname(m[0]) }
60
+ guard :rubocop, cli: '-D -E' do
61
+ watch(/.+\.rb$/)
62
+ watch('Gemfile')
63
+ watch('Guardfile')
64
+ watch(/.+\.gemspec$/)
65
+ watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
66
+ end
50
67
  end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013-2015 Matt Campbell
3
+ Copyright (c) 2013-2016 Matt Campbell
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -6,12 +6,12 @@ require 'bundler/gem_tasks'
6
6
  require 'rspec/core/rake_task'
7
7
  require 'cucumber/rake/task'
8
8
 
9
- require 'coveralls/rake/task'
10
-
11
9
  begin
12
10
  require 'rubocop/rake_task'
13
11
  RuboCop::RakeTask.new do |t|
14
12
  t.fail_on_error = false
13
+ t.options << '-D'
14
+ t.options << '-E'
15
15
  end
16
16
  rescue LoadError
17
17
  puts 'rubocop not present'
@@ -31,7 +31,7 @@ namespace :spec do
31
31
  end
32
32
 
33
33
  cucumber_opts = "--format progress --tag @all_adapters,@#{BrokerConfig.current_adapter} --tag ~@wip"
34
- cucumber_opts += ' --tag ~@no_ci' #if ENV['CI'] == 'true' && ENV['ADAPTER'] && ENV['ADAPTER'].start_with?('bunny')
34
+ cucumber_opts += ' --tag ~@no_ci' # if ENV['CI'] == 'true' && ENV['ADAPTER'] && ENV['ADAPTER'].start_with?('bunny')
35
35
  Cucumber::Rake::Task.new(:features) do |t|
36
36
  t.cucumber_opts = cucumber_opts
37
37
  end
@@ -48,7 +48,6 @@ begin
48
48
 
49
49
  YARD::Rake::YardocTask.new(:docs)
50
50
  namespace :docs do
51
-
52
51
  desc 'open the documentation for this gem in your browser'
53
52
  task open: [:docs] do
54
53
  Launchy.open("file:///#{File.join(Dir.pwd, 'doc', 'index.html')}")
@@ -74,8 +73,17 @@ def set_adapter_under_test(adapter)
74
73
  system "echo #{adapter} > #{File.join(File.dirname(__FILE__), '.adapter_under_test')}"
75
74
  end
76
75
 
77
- Coveralls::RakeTask.new
78
- desc 'run with code coverage'
76
+ begin
77
+ require 'coveralls/rake/task'
78
+ Coveralls::RakeTask.new
79
+ desc 'run with code coverage'
80
+ rescue LoadError
81
+ puts "couldn't load coveralls gems, code coverage tasks not available"
82
+ namespace :coveralls do
83
+ task :push
84
+ end
85
+ end
86
+
79
87
  task ci: ['spec', 'coveralls:push']
80
88
 
81
89
  namespace :undertest do
@@ -0,0 +1 @@
1
+ ../CHANGELOG.md
@@ -1,6 +1,6 @@
1
1
  require 'logger'
2
2
 
3
- LOG_FILE_NAME = 'cucumber_log_file.log'
3
+ LOG_FILE_NAME = 'cucumber_log_file.log'.freeze
4
4
 
5
5
  Given(/^I am logging to a log file(?: at the (#{STRING_OR_SYM}) level)?$/) do |level|
6
6
  step "an empty file named \"#{LOG_FILE_NAME}\""
@@ -8,7 +8,8 @@ Given(/^I am logging to a log file(?: at the (#{STRING_OR_SYM}) level)?$/) do |l
8
8
  @logger = Logger.new(LOG_FILE_NAME)
9
9
  end
10
10
  step "I set the log level to #{level || 'info'}"
11
- @orig_logger, MessageDriver.logger = MessageDriver.logger, @logger
11
+ @orig_logger = MessageDriver.logger
12
+ MessageDriver.logger = @logger
12
13
  end
13
14
 
14
15
  Given(/^I set the log level to (#{STRING_OR_SYM})$/) do |level|