hanami-rspec 3.0.0.rc1 → 3.1.0.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52da36692e852f309936a6de50d48b1e39aae141cd0a90dc8c2a1a2905f7024e
4
- data.tar.gz: 203f42d283c278333080bf223b5f51fb8d7510ba37b3b4421e8ac4f81434faec
3
+ metadata.gz: f8221691adbbed288f5aa3a7517b19b7bbae1c743a9bda492ec95e9714df822d
4
+ data.tar.gz: 5da63d897c69088e1ae13d9f4b815647902b7fb0b15981e7e830404fd67c41af
5
5
  SHA512:
6
- metadata.gz: ace50373169fd424ffc76c832d13d04ad6f43388e1e552e09b776ba59e1b2f221b06fefbff60f455678290640f209dc06166975f16538ffc246a28a43a66e60a
7
- data.tar.gz: 9ee94f6821a888afda9d331f6aa896766314d8192787fc16eb1288987af16815eea758682caafbae53af12c3db3bf969609e02c6243ddf241a58f84b70340408
6
+ metadata.gz: 231e1d3020fc85ce46546be0d7d22ca20e9c45aabb0d16d94020bc35e2e8a753c2fa3c0a5baa0c8a9b59aef4482eaf4305ede01c7a329c2341c5525891892e9e
7
+ data.tar.gz: 119042188ee7e3b649af47e80a2fb460f42194db1dcded6c6bcf397b4f4fea439969af3b4e4e043c77c1b18e2d85424f4eb0b8c9884c2afe29e122d58c04ece0
data/CHANGELOG.md CHANGED
@@ -19,7 +19,36 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
19
19
 
20
20
  ### Security
21
21
 
22
- [Unreleased]: https://github.com/hanami/rspec/compare/v3.0.0.rc1...HEAD
22
+ [Unreleased]: https://github.com/hanami/rspec/compare/v3.1.0.rc1...HEAD
23
+
24
+ ## [v3.1.0.rc1] - 2026-11-27
25
+
26
+ ### Changed
27
+
28
+ - Declare the `--skip-tests` option for each `hanami generate` command that hanami-rspec hooks into, using Dry CLI's `Registry#option`. hanami-rspec no longer depends on hanami-cli to declare this option. (@timriley)
29
+
30
+ ### Fixed
31
+
32
+ - Use the app's inflector when generating specs for `hanami generate slice`, so the module name in the generated spec respects the app's custom inflections (such as acronyms). (@timriley)
33
+
34
+ [v3.1.0.rc1]: https://github.com/hanami/rspec/compare/v3.0.0...v3.1.0.rc1
35
+
36
+ ## [v3.0.0] - 2026-06-30
37
+
38
+ ### Added
39
+
40
+ - Activate Dry Monads' RSpec extension in `spec/support/operations.rb`. (@timriley in #48)
41
+ - Generate a starter spec when running `hanami generate operation`. (@timriley in #48)
42
+ - Generate `spec/support/mailers.rb` to reset recorded mail deliveries between examples tagged `:mailers`. Use this tag for the generated mailer tests. (@timriley in #49)
43
+ - Generate a starter spec when running `hanami generate mailer`. (@timriley in #48)
44
+
45
+ ### Changed
46
+
47
+ - Use `prepend_before` for the generated DatabaseCleaner `:db` hook, so it runs before any other `before` hooks that might touch the database. This prevents factory calls in spec-level `before` blocks from running before the test transaction starts and leaking records across tests. (@timriley in #47)
48
+ - Check for presence of hanami-action gem rather than hanami-controller (now retired). (@cllns in #44)
49
+ - Require Ruby 3.3 or newer.
50
+
51
+ [v3.0.0]: https://github.com/hanami/rspec/compare/v2.3.1...v3.0.0
23
52
 
24
53
  ## [v3.0.0.rc1] - 2026-06-16
25
54
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [actions]: https://github.com/hanami/hanami-rspec/actions
4
4
  [chat]: https://discord.gg/naQApPAsZB
5
- [forum]: https://discourse.hanamirb.org
5
+ [forum]: https://discourse.hanakai.org
6
6
  [rubygem]: https://rubygems.org/gems/hanami-rspec
7
7
 
8
8
  # Hanami RSpec [![Gem Version](https://badge.fury.io/rb/hanami-rspec.svg)][rubygem] [![CI Status](https://github.com/hanami/hanami-rspec/workflows/CI/badge.svg)][actions]
data/hanami-rspec.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.required_ruby_version = ">= 3.3"
32
32
 
33
- spec.add_runtime_dependency "hanami-cli", "~> 3.0.0.rc"
33
+ spec.add_runtime_dependency "hanami-cli", "~> 3.1.0.rc"
34
34
  spec.add_runtime_dependency "rspec", "~> 3.12"
35
35
  spec.add_runtime_dependency "rake", "~> 13.0"
36
36
  spec.add_runtime_dependency "zeitwerk", "~> 2.6"
@@ -7,7 +7,7 @@ module Hanami
7
7
  # @api private
8
8
  module Commands
9
9
  class Install < Hanami::CLI::Command
10
- def call(*, **)
10
+ def call
11
11
  append_gemfile
12
12
  append_gitignore
13
13
  copy_dotrspec
@@ -16,6 +16,7 @@ module Hanami
16
16
  copy_support_db
17
17
  copy_support_features
18
18
  copy_support_operations
19
+ copy_support_mailers
19
20
  copy_support_requests
20
21
 
21
22
  generate_request_spec
@@ -88,6 +89,15 @@ module Hanami
88
89
  )
89
90
  end
90
91
 
92
+ def copy_support_mailers
93
+ return unless Hanami.bundled?("hanami-mailer")
94
+
95
+ fs.cp(
96
+ fs.expand_path(fs.join("generators", "support_mailers.rb"), __dir__),
97
+ fs.expand_path(fs.join("spec", "support", "mailers.rb"))
98
+ )
99
+ end
100
+
91
101
  def copy_support_requests
92
102
  fs.cp(
93
103
  fs.expand_path(fs.join("generators", "support_requests.rb"), __dir__),
@@ -104,17 +114,17 @@ module Hanami
104
114
  end
105
115
 
106
116
  module Generate
107
- class Slice < Hanami::CLI::Command
108
- def call(name: nil, **)
117
+ class Slice < Hanami::CLI::Commands::App::Command
118
+ def call(name:)
109
119
  slice = inflector.underscore(Shellwords.shellescape(name))
110
120
 
111
- generator = Generators::Slice.new(fs: fs, inflector: inflector)
121
+ generator = Generators::Slice.new(fs:, inflector:)
112
122
  generator.call(slice)
113
123
  end
114
124
  end
115
125
 
116
126
  class Action < Hanami::CLI::Commands::App::Command
117
- def call(name: nil, slice: nil, skip_tests: false, **)
127
+ def call(name:, slice: nil, skip_tests: false)
118
128
  return if skip_tests
119
129
 
120
130
  slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
@@ -129,19 +139,19 @@ module Hanami
129
139
  end
130
140
 
131
141
  class Part < Hanami::CLI::Commands::App::Command
132
- def call(name: nil, slice: nil, skip_tests: false, **)
142
+ def call(name:, slice: nil, skip_tests: false)
133
143
  return if skip_tests
134
144
 
135
145
  slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
136
146
  name = inflector.underscore(Shellwords.shellescape(name))
137
147
 
138
- generator = Generators::Part.new(fs: fs, inflector: inflector)
148
+ generator = Generators::Part.new(fs:, inflector:)
139
149
  generator.call(app.namespace, slice, name)
140
150
  end
141
151
  end
142
152
 
143
153
  class Operation < Hanami::CLI::Commands::App::Command
144
- def call(name: nil, slice: nil, skip_tests: false, **)
154
+ def call(name:, slice: nil, skip_tests: false)
145
155
  return if skip_tests
146
156
 
147
157
  slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
@@ -156,7 +166,7 @@ module Hanami
156
166
  end
157
167
 
158
168
  class Mailer < Hanami::CLI::Commands::App::Command
159
- def call(name: nil, slice: nil, skip_tests: false, **)
169
+ def call(name:, slice: nil, skip_tests: false)
160
170
  return if skip_tests
161
171
 
162
172
  slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
@@ -37,7 +37,7 @@ module Hanami
37
37
  <<~RUBY
38
38
  # frozen_string_literal: true
39
39
 
40
- RSpec.describe #{class_name} do
40
+ RSpec.describe #{class_name}, :mailers do
41
41
  subject(:mailer) { described_class.new }
42
42
 
43
43
  # Inspect the delivered message to set expectations on its contents:
@@ -10,9 +10,7 @@ RSpec.configure do |config|
10
10
  #
11
11
  # Modify this proc (or any code below) if you only need specific databases cleaned.
12
12
  all_databases = -> {
13
- slices = [Hanami.app] + Hanami.app.slices.with_nested
14
-
15
- slices.each_with_object([]) { |slice, dbs|
13
+ Hanami.app.with_slices.each_with_object([]) { |slice, dbs|
16
14
  next unless slice.key?("db.rom")
17
15
 
18
16
  dbs.concat slice["db.rom"].gateways.values.map(&:connection)
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Reset recorded mail deliveries between examples tagged `:mailers`
4
+ #
5
+ # In the test env, mail is delivered via a shared test delivery method, so recorded deliveries
6
+ # accumulate across examples. Tag any example that sends mail with `:mailers` to start with a clean
7
+ # slate:
8
+ #
9
+ # RSpec.describe Mailers::Welcome, :mailers do
10
+ # # ...
11
+ # end
12
+ RSpec.configure do |config|
13
+ config.prepend_before :each, :mailers do
14
+ Hanami.app.with_slices.each do |slice|
15
+ next unless slice.key?("mailers.delivery_method")
16
+
17
+ slice["mailers.delivery_method"].clear
18
+ end
19
+ end
20
+ end
@@ -5,6 +5,6 @@ module Hanami
5
5
  # The current hanami-rspec version.
6
6
  #
7
7
  # @api public
8
- VERSION = "3.0.0.rc1"
8
+ VERSION = "3.1.0.rc1"
9
9
  end
10
10
  end
data/lib/hanami/rspec.rb CHANGED
@@ -37,18 +37,26 @@ module Hanami
37
37
 
38
38
  if Hanami.bundled?("dry-operation")
39
39
  Hanami::CLI.after "generate operation", Commands::Generate::Operation
40
+ Hanami::CLI.option "generate operation", :skip_tests,
41
+ required: false, type: :flag, default: false, desc: "Skip test generation"
40
42
  end
41
43
 
42
44
  if Hanami.bundled?("hanami-action")
43
45
  Hanami::CLI.after "generate action", Commands::Generate::Action
46
+ Hanami::CLI.option "generate action", :skip_tests,
47
+ required: false, type: :flag, default: false, desc: "Skip test generation"
44
48
  end
45
49
 
46
50
  if Hanami.bundled?("hanami-view")
47
51
  Hanami::CLI.after "generate part", Commands::Generate::Part
52
+ Hanami::CLI.option "generate part", :skip_tests,
53
+ required: false, type: :flag, default: false, desc: "Skip test generation"
48
54
  end
49
55
 
50
56
  if Hanami.bundled?("hanami-mailer")
51
57
  Hanami::CLI.after "generate mailer", Commands::Generate::Mailer
58
+ Hanami::CLI.option "generate mailer", :skip_tests,
59
+ required: false, type: :flag, default: false, desc: "Skip test generation"
52
60
  end
53
61
  end
54
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanakai team
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 3.0.0.rc
18
+ version: 3.1.0.rc
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 3.0.0.rc
25
+ version: 3.1.0.rc
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +104,7 @@ files:
104
104
  - lib/hanami/rspec/generators/support_db.rb
105
105
  - lib/hanami/rspec/generators/support_db_cleaning.rb
106
106
  - lib/hanami/rspec/generators/support_features.rb
107
+ - lib/hanami/rspec/generators/support_mailers.rb
107
108
  - lib/hanami/rspec/generators/support_operations.rb
108
109
  - lib/hanami/rspec/generators/support_requests.rb
109
110
  - lib/hanami/rspec/generators/support_rspec.rb