abstract_notifier 0.3.1 → 0.3.2

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: 03f0a4930f3a771cd4c4ba112ea3dfb0ad5df8da51d2a355c5588aa4d4d164f7
4
- data.tar.gz: cac11a3dc5d86a394ae114aab6b4f751b028e0e582f344611061ebb50903374a
3
+ metadata.gz: 13fab6c214c70888c9977a9e924d3ede95c09de3b9f0207285967af0c20a5db2
4
+ data.tar.gz: 922c76000a77862e8a3cbf1fe5d6dad49656f39fd8ad8df30cbcc6b0ea705a6a
5
5
  SHA512:
6
- metadata.gz: bd0fb71fa422dfaa8309294eff7593561af5d0dde3a45fba0345c1642ae6418f269e5d8d409bfbffafd967897506be2d6aa5990329041ca8d131ea7cf77ede43
7
- data.tar.gz: 83c389be95c2d1ee64f5dc1645d80992f08b7ed03a382407c9f869d1cbd079cb4823d4c2924451131d55578d7382dfaaa93131ec52771b303959e9a2b2e15d0d
6
+ metadata.gz: d58c62166442f76b74b077d85219eb853b83a8453b8e7da9e465e7e6b3217c10f78c1f1bf6a7ce6e7c50d8a12d4274e3fd7fccb592e26ca8d2206b1da0c13437
7
+ data.tar.gz: 37b900f7210fcee8f5201658f6a2ec42e5e81eec289cd5a60537df71b945f9b5d293304b75f70ce2a64fd4e56ce69a5bb03bccd8bcb674b07b1afac082c32e8e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.3.2 (2022-06-02)
6
+
7
+ - Added Minitest assertions. ([@komagata][])
8
+
5
9
  ## 0.3.1 (2020-04-09)
6
10
 
7
11
  - Fix loading testing utils. ([@brovikov][])
@@ -25,3 +29,4 @@ Initial version.
25
29
 
26
30
  [@palkan]: https://github.com/palkan
27
31
  [@brovikov]: https://github.com/brovikov
32
+ [@komagata]: https://github.com/komagata
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/abstract_notifier.svg)](https://badge.fury.io/rb/abstract_notifier)
2
- [![Build Status](https://travis-ci.org/palkan/abstract_notifier.svg?branch=master)](https://travis-ci.org/palkan/abstract_notifier)
2
+ [![Build](https://github.com/palkan/abstract_notifier/workflows/Build/badge.svg)](https://github.com/palkan/abstract_notifier/actions)
3
3
 
4
4
  # Abstract Notifier
5
5
 
@@ -22,7 +22,7 @@ Requirements:
22
22
  Add this line to your application's Gemfile:
23
23
 
24
24
  ```ruby
25
- gem 'abstract_notifier'
25
+ gem "abstract_notifier"
26
26
  ```
27
27
 
28
28
  And then execute:
@@ -105,10 +105,9 @@ You can also specify a block or a method name as the default params _generator_.
105
105
  This could be useful in combination with the `#notification_name` method to generate dynamic payloads:
106
106
 
107
107
  ```ruby
108
- class ApplicationNotifier < AbstractNofitier::Base
108
+ class ApplicationNotifier < AbstractNotifier::Base
109
109
  default :build_defaults_from_locale
110
110
 
111
-
112
111
  private
113
112
 
114
113
  def build_defaults_from_locale
@@ -161,7 +160,6 @@ For test/development purposes there are two special _global_ delivery modes:
161
160
  # config/environments/test.rb
162
161
  AbstractNotifier.delivery_mode = :test
163
162
 
164
-
165
163
  # If you don't want to trigger notifications in development,
166
164
  # you can make Abstract Notifier no-op.
167
165
  #
@@ -183,14 +181,34 @@ Abstract Notifier provides two convinient RSpec matchers:
183
181
 
184
182
  ```ruby
185
183
  # for testing sync notifications (sent with `notify_now`)
186
- expect { EventsNotifier.with(profile: profile).canceled(event).notify_now }.
187
- to have_sent_notification(identify: '123', body: 'Alarma!')
184
+ expect { EventsNotifier.with(profile: profile).canceled(event).notify_now }
185
+ .to have_sent_notification(identify: "123", body: "Alarma!")
188
186
 
189
187
  # for testing async notifications (sent with `notify_later`)
190
- expect { EventsNotifier.with(profile: profile).canceled(event).notify_later}.
191
- to have_enqueued_notification(identify: '123', body: 'Alarma!')
188
+ expect { EventsNotifier.with(profile: profile).canceled(event).notify_later }
189
+ .to have_enqueued_notification(identify: "123", body: "Alarma!")
192
190
  ```
193
-
191
+
192
+ Abstract Notifier provides two convinient minitest assertions:
193
+
194
+ ```ruby
195
+ require 'abstract_notifier/testing/minitest'
196
+
197
+ class EventsNotifierTestCase < Minitest::Test
198
+ include AbstractNotifier::TestHelper
199
+
200
+ test 'canceled' do
201
+ assert_notifications_sent 1, identify: "123", body: "Alarma!" do
202
+ EventsNotifier.with(profile: profile).canceled(event).notify_now
203
+ end
204
+
205
+ assert_notifications_enqueued 1, identify: "123", body: "Alarma!" do
206
+ EventsNotifier.with(profile: profile).canceled(event).notify_later
207
+ end
208
+ end
209
+ end
210
+ ```
211
+
194
212
  **NOTE:** test mode activated automatically if `RAILS_ENV` or `RACK_ENV` env variable is equal to "test". Otherwise add `require "abstract_notifier/testing/rspec"` to your `spec_helper.rb` / `rails_helper.rb` manually. This is also required if you're using Spring in test environment (e.g. with help of [spring-commands-rspec](https://github.com/jonleighton/spring-commands-rspec)).
195
213
 
196
214
  ## Related projects
@@ -207,7 +225,7 @@ class ApplicationDelivery < ActiveDelivery::Base
207
225
  register_line :notifier, ActiveDelivery::Lines::Notifier,
208
226
  # you may provide a resolver, which infers notifier class
209
227
  # from delivery name (resolver is a callable).
210
- resolver: ->(name) { resolve_somehow(name) }
228
+ resolver: ->(name) { resolve_somehow(name) }
211
229
  end
212
230
  ```
213
231
 
@@ -80,7 +80,7 @@ module AbstractNotifier
80
80
  end
81
81
 
82
82
  def default(method_name = nil, **hargs, &block)
83
- return @defaults_generator = block if block_given?
83
+ return @defaults_generator = block if block
84
84
 
85
85
  return @defaults_generator = proc { send(method_name) } unless method_name.nil?
86
86
 
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AbstractNotifier
4
+ module TestHelper
5
+ def assert_notifications_sent(count, params)
6
+ yield
7
+ assert_equal deliveries.count, count
8
+ count.times do |i|
9
+ delivery = deliveries[0 - i]
10
+ msg = message(msg) { "Expected #{mu_pp(delivery)} to include #{mu_pp(params)}" }
11
+ assert hash_include?(delivery, params), msg
12
+ end
13
+ end
14
+
15
+ def assert_notifications_enqueued(count, params)
16
+ yield
17
+ assert_equal enqueued_deliveries.count, count
18
+ count.times do |i|
19
+ delivery = enqueued_deliveries[0 - i]
20
+ msg = message(msg) { "Expected #{mu_pp(delivery)} to include #{mu_pp(params)}" }
21
+ assert hash_include?(delivery, params), msg
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def deliveries
28
+ AbstractNotifier::Testing::Driver.deliveries
29
+ end
30
+
31
+ def enqueued_deliveries
32
+ AbstractNotifier::Testing::Driver.enqueued_deliveries
33
+ end
34
+
35
+ def hash_include?(haystack, needle)
36
+ needle.all? do |k, v|
37
+ haystack.key?(k) && haystack[k] == v
38
+ end
39
+ end
40
+ end
41
+ end
@@ -46,3 +46,4 @@ end
46
46
  AbstractNotifier::Notification.prepend AbstractNotifier::Testing::Notification
47
47
 
48
48
  require "abstract_notifier/testing/rspec" if defined?(RSpec::Core)
49
+ require "abstract_notifier/testing/minitest" if defined?(Minitest::Assertions)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbstractNotifier
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstract_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_delivery
@@ -42,44 +42,30 @@ dependencies:
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: standard
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 0.2.0
61
+ version: '4.0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 0.2.0
68
+ version: '4.0'
83
69
  description: ActionMailer-like interface for any type of notifications
84
70
  email:
85
71
  - dementiev.vm@gmail.com
@@ -87,27 +73,17 @@ executables: []
87
73
  extensions: []
88
74
  extra_rdoc_files: []
89
75
  files:
90
- - ".gitignore"
91
- - ".rspec"
92
- - ".rubocop.yml"
93
- - ".travis.yml"
94
76
  - CHANGELOG.md
95
- - Gemfile
96
77
  - LICENSE.txt
97
78
  - README.md
98
- - Rakefile
99
- - abstract_notifier.gemspec
100
79
  - bin/console
101
80
  - bin/setup
102
- - gemfiles/activedeliverymaster.gemfile
103
- - gemfiles/rails42.gemfile
104
- - gemfiles/rails52.gemfile
105
- - gemfiles/railsmaster.gemfile
106
81
  - lib/abstract_notifier.rb
107
82
  - lib/abstract_notifier/async_adapters.rb
108
83
  - lib/abstract_notifier/async_adapters/active_job.rb
109
84
  - lib/abstract_notifier/base.rb
110
85
  - lib/abstract_notifier/testing.rb
86
+ - lib/abstract_notifier/testing/minitest.rb
111
87
  - lib/abstract_notifier/testing/rspec.rb
112
88
  - lib/abstract_notifier/version.rb
113
89
  - lib/active_delivery/lines/notifier.rb
@@ -120,7 +96,7 @@ metadata:
120
96
  documentation_uri: http://github.com/palkan/abstract_notifier
121
97
  homepage_uri: http://github.com/palkan/abstract_notifier
122
98
  source_code_uri: http://github.com/palkan/abstract_notifier
123
- post_install_message:
99
+ post_install_message:
124
100
  rdoc_options: []
125
101
  require_paths:
126
102
  - lib
@@ -135,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
111
  - !ruby/object:Gem::Version
136
112
  version: '0'
137
113
  requirements: []
138
- rubygems_version: 3.0.6
139
- signing_key:
114
+ rubygems_version: 3.3.7
115
+ signing_key:
140
116
  specification_version: 4
141
117
  summary: ActionMailer-like interface for any type of notifications
142
118
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
10
- Gemfile.local
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,28 +0,0 @@
1
- require:
2
- - standard/cop/semantic_blocks
3
-
4
- inherit_gem:
5
- standard: config/base.yml
6
-
7
- AllCops:
8
- Exclude:
9
- - 'bin/*'
10
- - 'tmp/**/*'
11
- - 'Gemfile'
12
- - 'node_modules/**/*'
13
- - 'vendor/**/*'
14
- - 'gemfiles/**/*'
15
- DisplayCopNames: true
16
- TargetRubyVersion: 2.5
17
-
18
- Standard/SemanticBlocks:
19
- Enabled: false
20
-
21
- Style/FrozenStringLiteralComment:
22
- Enabled: true
23
-
24
- Style/TrailingCommaInArrayLiteral:
25
- EnforcedStyleForMultiline: no_comma
26
-
27
- Style/TrailingCommaInHashLiteral:
28
- EnforcedStyleForMultiline: no_comma
data/.travis.yml DELETED
@@ -1,35 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
-
5
- notifications:
6
- email: false
7
-
8
- before_install:
9
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
10
- - gem install bundler -v '< 2'
11
-
12
- matrix:
13
- fast_finish: true
14
- include:
15
- - rvm: ruby-head
16
- gemfile: gemfiles/railsmaster.gemfile
17
- - rvm: 2.7
18
- gemfile: Gemfile
19
- - rvm: 2.7
20
- gemfile: gemfiles/activedeliverymaster.gemfile
21
- - rvm: 2.6
22
- gemfile: Gemfile
23
- - rvm: 2.5
24
- gemfile: Gemfile
25
- env:
26
- - NO_RAILS=1
27
- - rvm: 2.5
28
- gemfile: gemfiles/rails52.gemfile
29
- - rvm: 2.5
30
- gemfile: gemfiles/rails42.gemfile
31
- allow_failures:
32
- - rvm: ruby-head
33
- gemfile: gemfiles/railsmaster.gemfile
34
- - rvm: 2.7
35
- gemfile: gemfiles/activedeliverymaster.gemfile
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in abstract_notifier.gemspec
4
- gemspec
5
-
6
- gem "pry-byebug"
7
-
8
- local_gemfile = File.join(__dir__, "Gemfile.local")
9
-
10
- if File.exist?(local_gemfile)
11
- eval(File.read(local_gemfile)) # rubocop:disable Security/Eval
12
- else
13
- gem "rails", "~> 6.0"
14
- end
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- require "rubocop/rake_task"
6
-
7
- RuboCop::RakeTask.new
8
- RSpec::Core::RakeTask.new(:spec)
9
-
10
- task default: [:rubocop, :spec]
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "abstract_notifier/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "abstract_notifier"
9
- spec.version = AbstractNotifier::VERSION
10
- spec.authors = ["Vladimir Dementyev"]
11
- spec.email = ["dementiev.vm@gmail.com"]
12
-
13
- spec.summary = "ActionMailer-like interface for any type of notifications"
14
- spec.description = "ActionMailer-like interface for any type of notifications"
15
- spec.homepage = "https://github.com/palkan/abstract_notifier"
16
- spec.license = "MIT"
17
-
18
- spec.required_ruby_version = ">= 2.4"
19
-
20
- spec.metadata = {
21
- "bug_tracker_uri" => "http://github.com/palkan/abstract_notifier/issues",
22
- "changelog_uri" => "https://github.com/palkan/abstract_notifier/blob/master/CHANGELOG.md",
23
- "documentation_uri" => "http://github.com/palkan/abstract_notifier",
24
- "homepage_uri" => "http://github.com/palkan/abstract_notifier",
25
- "source_code_uri" => "http://github.com/palkan/abstract_notifier"
26
- }
27
-
28
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
- spec.require_paths = ["lib"]
30
-
31
- spec.add_development_dependency "active_delivery"
32
-
33
- spec.add_development_dependency "bundler", ">= 1.16"
34
- spec.add_development_dependency "rake", "~> 13.0"
35
- spec.add_development_dependency "rspec-rails", "~> 3.0"
36
- spec.add_development_dependency "standard", "~> 0.2.0"
37
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 6.0"
6
- gem "active_delivery", github: "palkan/active_delivery"
7
-
8
- gemspec path: ".."
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.2"
6
- gem "bundler", "~> 1.17"
7
-
8
- gemspec path: ".."
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.2"
6
-
7
- gemspec path: ".."
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", github: "rails/rails"
6
- gem "rubocop", github: "rubocop-hq/rubocop"
7
-
8
- gemspec path: ".."