msgr 1.4.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1d1c4c93abd233370b3175719c7d41902637c1d8cae51223f86f3cd16611da9
4
- data.tar.gz: 432388472168160b0bc1be0ee303656ab0776674d3178ac63f6c375a7395fb6c
3
+ metadata.gz: b69f99b675987fb9acd292af1603a5806167aac39e49a98cd629a18cb03ef8f5
4
+ data.tar.gz: 41c53127e3fb1aee3efa28a107fd5d3b08baf99754582aef2415f6ee227676e0
5
5
  SHA512:
6
- metadata.gz: 11ce36e23b4a499aaaff01e67a1be9a91048e19e9c55cf0487491aef49d3343d1ead2cb854e4c1a1035319e524b764f62c4846e6632bac5fa81da9b7fb125329
7
- data.tar.gz: 62e2a4460070ae90fe264f270cab8852f81d85f177e2fe77e8b730926f88a11dd651506cc1b5ef58fafefa3b23c1ea0889239beacd7ba6b8342d04d65e11e05c
6
+ metadata.gz: 94753aaa39cb6be26a78962cd29fe0ad2fe922d117b85718b3a523fff032868f4b0e3ec9ac66d00e60cd0d561a2ba412cdf693c1eb736cf05201881d0e44664e
7
+ data.tar.gz: af7cc8d4e7d0ece9c03c673587797ed9d26412e83e3d96af1b41da872105dced4c7b2ad1a30d4dd95a91d3315b90cc2bb17845dba178fa51f76507665fb62c4a
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: maintenance-cache-clear
3
+ on:
4
+ schedule:
5
+ - cron: "0 0 1 * *"
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ cache-clear:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: easimon/wipe-cache@v2
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: maintenance-workflow-cleanup
3
+ on:
4
+ schedule:
5
+ - cron: "0 0 1 * *"
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ delete-workflow-runs:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: Mattraks/delete-workflow-runs@v2
13
+ with:
14
+ token: ${{ github.token }}
15
+ repository: ${{ github.repository }}
16
+ retain_days: 180
17
+ keep_minimum_runs: 50
@@ -0,0 +1,36 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ rubygems:
10
+ if: github.repository == 'jgraichen/msgr'
11
+ runs-on: ubuntu-24.04
12
+
13
+ permissions:
14
+ contents: write
15
+ id-token: write
16
+
17
+ env:
18
+ BUNDLE_JOBS: 4
19
+ BUNDLE_RETRY: 10
20
+ BUNDLE_WITHOUT: development test
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ruby
28
+ bundler-cache: true
29
+
30
+ - uses: rubygems/release-gem@v1
31
+
32
+ - uses: taiki-e/create-gh-release-action@v1
33
+ with:
34
+ changelog: CHANGELOG.md
35
+ draft: true
36
+ token: ${{ secrets.GITHUB_TOKEN }}
@@ -3,27 +3,30 @@ on: [push]
3
3
  jobs:
4
4
  test:
5
5
  name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}
6
- runs-on: ubuntu-20.04
6
+ runs-on: ubuntu-24.04
7
7
 
8
8
  strategy:
9
9
  matrix:
10
10
  ruby:
11
+ - "3.3"
12
+ - "3.2"
13
+ - "3.1"
11
14
  - "3.0"
12
15
  - "2.7"
13
- - "2.6"
14
- - "2.5"
15
16
  gemfile:
16
- - rails_5.2.gemfile
17
- - rails_6.0.gemfile
18
- - rails_6.1.gemfile
17
+ - rails_7.2.gemfile
18
+ - rails_7.1.gemfile
19
19
  - rails_7.0.gemfile
20
+ - rails_6.1.gemfile
20
21
  exclude:
21
- - ruby: "3.0"
22
- gemfile: rails_5.2.gemfile
23
- - ruby: "2.5"
24
- gemfile: rails_7.0.gemfile
25
- - ruby: "2.6"
26
- gemfile: rails_7.0.gemfile
22
+ - gemfile: rails_7.2.gemfile
23
+ ruby: "3.0"
24
+ - gemfile: rails_7.2.gemfile
25
+ ruby: "2.7"
26
+ - gemfile: rails_7.1.gemfile
27
+ ruby: "3.0"
28
+ - gemfile: rails_7.1.gemfile
29
+ ruby: "2.7"
27
30
  fail-fast: False
28
31
 
29
32
  services:
@@ -59,9 +62,14 @@ jobs:
59
62
  - name: Run integration tests
60
63
  run: bundle exec rspec -Ispec/integration --color spec/integration
61
64
 
65
+ - uses: codecov/codecov-action@v4
66
+ with:
67
+ fail_ci_if_error: true
68
+ token: ${{ secrets.CODECOV_TOKEN }}
69
+
62
70
  rubocop:
63
71
  name: rubocop
64
- runs-on: ubuntu-20.04
72
+ runs-on: ubuntu-24.04
65
73
 
66
74
  env:
67
75
  BUNDLE_JOBS: 4
@@ -72,7 +80,7 @@ jobs:
72
80
  - uses: actions/checkout@master
73
81
  - uses: ruby/setup-ruby@v1
74
82
  with:
75
- ruby-version: 3.0
83
+ ruby-version: "3.3"
76
84
  bundler-cache: true
77
85
 
78
86
  - name: Run rubocop
data/.gitignore CHANGED
@@ -1,29 +1,29 @@
1
- *.gem
2
- *.rbc
1
+ _yardoc
3
2
  .bundle
4
3
  .config
4
+ .idea
5
+ .rbx
6
+ .rspec
5
7
  .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
8
+ *.gem
9
+ *.iml
10
+ *.lock
11
+ *.log
12
+ *.rbc
9
13
  coverage
10
14
  doc/
15
+ InstalledFiles
11
16
  lib/bundler/man
12
17
  pkg
18
+ pmip
13
19
  rdoc
20
+ spec/integration/dummy/.generators
21
+ spec/integration/dummy/.rakeTasks
22
+ spec/integration/dummy/.sass-cache
23
+ spec/integration/dummy/db/*.sqlite3
24
+ spec/integration/dummy/db/*.sqlite3*
25
+ spec/integration/dummy/tmp
14
26
  spec/reports
15
27
  test/tmp
16
28
  test/version_tmp
17
29
  tmp
18
- .idea
19
- pmip
20
- *.iml
21
- .rbx
22
- .rspec
23
- *.log
24
- spec/integration/dummy/db/*.sqlite3
25
- spec/integration/dummy/db/*.sqlite3-journal
26
- spec/integration/dummy/tmp
27
- spec/integration/dummy/.sass-cache
28
- spec/integration/dummy/.generators
29
- spec/integration/dummy/.rakeTasks
data/.markdownlint.yml ADDED
@@ -0,0 +1,22 @@
1
+ # markdownlint config
2
+
3
+ # The CHANGELOG contains duplicated headers by design
4
+ MD024: false
5
+
6
+ # MD013/line-length: disable line length for all. We prefer lines as
7
+ # long as paragraph with in-editor line breaks.
8
+ MD013: false
9
+
10
+ # MD033/no-inline-html: allow often need tags
11
+ MD033:
12
+ allowed_elements:
13
+ - figure
14
+ - figcaption
15
+
16
+ # MD046/code-block-style: code block style conflicting with
17
+ # admonitions...
18
+ MD046: false
19
+
20
+ # MD048/code-fence-style: code fence style
21
+ MD048:
22
+ style: backtick
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  inherit_gem:
2
- my-rubocop: default.yml
2
+ rubocop-config: default.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 2.7
6
6
  SuggestExtensions: False
7
7
  Exclude:
8
8
  - gemfiles/**/*
@@ -0,0 +1 @@
1
+ AMQP
data/Appraisals CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  # vim: ft=ruby
4
4
 
5
- appraise 'rails-5.2' do
6
- gem 'rails', '~> 5.2.0'
7
- end
8
-
9
- appraise 'rails-6.0' do
10
- gem 'rails', '~> 6.0.0'
11
- end
12
-
13
5
  appraise 'rails-6.1' do
14
6
  gem 'rails', '~> 6.1.0'
7
+ gem 'sqlite3', '~> 1.4'
15
8
  end
16
9
 
17
10
  appraise 'rails-7.0' do
18
- gem 'rails', '~> 6.1.0'
11
+ gem 'rails', '~> 7.0.0'
12
+ gem 'sqlite3', '~> 1.4'
13
+ end
14
+
15
+ appraise 'rails-7.1' do
16
+ gem 'rails', '~> 7.1.0'
17
+ gem 'sqlite3', '~> 2.0'
19
18
  end
20
19
 
21
- appraise 'rails-head' do
22
- gem 'rails', git: 'https://github.com/rails/rails', require: 'rails'
20
+ appraise 'rails-7.2' do
21
+ gem 'rails', '~> 7.2.0'
22
+ gem 'sqlite3', '~> 2.0'
23
23
  end
data/CHANGELOG.md CHANGED
@@ -6,6 +6,26 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.6.0] - 2024-10-04
10
+
11
+ ### Added
12
+
13
+ - Support for Ruby 3.3
14
+
15
+ ## [1.5.0] - 2023-08-16
16
+
17
+ ### Added
18
+
19
+ - Support for Ruby 3.1 and 3.2
20
+
21
+ ### Changed
22
+
23
+ - Drop support for Ruby < 2.7
24
+
25
+ ### Fixed
26
+
27
+ - `TestPool#run` passing down keyword arguments
28
+
9
29
  ## [1.4.0] - 2022-01-10
10
30
 
11
31
  ### Added
@@ -48,7 +68,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
48
68
 
49
69
  ### Changed
50
70
 
51
- - Serialize JSON using core JSON instead of MultiJson
71
+ - Serialize JSON using core JSON instead of `MultiJson`
52
72
  - Remove application/text fallback for payload (#25)
53
73
 
54
74
  ## [1.1.0] - 2018-07-25
@@ -88,7 +108,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
108
 
89
109
  ### Changed
90
110
 
91
- - Rework TestPool timeout handling to not account processing time
111
+ - Rework `TestPool` timeout handling to not account processing time
92
112
 
93
113
  ## [0.14.1] - 2016-02-17
94
114
 
@@ -124,7 +144,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
124
144
 
125
145
  ### Added
126
146
 
127
- - Add checkcredentials config option to disable initial connect to rabbitmq
147
+ - Add `checkcredentials` config option to disable initial connect to RabbitMQ
128
148
  server to check the credentials
129
149
 
130
150
  ### Changed
@@ -135,13 +155,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
135
155
 
136
156
  ### Added
137
157
 
138
- - Add nack for messages when an error is rescued by dispatcher
158
+ - Add `#nack` for messages when an error is rescued by dispatcher
139
159
 
140
160
  ## [0.11.0-rc1] - 2014-03-29
141
161
 
142
162
  ### Added
143
163
 
144
- - Add pool_class config to override pool classes used by dispatcher
164
+ - Add `pool_class` config to override pool classes used by dispatcher
145
165
 
146
166
  ## [0.4.1] - 2014-03-18
147
167
 
@@ -153,7 +173,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
153
173
 
154
174
  ### Changed
155
175
 
156
- - Improve railtie and autostart code
176
+ - Improve `Railtie` and autostart code
157
177
 
158
178
  ## 0.4.0 - 0.10.0
159
179
 
@@ -171,7 +191,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
171
191
 
172
192
  ### Fixed
173
193
 
174
- - Fix wrong rails initializer code - was not use the config file
194
+ - Fix wrong Rails initializer code - was not use the config file
175
195
 
176
196
  ## [0.2.0] - 2014-02-21
177
197
 
@@ -179,7 +199,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
179
199
 
180
200
  - Improve rails initializer code
181
201
 
182
- [unreleased]: https://github.com/jgraichen/msgr/compare/v1.4.0...HEAD
202
+ [Unreleased]: https://github.com/jgraichen/msgr/compare/v1.6.0...HEAD
203
+ [1.6.0]: https://github.com/jgraichen/msgr/compare/v1.5.0...v1.6.0
204
+ [1.5.0]: https://github.com/jgraichen/msgr/compare/v1.4.0...v1.5.0
183
205
  [1.4.0]: https://github.com/jgraichen/msgr/compare/v1.3.2...v1.4.0
184
206
  [1.3.2]: https://github.com/jgraichen/msgr/compare/v1.3.1...v1.3.2
185
207
  [1.3.1]: https://github.com/jgraichen/msgr/compare/v1.3.0...v1.3.1
data/Gemfile CHANGED
@@ -3,15 +3,18 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gem 'appraisal'
6
- gem 'coveralls'
7
- gem 'my-rubocop', github: 'jgraichen/my-rubocop', ref: 'v4'
8
6
  gem 'rake'
9
7
  gem 'rake-release', '~> 1.1'
8
+
10
9
  gem 'rspec', '~> 3.0'
11
10
  gem 'rspec-rails'
12
11
 
12
+ gem 'simplecov', require: false
13
+ gem 'simplecov-cobertura', require: false
14
+
15
+ gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v12', require: false
16
+
13
17
  gem 'rails'
14
- gem 'sqlite3'
15
18
 
16
19
  # Specify your gem's dependencies in acfs.gemspec
17
20
  gemspec
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Msgr: _Rails-like Messaging Framework_
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/msgr?logo=rubygems)](https://rubygems.org/gems/msgr)
4
- [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/jgraichen/msgr/test?logo=github)](https://github.com/jgraichen/msgr/actions/workflows/test.yml)
4
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jgraichen/msgr/test.yml?branch=main&logo=github)](https://github.com/jgraichen/msgr/actions/workflows/test.yml)
5
5
  [![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/msgr/master/frames)
6
6
 
7
7
  You know it and you like it. Using Rails you can just declare your routes and
@@ -14,19 +14,25 @@ your routes, create your consumer and watch your app processing messages.
14
14
 
15
15
  Add this line to your application's Gemfile:
16
16
 
17
- gem 'msgr'
17
+ ```ruby
18
+ gem 'msgr', '~> 1.5'
19
+ ```
18
20
 
19
21
  And then execute:
20
22
 
21
- $ bundle
23
+ ```console
24
+ bundle
25
+ ```
22
26
 
23
27
  Or install it yourself as:
24
28
 
25
- $ gem install msgr
29
+ ```console
30
+ gem install msgr
31
+ ```
26
32
 
27
33
  ## Usage
28
34
 
29
- After adding 'msgr' to your gemfile create a `config/rabbitmq.yml` like this:
35
+ After adding 'msgr' to your Gemfile create a `config/rabbitmq.yml` like this:
30
36
 
31
37
  ```yaml
32
38
  common: &common
@@ -3,13 +3,14 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
8
6
  gem "rake"
9
7
  gem "rake-release", "~> 1.1"
10
8
  gem "rspec", "~> 3.0"
11
9
  gem "rspec-rails"
10
+ gem "simplecov", require: false
11
+ gem "simplecov-cobertura", require: false
12
+ gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
12
13
  gem "rails", "~> 6.1.0"
13
- gem "sqlite3"
14
+ gem "sqlite3", "~> 1.4"
14
15
 
15
16
  gemspec path: "../"
@@ -3,13 +3,14 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
8
6
  gem "rake"
9
7
  gem "rake-release", "~> 1.1"
10
8
  gem "rspec", "~> 3.0"
11
9
  gem "rspec-rails"
12
- gem "rails", "~> 6.1.0"
13
- gem "sqlite3"
10
+ gem "simplecov", require: false
11
+ gem "simplecov-cobertura", require: false
12
+ gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
13
+ gem "rails", "~> 7.0.0"
14
+ gem "sqlite3", "~> 1.4"
14
15
 
15
16
  gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rake-release", "~> 1.1"
8
+ gem "rspec", "~> 3.0"
9
+ gem "rspec-rails"
10
+ gem "simplecov", require: false
11
+ gem "simplecov-cobertura", require: false
12
+ gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
13
+ gem "rails", "~> 7.1.0"
14
+ gem "sqlite3", "~> 2.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rake-release", "~> 1.1"
8
+ gem "rspec", "~> 3.0"
9
+ gem "rspec-rails"
10
+ gem "simplecov", require: false
11
+ gem "simplecov-cobertura", require: false
12
+ gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12", require: false
13
+ gem "rails", "~> 7.2.0"
14
+ gem "sqlite3", "~> 2.0"
15
+
16
+ gemspec path: "../"
data/lib/msgr/cli.rb CHANGED
@@ -45,8 +45,8 @@ module Msgr
45
45
  Msgr.client.start
46
46
 
47
47
  # Wait until we receive a signal
48
- readable = IO.select([r])
49
- case readable.first[0].gets.strip
48
+ r.wait_readable
49
+ case r.gets.strip
50
50
  when 'INT', 'TERM' # Safe shutdown
51
51
  Msgr.client.stop
52
52
  else # Error
@@ -87,8 +87,8 @@ module Msgr
87
87
  def bind(routes)
88
88
  if routes.empty?
89
89
  log(:warn) do
90
- "No routes to bound to. Bind will have no effect:\n" \
91
- " #{routes.inspect}"
90
+ "No routes to bound to. Bind will have no effect:\n " \
91
+ "#{routes.inspect}"
92
92
  end
93
93
  else
94
94
  bind_all(routes)
@@ -57,15 +57,15 @@ module Msgr
57
57
 
58
58
  class << self
59
59
  def new(*args)
60
- @instance ||= super(*args) # rubocop:disable Naming/MemoizedInstanceVariableName
60
+ @instance ||= super # rubocop:disable Naming/MemoizedInstanceVariableName
61
61
  end
62
62
 
63
- def run(*args)
64
- new.run(*args)
63
+ def run(**kwargs)
64
+ new.run(**kwargs)
65
65
  end
66
66
 
67
67
  def clear
68
- @instance ? @instance.clear : nil
68
+ @instance&.clear
69
69
  end
70
70
 
71
71
  alias reset clear
data/lib/msgr/version.rb CHANGED
@@ -3,10 +3,10 @@
3
3
  module Msgr
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 4
6
+ MINOR = 6
7
7
  PATCH = 0
8
8
  STAGE = nil
9
- STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
9
+ STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.')
10
10
 
11
11
  def self.to_s
12
12
  STRING
data/msgr.gemspec CHANGED
@@ -21,13 +21,10 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.files = `git ls-files -z`.split("\x0")
23
23
  spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
24
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
24
  spec.require_paths = %w[lib]
26
25
 
27
- spec.required_ruby_version = '>= 2.5'
26
+ spec.required_ruby_version = '>= 2.7'
28
27
 
29
28
  spec.add_dependency 'activesupport'
30
29
  spec.add_dependency 'bunny', '>= 1.4', '< 3.0'
31
-
32
- spec.add_development_dependency 'bundler'
33
30
  end
@@ -1,13 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TestConsumer < ApplicationConsumer
4
+ class << self
5
+ attr_accessor :queue
6
+ end
7
+
4
8
  def index
5
9
  data = {fuubar: 'abc'}
6
10
 
7
- publish data, to: 'local.test.another_action'
11
+ publish(data, to: 'local.test.another_action')
8
12
  end
9
13
 
10
14
  def another_action
11
- puts payload.inspect.to_s
15
+ self.class.queue ||= []
16
+ self.class.queue << payload
12
17
  end
13
18
  end
@@ -3,6 +3,8 @@ common: &common
3
3
 
4
4
  test:
5
5
  <<: *common
6
+ pool_class: Msgr::TestPool
7
+ raise_exceptions: true
6
8
 
7
9
  development:
8
10
  <<: *common
@@ -31,24 +31,23 @@ describe Msgr::Dispatcher do
31
31
  let(:config) { {max: 1} }
32
32
  let(:consumer) { 'DispatcherTestConsumer' }
33
33
  let(:route) do
34
- instance_double('Msgr::Route').tap do |t|
35
- allow(t).to receive(:consumer).and_return consumer
36
- allow(t).to receive(:action).and_return 'index'
34
+ instance_double(Msgr::Route).tap do |t|
35
+ allow(t).to receive_messages(consumer: consumer, action: 'index')
37
36
  end
38
37
  end
39
38
  let(:channel) do
40
- instance_double('Msgr::Channel').tap do |c|
39
+ instance_double(Msgr::Channel).tap do |c|
41
40
  allow(c).to receive(:ack)
42
41
  end
43
42
  end
44
43
  let(:delivery_info) do
45
- instance_double('Bunny::DeliveryInfo').tap do |ti|
44
+ instance_double(Bunny::DeliveryInfo).tap do |ti|
46
45
  allow(ti).to receive(:delivery_tag).and_return(3)
47
46
  end
48
47
  end
49
48
  let(:payload) { {} }
50
49
  let(:metadata) do
51
- instance_double('Bunny::MessageProperties').tap do |metadata|
50
+ instance_double(Bunny::MessageProperties).tap do |metadata|
52
51
  allow(metadata).to receive(:content_type).and_return('text/plain')
53
52
  end
54
53
  end
@@ -4,14 +4,21 @@
4
4
  require 'bundler'
5
5
  Bundler.require :rails, :test
6
6
 
7
- # Coverage
8
- require 'coveralls'
9
- Coveralls.wear! do
7
+ require 'simplecov'
8
+ require 'simplecov-cobertura'
9
+
10
+ SimpleCov.start do
11
+ command_name 'rspec:integration'
10
12
  add_filter 'spec'
13
+
14
+ self.formatters = [
15
+ SimpleCov::Formatter::HTMLFormatter,
16
+ SimpleCov::Formatter::CoberturaFormatter,
17
+ ]
11
18
  end
12
19
 
13
20
  ENV['RAILS_ENV'] ||= 'test'
14
- ENV['RAILS_GROUPS'] = ['rails', ENV['RAILS_GROUPS']].reject(&:nil?).join(',')
21
+ ENV['RAILS_GROUPS'] = ['rails', ENV.fetch('RAILS_GROUPS', nil)].compact.join(',')
15
22
  require File.expand_path('dummy/config/environment', __dir__)
16
23
  require 'rspec/rails'
17
24
 
@@ -19,9 +26,9 @@ require 'rspec/rails'
19
26
  # in spec/support/ and its subdirectories.
20
27
  Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each {|f| require f }
21
28
 
22
- # Checks for pending migrations before tests are run.
23
- # If you are not using ActiveRecord, you can remove this line.
24
- if defined?(ActiveRecord::Migration) && Rails::VERSION::MAJOR >= 4
29
+ if ActiveRecord::Migration.respond_to?(:check_all_pending!)
30
+ ActiveRecord::Migration.check_all_pending!
31
+ else
25
32
  ActiveRecord::Migration.check_pending!
26
33
  end
27
34
 
@@ -47,7 +54,9 @@ RSpec.configure do |config|
47
54
  c.syntax = :expect
48
55
  end
49
56
 
50
- config.before do
51
- Msgr.logger = false
57
+ config.after do
58
+ # Flush the consumer queue
59
+ Msgr.client.stop delete: true
60
+ Msgr::TestPool.reset
52
61
  end
53
62
  end
@@ -2,8 +2,16 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe TestController, type: :request do
5
+ describe TestController, type: :controller do
6
+ before do
7
+ Msgr.client.start
8
+ end
9
+
6
10
  it 'sends messages on :index' do
7
- get '/'
11
+ get :index
12
+
13
+ Msgr::TestPool.run(count: 2)
14
+
15
+ expect(TestConsumer.queue).to eq [{fuubar: 'abc'}]
8
16
  end
9
17
  end
@@ -61,8 +61,8 @@ describe Msgr::Client do
61
61
  subject(:drain) { client.drain }
62
62
 
63
63
  let(:config) { {routing_file: 'spec/fixtures/msgr_routes_test_drain.rb'} }
64
- let(:channel_stub) { instance_double('Msgr::Channel', prefetch: true) }
65
- let(:queue_stub) { instance_double('Bunny::Queue', purge: true) }
64
+ let(:channel_stub) { instance_double(Msgr::Channel, prefetch: true) }
65
+ let(:queue_stub) { instance_double(Bunny::Queue, purge: true) }
66
66
 
67
67
  before do
68
68
  allow(Msgr::Channel).to receive(:new).and_return(channel_stub)
@@ -23,8 +23,8 @@ describe Msgr::Dispatcher do
23
23
 
24
24
  describe 'dispatch' do
25
25
  it 'acks messages automatically if auto_ack is enabled' do
26
- route_db = instance_double('Msgr::Route', consumer: 'MsgrAutoAckConsumer', action: :index)
27
- msg_db = instance_spy('Msgr::Message', route: route_db, acked?: false)
26
+ route_db = instance_double(Msgr::Route, consumer: 'MsgrAutoAckConsumer', action: :index)
27
+ msg_db = instance_spy(Msgr::Message, route: route_db, acked?: false)
28
28
 
29
29
  dispatcher.dispatch(msg_db)
30
30
 
@@ -33,8 +33,8 @@ describe Msgr::Dispatcher do
33
33
  end
34
34
 
35
35
  it 'does not ack messages if auto_ack is disabled' do
36
- route_db = instance_double('Msgr::Route', consumer: 'MsgrManualAckConsumer', action: :index)
37
- msg_db = instance_spy('Msgr::Message', route: route_db, acked?: false)
36
+ route_db = instance_double(Msgr::Route, consumer: 'MsgrManualAckConsumer', action: :index)
37
+ msg_db = instance_spy(Msgr::Message, route: route_db, acked?: false)
38
38
 
39
39
  dispatcher.dispatch(msg_db)
40
40
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Msgr::TestPool do
6
+ let(:pool) { described_class.new }
7
+
8
+ describe '.run' do
9
+ it 'passes through to #run' do
10
+ expect(pool).to receive(:run).with(count: 5) # rubocop:disable RSpec/MessageSpies
11
+ described_class.run(count: 5)
12
+ end
13
+ end
14
+ end
@@ -24,7 +24,7 @@ end
24
24
 
25
25
  describe Msgr do
26
26
  let(:queue) { Queue.new }
27
- let(:client) { Msgr::Client.new size: 1, prefix: SecureRandom.hex(2), uri: ENV['AMQP_SERVER'] }
27
+ let(:client) { Msgr::Client.new size: 1, prefix: SecureRandom.hex(2), uri: ENV.fetch('AMQP_SERVER', nil) }
28
28
 
29
29
  before do
30
30
  client.routes.configure do
@@ -85,7 +85,7 @@ describe Msgr do
85
85
  # Test whether the nacked message gets redelivered. In this case, it was not acked when acknowledging the other message
86
86
  message = Timeout.timeout(4) { queue.pop }
87
87
  expect(message.payload).to eq(messages[0].payload)
88
- expect(message.delivery_info.redelivered).to eq(true)
88
+ expect(message.delivery_info.redelivered).to be(true)
89
89
 
90
90
  expect(Receiver).to have_received(:batch).exactly(3).times
91
91
  end
@@ -4,10 +4,17 @@
4
4
  require 'bundler'
5
5
  Bundler.setup :default, :test
6
6
 
7
- # Coverage
8
- require 'coveralls'
9
- Coveralls.wear! do
7
+ require 'simplecov'
8
+ require 'simplecov-cobertura'
9
+
10
+ SimpleCov.start do
11
+ command_name 'rspec:unit'
10
12
  add_filter 'spec'
13
+
14
+ self.formatters = [
15
+ SimpleCov::Formatter::HTMLFormatter,
16
+ SimpleCov::Formatter::CoberturaFormatter,
17
+ ]
11
18
  end
12
19
 
13
20
  require 'msgr'
@@ -20,8 +27,4 @@ RSpec.configure do |config|
20
27
  # Only allow expect syntax
21
28
  c.syntax = :expect
22
29
  end
23
-
24
- config.before do
25
- Msgr.logger = false
26
- end
27
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,20 +44,6 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '3.0'
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
47
  description: 'Msgr: Rails-like Messaging Framework'
62
48
  email:
63
49
  - jgraichen@altimos.de
@@ -67,9 +53,14 @@ extensions: []
67
53
  extra_rdoc_files: []
68
54
  files:
69
55
  - ".editorconfig"
56
+ - ".github/workflows/maintenance-cache-wipe.yml"
57
+ - ".github/workflows/maintenance-workflow-cleanup.yml"
58
+ - ".github/workflows/release.yml"
70
59
  - ".github/workflows/test.yml"
71
60
  - ".gitignore"
61
+ - ".markdownlint.yml"
72
62
  - ".rubocop.yml"
63
+ - ".vscode/ltex.dictionary.en-US.txt"
73
64
  - Appraisals
74
65
  - CHANGELOG.md
75
66
  - Gemfile
@@ -77,11 +68,10 @@ files:
77
68
  - README.md
78
69
  - Rakefile
79
70
  - bin/msgr
80
- - gemfiles/rails_5.2.gemfile
81
- - gemfiles/rails_6.0.gemfile
82
71
  - gemfiles/rails_6.1.gemfile
83
72
  - gemfiles/rails_7.0.gemfile
84
- - gemfiles/rails_head.gemfile
73
+ - gemfiles/rails_7.1.gemfile
74
+ - gemfiles/rails_7.2.gemfile
85
75
  - lib/msgr.rb
86
76
  - lib/msgr/binding.rb
87
77
  - lib/msgr/channel.rb
@@ -123,7 +113,6 @@ files:
123
113
  - spec/integration/dummy/config/rabbitmq.yml
124
114
  - spec/integration/dummy/config/routes.rb
125
115
  - spec/integration/dummy/config/secrets.yml
126
- - spec/integration/dummy/db/test.sqlite3
127
116
  - spec/integration/dummy/log/.keep
128
117
  - spec/integration/dummy/public/404.html
129
118
  - spec/integration/dummy/public/422.html
@@ -139,6 +128,7 @@ files:
139
128
  - spec/unit/msgr/dispatcher_spec.rb
140
129
  - spec/unit/msgr/route_spec.rb
141
130
  - spec/unit/msgr/routes_spec.rb
131
+ - spec/unit/msgr/test_pool_spec.rb
142
132
  - spec/unit/msgr_spec.rb
143
133
  - spec/unit/spec_helper.rb
144
134
  - spec/unit/support/.keep
@@ -147,7 +137,7 @@ licenses:
147
137
  - MIT
148
138
  metadata:
149
139
  rubygems_mfa_required: 'true'
150
- post_install_message:
140
+ post_install_message:
151
141
  rdoc_options: []
152
142
  require_paths:
153
143
  - lib
@@ -155,55 +145,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
145
  requirements:
156
146
  - - ">="
157
147
  - !ruby/object:Gem::Version
158
- version: '2.5'
148
+ version: '2.7'
159
149
  required_rubygems_version: !ruby/object:Gem::Requirement
160
150
  requirements:
161
151
  - - ">="
162
152
  - !ruby/object:Gem::Version
163
153
  version: '0'
164
154
  requirements: []
165
- rubygems_version: 3.1.6
166
- signing_key:
155
+ rubygems_version: 3.5.16
156
+ signing_key:
167
157
  specification_version: 4
168
158
  summary: 'Msgr: Rails-like Messaging Framework'
169
- test_files:
170
- - spec/fixtures/msgr_routes_test_1.rb
171
- - spec/fixtures/msgr_routes_test_drain.rb
172
- - spec/integration/dummy/Rakefile
173
- - spec/integration/dummy/app/assets/config/manifest.js
174
- - spec/integration/dummy/app/consumers/application_consumer.rb
175
- - spec/integration/dummy/app/consumers/test_consumer.rb
176
- - spec/integration/dummy/app/controllers/application_controller.rb
177
- - spec/integration/dummy/app/controllers/test_controller.rb
178
- - spec/integration/dummy/app/helpers/application_helper.rb
179
- - spec/integration/dummy/bin/bundle
180
- - spec/integration/dummy/bin/rails
181
- - spec/integration/dummy/bin/rake
182
- - spec/integration/dummy/config.ru
183
- - spec/integration/dummy/config/application.rb
184
- - spec/integration/dummy/config/boot.rb
185
- - spec/integration/dummy/config/database.yml
186
- - spec/integration/dummy/config/environment.rb
187
- - spec/integration/dummy/config/msgr.rb
188
- - spec/integration/dummy/config/rabbitmq.yml
189
- - spec/integration/dummy/config/routes.rb
190
- - spec/integration/dummy/config/secrets.yml
191
- - spec/integration/dummy/db/test.sqlite3
192
- - spec/integration/dummy/log/.keep
193
- - spec/integration/dummy/public/404.html
194
- - spec/integration/dummy/public/422.html
195
- - spec/integration/dummy/public/500.html
196
- - spec/integration/dummy/public/favicon.ico
197
- - spec/integration/msgr/dispatcher_spec.rb
198
- - spec/integration/msgr/railtie_spec.rb
199
- - spec/integration/spec_helper.rb
200
- - spec/integration/test_controller_spec.rb
201
- - spec/unit/msgr/client_spec.rb
202
- - spec/unit/msgr/connection_spec.rb
203
- - spec/unit/msgr/consumer_spec.rb
204
- - spec/unit/msgr/dispatcher_spec.rb
205
- - spec/unit/msgr/route_spec.rb
206
- - spec/unit/msgr/routes_spec.rb
207
- - spec/unit/msgr_spec.rb
208
- - spec/unit/spec_helper.rb
209
- - spec/unit/support/.keep
159
+ test_files: []
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
8
- gem "rake"
9
- gem "rake-release", "~> 1.1"
10
- gem "rspec", "~> 3.0"
11
- gem "rspec-rails"
12
- gem "rails", "~> 5.2.0"
13
- gem "sqlite3"
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
8
- gem "rake"
9
- gem "rake-release", "~> 1.1"
10
- gem "rspec", "~> 3.0"
11
- gem "rspec-rails"
12
- gem "rails", "~> 6.0.0"
13
- gem "sqlite3"
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "coveralls"
7
- gem "my-rubocop", github: "jgraichen/my-rubocop", ref: "v3"
8
- gem "rake"
9
- gem "rake-release", "~> 1.1"
10
- gem "rspec", "~> 3.0"
11
- gem "rspec-rails"
12
- gem "rails", git: "https://github.com/rails/rails", require: "rails"
13
- gem "sqlite3"
14
-
15
- gemspec path: "../"
File without changes