hanami-rspec 2.3.1 → 3.11.0.beta1

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +13 -16
  3. data/.rubocop.yml +0 -2
  4. data/CHANGELOG.md +1 -180
  5. data/Gemfile +5 -5
  6. data/LICENSE.txt +21 -0
  7. data/README.md +17 -7
  8. data/hanami-rspec.gemspec +5 -6
  9. data/lib/hanami/rspec/commands.rb +15 -125
  10. data/lib/hanami/rspec/error.rb +8 -0
  11. data/lib/hanami/rspec/generators/gemfile +0 -2
  12. data/lib/hanami/rspec/generators/helper.rb +2 -1
  13. data/lib/hanami/rspec/generators/request.rb +4 -4
  14. data/lib/hanami/rspec/generators/slice/action_spec.erb +3 -2
  15. data/lib/hanami/rspec/generators/slice/repository_spec.erb +1 -1
  16. data/lib/hanami/rspec/generators/slice/view_spec.erb +1 -1
  17. data/lib/hanami/rspec/generators/slice.rb +13 -23
  18. data/lib/hanami/rspec/generators/support_requests.rb +2 -3
  19. data/lib/hanami/rspec/generators/support_rspec.rb +2 -36
  20. data/lib/hanami/rspec/generators.rb +9 -0
  21. data/lib/hanami/rspec/rake_tasks.rb +2 -0
  22. data/lib/hanami/rspec/version.rb +1 -5
  23. data/lib/hanami/rspec.rb +2 -39
  24. data/lib/hanami-rspec.rb +1 -1
  25. metadata +18 -39
  26. data/LICENSE.md +0 -22
  27. data/lib/hanami/rspec/generators/action.rb +0 -60
  28. data/lib/hanami/rspec/generators/gemfile_db +0 -9
  29. data/lib/hanami/rspec/generators/gitignore +0 -1
  30. data/lib/hanami/rspec/generators/part/part_base_spec.erb +0 -10
  31. data/lib/hanami/rspec/generators/part/part_slice_base_spec.erb +0 -10
  32. data/lib/hanami/rspec/generators/part/part_slice_spec.erb +0 -10
  33. data/lib/hanami/rspec/generators/part/part_spec.erb +0 -10
  34. data/lib/hanami/rspec/generators/part.rb +0 -114
  35. data/lib/hanami/rspec/generators/support_db.rb +0 -10
  36. data/lib/hanami/rspec/generators/support_db_cleaning.rb +0 -42
  37. data/lib/hanami/rspec/generators/support_features.rb +0 -5
  38. data/lib/hanami/rspec/generators/support_operations.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a2185e39d0b525de7f16d338057a0e2f87b1b2537663c63f0d0f2f9ddc09741
4
- data.tar.gz: 691c5b210355c983af3a879dca1cf69cfbb6197b6c7151a76d37d78b002748c4
3
+ metadata.gz: bb274d263b143f47cda8bf26d3e064125d57dea50a5be98b0b5182e6a952d186
4
+ data.tar.gz: e98375c2ef0d2974a1982989694e5873377bb1b5cafccf159477e5e90e963657
5
5
  SHA512:
6
- metadata.gz: 79f9422d2a433e90b9b4cf0bc2a8e963c12869004aeac391425c1f23413d5b3c78f04683ba5bd44f10ec74a74c31a9ae99c7fee7f5c96c2e377efbe665b822eb
7
- data.tar.gz: 146c5ee5983d235ddd02a8263d74c67c13acf8e1f58e491c9c068ee0383f6e56e3e7972de2ba47ada5db3b5bca2f1e8cce00e8d11c4dfbb04b43dfa12a6974ac
6
+ metadata.gz: 89e4a5322a0f7bafd4c8abbfd94f8edaf0e7f9ff617ac65f543ce8d2232dbdc40c33618ca3061f93b092359a0c83ea29c42039b9c64976bb6e810dceac7813fe
7
+ data.tar.gz: 8049790bcf4437f5363c94af6d41a58be5b90a5c02cea61c4f6b274180f6559a00b1271a7d566b8ef6a52c36c6304c2c24f9c9c7e25d9abdc95b360a48a56d40
@@ -1,11 +1,19 @@
1
1
  name: ci
2
2
 
3
- on:
3
+ 'on':
4
4
  push:
5
+ paths:
6
+ - '.github/workflows/ci.yml'
7
+ - 'lib/**'
8
+ - '*.gemspec'
9
+ - 'spec/**'
10
+ - 'Rakefile'
11
+ - 'Gemfile'
12
+ - '.rubocop.yml'
5
13
  pull_request:
14
+ branches:
15
+ - master
6
16
  create:
7
- schedule:
8
- - cron: "30 4 * * *"
9
17
 
10
18
  jobs:
11
19
  tests:
@@ -14,14 +22,11 @@ jobs:
14
22
  fail-fast: false
15
23
  matrix:
16
24
  ruby:
17
- - "4.0"
18
- - "3.4"
19
- - "3.3"
20
- - "3.2"
25
+ - '3.0'
21
26
  steps:
22
27
  - uses: actions/checkout@v1
23
28
  - name: Install package dependencies
24
- run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
29
+ run: '[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS'
25
30
  - name: Set up Ruby
26
31
  uses: ruby/setup-ruby@v1
27
32
  with:
@@ -33,11 +38,3 @@ jobs:
33
38
  run: bundle install --jobs 4 --retry 3
34
39
  - name: Run all tests
35
40
  run: bundle exec rake
36
-
37
- workflow-keepalive:
38
- if: github.event_name == 'schedule'
39
- runs-on: ubuntu-latest
40
- permissions:
41
- actions: write
42
- steps:
43
- - uses: liskin/gh-workflow-keepalive@v1
data/.rubocop.yml CHANGED
@@ -16,8 +16,6 @@ Style/BlockDelimiters:
16
16
  Enabled: false
17
17
  Style/CommentedKeyword:
18
18
  Enabled: false
19
- Style/HashSyntax:
20
- EnforcedShorthandSyntax: either_consistent
21
19
  Style/LambdaCall:
22
20
  Enabled: false
23
21
  Style/TrailingCommaInArguments:
data/CHANGELOG.md CHANGED
@@ -1,184 +1,5 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
- ### Added
11
-
12
- ### Changed
13
-
14
- ### Deprecated
15
-
16
- ### Removed
17
-
18
- ### Fixed
19
-
20
- ### Security
21
-
22
- [Unreleased]: https://github.com/hanami/rspec/compare/v2.3.0...HEAD
23
-
24
- ## [2.3.1] - 2026-01-23
25
-
26
- ### Fixed
27
-
28
- - Allow command callbacks to run with both Dry CLI 1.3 and 1.4 (1.4 corrects a longstanding bug regarding argument passing to command callbacks, which we had previously worked around here). (@timriley in #41)
29
-
30
- ## [2.3.0] - 2025-11-12
31
-
32
- [2.3.0]: https://github.com/hanami/rspec/compare/v2.3.0.beta2...v2.3.0
33
-
34
- ## [2.3.0.beta2] - 2025-10-17
35
-
36
- ### Changed
37
-
38
- - Drop support for Ruby 3.1
39
-
40
- [2.3.0.beta2]: https://github.com/hanami/rspec/compare/v2.3.0.beta1...v2.3.0.beta2
41
-
42
- ## [2.3.0.beta1] - 2025-10-03
43
-
44
- ### Changed
45
-
46
- - [Aaron Allen] Change shared context name in generated `spec/support/requests.rb` to avoid a RuboCop RSpec offense (#40)
47
-
48
- [2.3.0.beta1]: https://github.com/hanami/rspec/compare/v2.2.1...v2.3.0.beta1
49
-
50
- ## [2.2.1] - 2024-11-12
51
-
52
- ### Changed
53
-
54
- - [Tim Riley] Modify `Gemfile` via a `before "install"` hook on the `hanami` CLI. This ensures that testing-related gems are installed as part of running `hanami new` (#30)
55
-
56
- [2.2.1]: https://github.com/hanami/rspec/compare/v2.2.0...v2.2.1
57
-
58
- ## [2.2.0] - 2024-11-05
59
-
60
- ### Changed
61
-
62
- - [Paweł Świątkowski, Seb Wilgosz] Only enhance `generate` CLI commands if the relevant gems are bundled (#29)
63
-
64
- [2.2.0]: https://github.com/hanami/rspec/compare/v2.2.0.rc1...v2.2.0
65
-
66
- ## [2.2.0.rc1] - 2024-10-29
67
-
68
- ### Added
69
-
70
- - [Tim Riley] As part of `hanami install`, add `database_cleaner-sequel` to the `Gemfile` and generate DatabaseCleaner configuration in `spec/support/db.rb` and `spec/support/db/cleaning.rb` (#28)
71
-
72
- ### Changed
73
-
74
- - [Seb Wilgosz] Only enhance `generate` CLI commands if the relevant gems are bundled (#26)
75
-
76
- [2.2.0.rc1]: https://github.com/hanami/rspec/compare/v2.2.0.beta1...v2.2.0.rc1
77
-
78
- ## [2.2.0.beta1] - 2024-07-16
79
-
80
- ### Added
81
-
82
- - [Sean Collins] Include `Dry::Monads[:result]` in tests via `support/operations.rb`
83
-
84
- ### Changed
85
-
86
- - Drop support for Ruby 3.0
87
- - [Sean Collins] In generated `spec_helper.rb`, require all files under `spec/support/` in a loop, rather than via manual requires (#24)
88
-
89
- [2.2.0.beta1]: https://github.com/hanami/rspec/compare/v2.1.0...v2.2.0.beta1
90
-
91
- ## [2.1.0] - 2024-02-27
92
-
93
- [2.1.0]: https://github.com/hanami/rspec/compare/v2.1.0.rc3...v2.1.0
94
-
95
- ## [2.1.0.rc3] - 2024-02-16
96
-
97
- [2.1.0.rc3]: https://github.com/hanami/rspec/compare/v2.1.0.rc2...v2.1.0.rc3
98
-
99
- ## [2.1.0.rc2] - 2023-11-08
100
-
101
- ### Added
102
-
103
- - [Tim Riley] Skip generating tests for `hanami generate` when `--skip-tests` CLI option is given
104
- - [Tim Riley] Install Capybara and generate `spec/support/capybara.rb` in `hanami install` hook
105
-
106
- ### Changed
107
-
108
- - [Tim Riley] Add explanatory code comments to `spec/support/rspec.rb` generated in `hanami install` hook
109
-
110
- [2.1.0.rc2]: https://github.com/hanami/rspec/compare/v2.1.0.rc1...v2.1.0.rc2
111
-
112
- ## [2.1.0.rc1] - 2023-11-01
113
-
114
- ### Added
115
-
116
- - [Luca Guidi] Generate spec for `hanami generate part` command
117
-
118
- ### Changed
119
-
120
- - [Luca Guidi] Default request spec to expect 404, now that `hanami new` doesn't generate a default root route anymore
121
-
122
- [2.1.0.rc1]: https://github.com/hanami/rspec/compare/v2.1.0.beta1...v2.1.0.rc1
123
-
124
- ## [2.1.0.beta1] - 2023-06-29
125
-
126
- [2.1.0.beta1]: https://github.com/hanami/rspec/compare/v2.0.1...v2.1.0.beta1
127
-
128
- ## [2.0.1] - 2022-12-25
129
-
130
- ### Added
131
-
132
- - [Luca Guidi] Official support for Ruby 3.2
133
-
134
- [2.0.1]: https://github.com/hanami/rspec/compare/v2.0.0...v2.0.1
135
-
136
- ## [2.0.0] - 2022-11-22
137
-
138
- ### Added
139
-
140
- - [Tim Riley] Use Zeitwerk to autoload the gem
141
- - [Luca Guidi] Support RSpec 3.12
142
-
143
- [2.0.0]: https://github.com/hanami/rspec/compare/v2.0.0.rc1...v2.0.0
144
-
145
- ## [2.0.0.rc1] - 2022-11-08
146
-
147
- ### Changed
148
-
149
- - [Luca Guidi] Follow `hanami` versioning
150
-
151
- [2.0.0.rc1]: https://github.com/hanami/rspec/compare/v3.11.0.beta4...v2.0.0.rc1
152
-
153
- ## [3.11.0.beta4] - 2022-10-24
154
-
155
- ### Changed
156
-
157
- - [Luca Guidi] Generate slice specs under `spec/slices/[slice_name]/` (#9)
158
-
159
- [3.11.0.beta4]: https://github.com/hanami/rspec/compare/v3.11.0.beta3...v3.11.0.beta4
160
-
161
- ## [3.11.0.beta3] - 2022-09-21
162
-
163
- ### Added
164
-
165
- - [Luca Guidi] Hook into `hanami new` and `hanami generate` to respect name pluralization
166
- - [Luca Guidi] Hook into `hanami generate action` to generate action specs
167
-
168
- [3.11.0.beta3]: https://github.com/hanami/rspec/compare/v3.11.0.beta2...v3.11.0.beta3
169
-
170
- ## [3.11.0.beta2] - 2022-08-16
171
-
172
- ### Added
173
-
174
- - [Luca Guidi] Hook into `hanami generate slice` to generate a slice directory in spec/ along with a placeholder base action spec (#5)
175
-
176
- [3.11.0.beta2]: https://github.com/hanami/rspec/compare/v3.11.0.beta1...v3.11.0.beta2
177
-
178
- ## [3.11.0.beta1] - 2022-07-20
1
+ ## v3.11.0.beta1 - 2022-07-20
179
2
 
180
3
  ### Added
181
4
 
182
5
  - [Luca Guidi] Hook into `hanami install` to setup RSpec + Rack::Test
183
-
184
- [3.11.0.beta1]: https://github.com/hanami/rspec/releases/tag/v3.11.0.beta1
data/Gemfile CHANGED
@@ -4,10 +4,10 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  unless ENV["CI"]
7
- gem "byebug", platforms: :mri
8
- gem "yard"
7
+ gem "byebug", require: false, platforms: :mri
8
+ gem "yard", require: false
9
9
  end
10
10
 
11
- gem "hanami-utils", github: "hanami/utils", branch: "main"
12
- gem "hanami-cli", github: "hanami/cli", branch: "main"
13
- gem "hanami", github: "hanami/hanami", branch: "main"
11
+ gem "dry-files", require: false, git: "https://github.com/dry-rb/dry-files.git", branch: "main"
12
+ gem "hanami-cli", require: false, git: "https://github.com/hanami/cli.git", branch: "main"
13
+ gem "hanami", require: false, git: "https://github.com/hanami/hanami.git", branch: "main"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Luca Guidi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,19 +1,29 @@
1
1
  # Hanami::RSpec
2
2
 
3
- RSpec and testing support for [Hanami applications](https://github.com/hanami/hanami).
3
+ RSpec and testing support for [full-stack Hanami applications](`https://github.com/hanami/hanami`).
4
4
 
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/hanami-rspec.svg)](https://badge.fury.io/rb/hanami-rspec)
8
- [![CI](https://github.com/hanami/rspec/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/hanami/rspec/actions?query=workflow%3Aci+branch%3Amain)
8
+ [![CI](https://github.com/hanami/rspec/workflows/ci/badge.svg?branch=main)](https://github.com/hanami/rspec/actions?query=workflow%3Aci+branch%3Amain)
9
+ [![Depfu](https://badges.depfu.com/badges/a8545fb67cf32a2c75b6227bc0821027/overview.svg)](https://depfu.com/github/hanami/rspec?project=Bundler)
10
+
11
+ ## Version
12
+
13
+ Versioning of this gem follows RSpec.
9
14
 
10
15
  ## Contact
11
16
 
12
17
  - Home page: http://hanamirb.org
13
18
  - Mailing List: http://hanamirb.org/mailing-list
14
19
  - Bugs/Issues: https://github.com/hanami/rspec/issues
20
+ - Support: http://stackoverflow.com/questions/tagged/hanami
15
21
  - Chat: http://chat.hanamirb.org
16
22
 
23
+ ## Rubies
24
+
25
+ **Hanami::RSpec** supports Ruby (MRI) 3.0+
26
+
17
27
  ## Installation
18
28
 
19
29
  Add this line to your application's Gemfile:
@@ -26,10 +36,10 @@ end
26
36
 
27
37
  And then execute:
28
38
 
29
- ```
30
- $ bundle install
31
- $ bundle exec hanami setup
32
- ```
39
+ $ bundle install
40
+ $ bundle exec hanami setup
41
+
42
+ ## Usage
33
43
 
34
44
  ## Development
35
45
 
@@ -51,4 +61,4 @@ Everyone interacting in the `Hanami::RSpec` project's codebases, issue trackers,
51
61
 
52
62
  ## Copyright
53
63
 
54
- Copyright © 2014–2024 Hanami Team – Released under MIT License
64
+ Copyright © 2014-2022 Hanami Team – Released under MIT License
data/hanami-rspec.gemspec CHANGED
@@ -5,14 +5,14 @@ require_relative "lib/hanami/rspec/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "hanami-rspec"
7
7
  spec.version = Hanami::RSpec::VERSION
8
- spec.authors = ["Hanakai team"]
9
- spec.email = ["info@hanakai.org"]
8
+ spec.authors = ["Luca Guidi"]
9
+ spec.email = ["me@lucaguidi.com"]
10
10
 
11
11
  spec.summary = "Hanami RSpec"
12
12
  spec.description = "Hanami RSpec generators and Rake tasks"
13
13
  spec.homepage = "https://hanamirb.org"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 3.2"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
18
 
@@ -29,10 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_dependency "hanami-cli", "~> 2.3.0"
33
- spec.add_dependency "rspec", "~> 3.12"
32
+ spec.add_dependency "hanami-cli", "~> 2.0.0.alpha"
33
+ spec.add_dependency "rspec", "~> 3.11"
34
34
  spec.add_dependency "rake", "~> 13.0"
35
- spec.add_dependency "zeitwerk", "~> 2.6"
36
35
 
37
36
  spec.add_development_dependency "rubocop", "~> 1.11"
38
37
  spec.metadata["rubygems_mfa_required"] = "true"
@@ -1,26 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "hanami/cli"
3
4
  require "shellwords"
5
+ require "hanami/cli/generators/context"
6
+ require_relative "./generators"
4
7
 
5
8
  module Hanami
6
9
  module RSpec
7
- # @since 2.0.0
8
- # @api private
9
10
  module Commands
10
- # @since 2.0.0
11
- # @api private
12
11
  class Install < Hanami::CLI::Command
13
- # @since 2.0.0
14
- # @api private
15
12
  def call(*, **)
16
13
  append_gemfile
17
- append_gitignore
18
14
  copy_dotrspec
19
15
  copy_spec_helper
20
16
  copy_support_rspec
21
- copy_support_db
22
- copy_support_features
23
- copy_support_operations
24
17
  copy_support_requests
25
18
 
26
19
  generate_request_spec
@@ -29,18 +22,11 @@ module Hanami
29
22
  private
30
23
 
31
24
  def append_gemfile
32
- gemfile_template = Hanami.bundled?("hanami-db") ? "gemfile_db" : "gemfile"
33
-
34
25
  fs.append(
35
26
  fs.expand_path("Gemfile"),
36
- fs.read(fs.expand_path(fs.join("generators", gemfile_template), __dir__))
37
- )
38
- end
39
-
40
- def append_gitignore
41
- fs.append(
42
- fs.expand_path(".gitignore"),
43
- fs.read(fs.expand_path(fs.join("generators", "gitignore"), __dir__))
27
+ fs.read(
28
+ fs.expand_path(fs.join("generators", "gemfile"), __dir__)
29
+ ),
44
30
  )
45
31
  end
46
32
 
@@ -65,34 +51,6 @@ module Hanami
65
51
  )
66
52
  end
67
53
 
68
- def copy_support_db
69
- return unless Hanami.bundled?("hanami-db")
70
-
71
- fs.cp(
72
- fs.expand_path(fs.join("generators/support_db.rb"), __dir__),
73
- fs.expand_path(fs.join("spec", "support", "db.rb"))
74
- )
75
-
76
- fs.cp(
77
- fs.expand_path(fs.join("generators/support_db_cleaning.rb"), __dir__),
78
- fs.expand_path(fs.join("spec", "support", "db", "cleaning.rb"))
79
- )
80
- end
81
-
82
- def copy_support_features
83
- fs.cp(
84
- fs.expand_path(fs.join("generators", "support_features.rb"), __dir__),
85
- fs.expand_path(fs.join("spec", "support", "features.rb"))
86
- )
87
- end
88
-
89
- def copy_support_operations
90
- fs.cp(
91
- fs.expand_path(fs.join("generators", "support_operations.rb"), __dir__),
92
- fs.expand_path(fs.join("spec", "support", "operations.rb"))
93
- )
94
- end
95
-
96
54
  def copy_support_requests
97
55
  fs.cp(
98
56
  fs.expand_path(fs.join("generators", "support_requests.rb"), __dir__),
@@ -108,91 +66,23 @@ module Hanami
108
66
  end
109
67
  end
110
68
 
111
- # @since 2.0.0
112
- # @api private
113
69
  module Generate
114
- # @since 2.0.0
115
- # @api private
116
70
  class Slice < Hanami::CLI::Command
117
- # @since 2.0.0
118
- # @api private
119
- def call(options = nil, name: nil, **)
120
- # Support multiple calling conventions for dry-cli cross-version compatibility:
121
- #
122
- # - dry-cli 1.3 calls with positional hash: call({name: "foo"})
123
- # - dry-cli 1.4+: calls with keyword arguments: call(name: "foo")
124
- #
125
- # TODO: Remove this with Hanami 2.4 (which will require dry-cli 1.4+).
126
- if options.is_a?(Hash)
127
- name = options[:name]
128
- end
129
-
130
- slice = inflector.underscore(Shellwords.shellescape(name))
71
+ # FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
72
+ def call(options, **)
73
+ slice = inflector.underscore(Shellwords.shellescape(options[:name]))
131
74
 
75
+ out.puts "generating #{slice} (rspec)"
132
76
  generator = Generators::Slice.new(fs: fs, inflector: inflector)
133
77
  generator.call(slice)
134
78
  end
135
79
  end
136
-
137
- # @since 2.0.0
138
- # @api private
139
- class Action < Hanami::CLI::Commands::App::Command
140
- # @since 2.0.0
141
- # @api private
142
- def call(options = nil, name: nil, slice: nil, skip_tests: false, **)
143
- # Support multiple calling conventions for dry-cli cross-version compatibility:
144
- #
145
- # - dry-cli 1.3 calls with positional hash: call({name: "foo"})
146
- # - dry-cli 1.4+: calls with keyword arguments: call(name: "foo")
147
- #
148
- # TODO: Remove this with Hanami 2.4 (which will require dry-cli 1.4+).
149
- if options.is_a?(Hash)
150
- name = options[:name]
151
- slice = options[:slice]
152
- skip_tests = options[:skip_tests] || false
153
- end
154
-
155
- return if skip_tests
156
-
157
- slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
158
- key = inflector.underscore(Shellwords.shellescape(name))
159
-
160
- namespace = slice ? inflector.camelize(slice) : app.namespace
161
- base_path = slice ? "spec/slices/#{slice}" : "spec"
162
-
163
- generator = Generators::Action.new(fs:, inflector:)
164
- generator.call(key:, namespace:, base_path:)
165
- end
166
- end
167
-
168
- # @since 2.1.0
169
- # @api private
170
- class Part < Hanami::CLI::Commands::App::Command
171
- # @since 2.1.0
172
- # @api private
173
- def call(options = nil, name: nil, slice: nil, skip_tests: false, **)
174
- # Support multiple calling conventions for dry-cli cross-version compatibility:
175
- #
176
- # - dry-cli 1.3 calls with positional hash: call({name: "foo"})
177
- # - dry-cli 1.4+: calls with keyword arguments: call(name: "foo")
178
- #
179
- # TODO: Remove this with Hanami 2.4 (which will require dry-cli 1.4+).
180
- if options.is_a?(Hash)
181
- name = options[:name]
182
- slice = options[:slice]
183
- skip_tests = options[:skip_tests] || false
184
- end
185
-
186
- return if skip_tests
187
-
188
- slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
189
- name = inflector.underscore(Shellwords.shellescape(name))
190
-
191
- generator = Generators::Part.new(fs: fs, inflector: inflector)
192
- generator.call(app.namespace, slice, name)
193
- end
194
- end
195
80
  end
196
81
  end
197
82
  end
198
83
  end
84
+
85
+ if Hanami::CLI.within_hanami_app?
86
+ Hanami::CLI.after "install", Hanami::RSpec::Commands::Install
87
+ # Hanami::CLI.after "generate slice", Hanami::RSpec::Commands::Generate::Slice
88
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module RSpec
5
+ class Error < StandardError
6
+ end
7
+ end
8
+ end
@@ -1,6 +1,4 @@
1
1
 
2
2
  group :test do
3
- # Web integration
4
- gem "capybara"
5
3
  gem "rack-test"
6
4
  end
@@ -6,4 +6,5 @@ SPEC_ROOT = Pathname(__dir__).realpath.freeze
6
6
  ENV["HANAMI_ENV"] ||= "test"
7
7
  require "hanami/prepare"
8
8
 
9
- SPEC_ROOT.glob("support/**/*.rb").each { |f| require f }
9
+ require_relative "support/rspec"
10
+ require_relative "support/requests"
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe "Root", type: :request do
4
- it "is not found" do
4
+ it "is successful" do
5
5
  get "/"
6
6
 
7
- # Generate new action via:
8
- # `bundle exec hanami generate action home.index --url=/`
9
- expect(last_response.status).to be(404)
7
+ # Find me in `config/routes.rb`
8
+ expect(last_response).to be_successful
9
+ expect(last_response.body).to eq("Hello from Hanami")
10
10
  end
11
11
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe <%= camelized_slice_name %>::Action do
4
- xit "works"
3
+ require "slices/<%= underscored_slice_name %>/action"
4
+
5
+ RSpec.describe <%= classified_slice_name %>::Action do
5
6
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require "slices/<%= underscored_slice_name %>/repository"
4
4
 
5
- RSpec.describe <%= camelized_slice_name %>::Repository do
5
+ RSpec.describe <%= classified_slice_name %>::Repository do
6
6
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require "slices/<%= underscored_slice_name %>/view"
4
4
 
5
- RSpec.describe <%= camelized_slice_name %>::View do
5
+ RSpec.describe <%= classified_slice_name %>::View do
6
6
  end