hanami-rspec 2.3.0.beta2 → 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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +13 -15
- data/.rubocop.yml +0 -2
- data/CHANGELOG.md +0 -119
- data/Gemfile +5 -5
- data/LICENSE.txt +21 -0
- data/README.md +16 -9
- data/hanami-rspec.gemspec +3 -4
- data/lib/hanami/rspec/commands.rb +12 -91
- data/lib/hanami/rspec/error.rb +8 -0
- data/lib/hanami/rspec/generators/gemfile +0 -2
- data/lib/hanami/rspec/generators/helper.rb +2 -1
- data/lib/hanami/rspec/generators/request.rb +4 -4
- data/lib/hanami/rspec/generators/slice/action_spec.erb +3 -2
- data/lib/hanami/rspec/generators/slice/repository_spec.erb +1 -1
- data/lib/hanami/rspec/generators/slice/view_spec.erb +1 -1
- data/lib/hanami/rspec/generators/slice.rb +13 -23
- data/lib/hanami/rspec/generators/support_requests.rb +2 -3
- data/lib/hanami/rspec/generators/support_rspec.rb +2 -36
- data/lib/hanami/rspec/generators.rb +9 -0
- data/lib/hanami/rspec/rake_tasks.rb +2 -0
- data/lib/hanami/rspec/version.rb +1 -5
- data/lib/hanami/rspec.rb +2 -39
- data/lib/hanami-rspec.rb +1 -1
- metadata +16 -37
- data/LICENSE.md +0 -22
- data/lib/hanami/rspec/generators/action.rb +0 -60
- data/lib/hanami/rspec/generators/gemfile_db +0 -9
- data/lib/hanami/rspec/generators/gitignore +0 -1
- data/lib/hanami/rspec/generators/part/part_base_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part/part_slice_base_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part/part_slice_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part/part_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part.rb +0 -114
- data/lib/hanami/rspec/generators/support_db.rb +0 -10
- data/lib/hanami/rspec/generators/support_db_cleaning.rb +0 -42
- data/lib/hanami/rspec/generators/support_features.rb +0 -5
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb274d263b143f47cda8bf26d3e064125d57dea50a5be98b0b5182e6a952d186
|
|
4
|
+
data.tar.gz: e98375c2ef0d2974a1982989694e5873377bb1b5cafccf159477e5e90e963657
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89e4a5322a0f7bafd4c8abbfd94f8edaf0e7f9ff617ac65f543ce8d2232dbdc40c33618ca3061f93b092359a0c83ea29c42039b9c64976bb6e810dceac7813fe
|
|
7
|
+
data.tar.gz: 8049790bcf4437f5363c94af6d41a58be5b90a5c02cea61c4f6b274180f6559a00b1271a7d566b8ef6a52c36c6304c2c24f9c9c7e25d9abdc95b360a48a56d40
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -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,13 +22,11 @@ jobs:
|
|
|
14
22
|
fail-fast: false
|
|
15
23
|
matrix:
|
|
16
24
|
ruby:
|
|
17
|
-
-
|
|
18
|
-
- "3.3"
|
|
19
|
-
- "3.2"
|
|
25
|
+
- '3.0'
|
|
20
26
|
steps:
|
|
21
27
|
- uses: actions/checkout@v1
|
|
22
28
|
- name: Install package dependencies
|
|
23
|
-
run:
|
|
29
|
+
run: '[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS'
|
|
24
30
|
- name: Set up Ruby
|
|
25
31
|
uses: ruby/setup-ruby@v1
|
|
26
32
|
with:
|
|
@@ -32,11 +38,3 @@ jobs:
|
|
|
32
38
|
run: bundle install --jobs 4 --retry 3
|
|
33
39
|
- name: Run all tests
|
|
34
40
|
run: bundle exec rake
|
|
35
|
-
|
|
36
|
-
workflow-keepalive:
|
|
37
|
-
if: github.event_name == 'schedule'
|
|
38
|
-
runs-on: ubuntu-latest
|
|
39
|
-
permissions:
|
|
40
|
-
actions: write
|
|
41
|
-
steps:
|
|
42
|
-
- uses: liskin/gh-workflow-keepalive@v1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,122 +1,3 @@
|
|
|
1
|
-
# Hanami::RSpec
|
|
2
|
-
|
|
3
|
-
RSpec support for Hanami
|
|
4
|
-
|
|
5
|
-
## v2.3.0.beta2 - 2025-10-17
|
|
6
|
-
|
|
7
|
-
### Changed
|
|
8
|
-
|
|
9
|
-
- Drop support for Ruby 3.1
|
|
10
|
-
|
|
11
|
-
## v2.3.0.beta1 - 2025-10-03
|
|
12
|
-
|
|
13
|
-
### Changed
|
|
14
|
-
|
|
15
|
-
- [Aaron Allen] Change shared context name in generated `spec/support/requests.rb` to avoid a RuboCop RSpec offense (#40)
|
|
16
|
-
|
|
17
|
-
## v2.2.1 - 2024-11-12
|
|
18
|
-
|
|
19
|
-
### Changed
|
|
20
|
-
|
|
21
|
-
- [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)
|
|
22
|
-
|
|
23
|
-
## v2.2.0 - 2024-11-05
|
|
24
|
-
|
|
25
|
-
### Changed
|
|
26
|
-
|
|
27
|
-
- [Paweł Świątkowski, Seb Wilgosz] Only enhance `generate` CLI commands if the relevant gems are bundled (#29)
|
|
28
|
-
|
|
29
|
-
## v2.2.0.rc1 - 2024-10-29
|
|
30
|
-
|
|
31
|
-
### Added
|
|
32
|
-
|
|
33
|
-
- [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)
|
|
34
|
-
|
|
35
|
-
### Changed
|
|
36
|
-
|
|
37
|
-
- [Seb Wilgosz] Only enhance `generate` CLI commands if the relevant gems are bundled (#26)
|
|
38
|
-
|
|
39
|
-
## v2.2.0.beta1 - 2024-07-16
|
|
40
|
-
|
|
41
|
-
### Changed
|
|
42
|
-
|
|
43
|
-
- [Sean Collins] In generated `spec_helper.rb`, require all files under `spec/support/` in a loop, rather than via manual requires (#24)
|
|
44
|
-
|
|
45
|
-
## v2.2.0.beta1 - 2024-07-16
|
|
46
|
-
|
|
47
|
-
### Added
|
|
48
|
-
|
|
49
|
-
- [Sean Collins] Include `Dry::Monads[:result]` in tests via `support/operations.rb`
|
|
50
|
-
|
|
51
|
-
### Changed
|
|
52
|
-
|
|
53
|
-
- Drop support for Ruby 3.0
|
|
54
|
-
|
|
55
|
-
## v2.1.0 - 2024-02-27
|
|
56
|
-
|
|
57
|
-
## v2.1.0.rc3 - 2024-02-16
|
|
58
|
-
|
|
59
|
-
## v2.1.0.rc2 - 2023-11-08
|
|
60
|
-
|
|
61
|
-
### Added
|
|
62
|
-
|
|
63
|
-
- [Tim Riley] Skip generating tests for `hanami generate` when `--skip-tests` CLI option is given.
|
|
64
|
-
- [Tim Riley] Install Capybara and generate `spec/support/capybara.rb` in `hanami install` hook.
|
|
65
|
-
|
|
66
|
-
### Changed
|
|
67
|
-
|
|
68
|
-
- [Tim Riley] Add explanatory code comments to `spec/support/rspec.rb` generated in `hanami install` hook.
|
|
69
|
-
|
|
70
|
-
## v2.1.0.rc1 - 2023-11-01
|
|
71
|
-
|
|
72
|
-
### Added
|
|
73
|
-
|
|
74
|
-
- [Luca Guidi] Generate spec for `hanami generate part` command
|
|
75
|
-
|
|
76
|
-
### Changed
|
|
77
|
-
|
|
78
|
-
- [Luca Guidi] Default request spec to expect 404, now that `hanami new` doesn't generate a default root route anymore
|
|
79
|
-
|
|
80
|
-
## v2.1.0.beta1 - 2023-06-29
|
|
81
|
-
|
|
82
|
-
## v2.0.1 - 2022-12-25
|
|
83
|
-
|
|
84
|
-
### Added
|
|
85
|
-
|
|
86
|
-
- [Luca Guidi] Official support for Ruby 3.2
|
|
87
|
-
|
|
88
|
-
## v2.0.0 - 2022-11-22
|
|
89
|
-
|
|
90
|
-
### Added
|
|
91
|
-
|
|
92
|
-
- [Tim Riley] Use Zeitwerk to autoload the gem
|
|
93
|
-
- [Luca Guidi] Support RSpec 3.12
|
|
94
|
-
|
|
95
|
-
## v2.0.0.rc1 - 2022-11-08
|
|
96
|
-
|
|
97
|
-
### Changed
|
|
98
|
-
|
|
99
|
-
- [Luca Guidi] Follow `hanami` versioning
|
|
100
|
-
|
|
101
|
-
## v3.11.0.beta4 - 2022-10-24
|
|
102
|
-
|
|
103
|
-
### Changed
|
|
104
|
-
|
|
105
|
-
- [Luca Guidi] Generate slice specs under `spec/slices/[slice_name]/` (#9)
|
|
106
|
-
|
|
107
|
-
## v3.11.0.beta3 - 2022-09-21
|
|
108
|
-
|
|
109
|
-
### Added
|
|
110
|
-
|
|
111
|
-
- [Luca Guidi] Hook into `hanami new` and `hanami generate` to respect name pluralization
|
|
112
|
-
- [Luca Guidi] Hook into `hanami generate action` to generate action specs
|
|
113
|
-
|
|
114
|
-
## v3.11.0.beta2 - 2022-08-16
|
|
115
|
-
|
|
116
|
-
### Added
|
|
117
|
-
|
|
118
|
-
- [Luca Guidi] Hook into `hanami generate slice` to generate a slice directory in spec/ along with a placeholder base action spec [#5]
|
|
119
|
-
|
|
120
1
|
## v3.11.0.beta1 - 2022-07-20
|
|
121
2
|
|
|
122
3
|
### Added
|
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 "
|
|
12
|
-
gem "hanami-cli",
|
|
13
|
-
gem "hanami",
|
|
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,23 +1,30 @@
|
|
|
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
|
[](https://badge.fury.io/rb/hanami-rspec)
|
|
8
|
-
[](https://github.com/hanami/rspec/actions?query=workflow%3Aci+branch%3Amain)
|
|
9
9
|
[](https://depfu.com/github/hanami/rspec?project=Bundler)
|
|
10
10
|
|
|
11
|
+
## Version
|
|
12
|
+
|
|
13
|
+
Versioning of this gem follows RSpec.
|
|
14
|
+
|
|
11
15
|
## Contact
|
|
12
16
|
|
|
13
17
|
- Home page: http://hanamirb.org
|
|
14
18
|
- Mailing List: http://hanamirb.org/mailing-list
|
|
15
19
|
- Bugs/Issues: https://github.com/hanami/rspec/issues
|
|
20
|
+
- Support: http://stackoverflow.com/questions/tagged/hanami
|
|
16
21
|
- Chat: http://chat.hanamirb.org
|
|
17
22
|
|
|
18
|
-
##
|
|
23
|
+
## Rubies
|
|
24
|
+
|
|
25
|
+
**Hanami::RSpec** supports Ruby (MRI) 3.0+
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
## Installation
|
|
21
28
|
|
|
22
29
|
Add this line to your application's Gemfile:
|
|
23
30
|
|
|
@@ -29,10 +36,10 @@ end
|
|
|
29
36
|
|
|
30
37
|
And then execute:
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
$ bundle
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
$ bundle install
|
|
40
|
+
$ bundle exec hanami setup
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
36
43
|
|
|
37
44
|
## Development
|
|
38
45
|
|
|
@@ -54,4 +61,4 @@ Everyone interacting in the `Hanami::RSpec` project's codebases, issue trackers,
|
|
|
54
61
|
|
|
55
62
|
## Copyright
|
|
56
63
|
|
|
57
|
-
Copyright © 2014
|
|
64
|
+
Copyright © 2014-2022 Hanami Team – Released under MIT License
|
data/hanami-rspec.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
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.
|
|
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.
|
|
33
|
-
spec.add_dependency "rspec", "~> 3.
|
|
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(
|
|
37
|
-
|
|
38
|
-
|
|
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,60 +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
71
|
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
|
118
72
|
def call(options, **)
|
|
119
73
|
slice = inflector.underscore(Shellwords.shellescape(options[:name]))
|
|
120
74
|
|
|
75
|
+
out.puts "generating #{slice} (rspec)"
|
|
121
76
|
generator = Generators::Slice.new(fs: fs, inflector: inflector)
|
|
122
77
|
generator.call(slice)
|
|
123
78
|
end
|
|
124
79
|
end
|
|
125
|
-
|
|
126
|
-
# @since 2.0.0
|
|
127
|
-
# @api private
|
|
128
|
-
class Action < Hanami::CLI::Commands::App::Command
|
|
129
|
-
# @since 2.0.0
|
|
130
|
-
# @api private
|
|
131
|
-
def call(options, **)
|
|
132
|
-
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
|
133
|
-
|
|
134
|
-
return if options[:skip_tests]
|
|
135
|
-
|
|
136
|
-
slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
|
|
137
|
-
key = inflector.underscore(Shellwords.shellescape(options[:name]))
|
|
138
|
-
|
|
139
|
-
namespace = slice ? inflector.camelize(slice) : app.namespace
|
|
140
|
-
base_path = slice ? "spec/slices/#{slice}" : "spec"
|
|
141
|
-
|
|
142
|
-
generator = Generators::Action.new(fs:, inflector:)
|
|
143
|
-
generator.call(key:, namespace:, base_path:)
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
# @since 2.1.0
|
|
148
|
-
# @api private
|
|
149
|
-
class Part < Hanami::CLI::Commands::App::Command
|
|
150
|
-
# @since 2.1.0
|
|
151
|
-
# @api private
|
|
152
|
-
def call(options, **)
|
|
153
|
-
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
|
154
|
-
|
|
155
|
-
return if options[:skip_tests]
|
|
156
|
-
|
|
157
|
-
slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
|
|
158
|
-
name = inflector.underscore(Shellwords.shellescape(options[:name]))
|
|
159
|
-
|
|
160
|
-
generator = Generators::Part.new(fs: fs, inflector: inflector)
|
|
161
|
-
generator.call(app.namespace, slice, name)
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
80
|
end
|
|
165
81
|
end
|
|
166
82
|
end
|
|
167
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
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe "Root", type: :request do
|
|
4
|
-
it "is
|
|
4
|
+
it "is successful" do
|
|
5
5
|
get "/"
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
expect(last_response.
|
|
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,38 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "erb"
|
|
4
|
+
require "hanami/cli/generators/app/slice_context"
|
|
4
5
|
|
|
5
6
|
module Hanami
|
|
6
7
|
module RSpec
|
|
7
8
|
module Generators
|
|
8
|
-
# @since 2.0.0
|
|
9
|
-
# @api private
|
|
10
9
|
class Slice
|
|
11
|
-
# @since 2.0.0
|
|
12
|
-
# @api private
|
|
13
10
|
def initialize(fs:, inflector:)
|
|
14
11
|
@fs = fs
|
|
15
12
|
@inflector = inflector
|
|
16
13
|
end
|
|
17
14
|
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
fs.write("spec
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
fs.write("spec/slices/#{slice}/actions/.keep", t("keep.erb", context))
|
|
31
|
-
# fs.write("spec/slices/#{slice}/views/.keep", t("keep.erb", context))
|
|
32
|
-
# fs.write("spec/slices/#{slice}/templates/.keep", t("keep.erb", context))
|
|
33
|
-
# fs.write("spec/slices/#{slice}/templates/layouts/.keep", t("keep.erb", context))
|
|
34
|
-
# fs.write("spec/slices/#{slice}/entities/.keep", t("keep.erb", context))
|
|
35
|
-
# fs.write("spec/slices/#{slice}/repositories/.keep", t("keep.erb", context))
|
|
15
|
+
def call(slice, context: Hanami::CLI::Generators::App::SliceContext.new(inflector, nil, slice, nil)) # rubocop:disable Metrics/AbcSize
|
|
16
|
+
fs.write("spec/#{slice}/action_spec.rb", t("action_spec.erb", context))
|
|
17
|
+
fs.write("spec/#{slice}/view_spec.rb", t("view_spec.erb", context))
|
|
18
|
+
fs.write("spec/#{slice}/repository_spec.rb", t("repository_spec.erb", context))
|
|
19
|
+
|
|
20
|
+
fs.write("spec/#{slice}/actions/.keep", t("keep.erb", context))
|
|
21
|
+
fs.write("spec/#{slice}/views/.keep", t("keep.erb", context))
|
|
22
|
+
fs.write("spec/#{slice}/templates/.keep", t("keep.erb", context))
|
|
23
|
+
fs.write("spec/#{slice}/templates/layouts/.keep", t("keep.erb", context))
|
|
24
|
+
fs.write("spec/#{slice}/entities/.keep", t("keep.erb", context))
|
|
25
|
+
fs.write("spec/#{slice}/repositories/.keep", t("keep.erb", context))
|
|
36
26
|
end
|
|
37
27
|
|
|
38
28
|
private
|
|
@@ -46,7 +36,7 @@ module Hanami
|
|
|
46
36
|
|
|
47
37
|
ERB.new(
|
|
48
38
|
File.read(__dir__ + "/slice/#{path}")
|
|
49
|
-
).result(context.
|
|
39
|
+
).result(context.ctx)
|
|
50
40
|
end
|
|
51
41
|
|
|
52
42
|
alias_method :t, :template
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
require "rack/test"
|
|
4
4
|
|
|
5
|
-
RSpec.shared_context "
|
|
6
|
-
# Define the app for Rack::Test requests
|
|
5
|
+
RSpec.shared_context "Hanami app" do
|
|
7
6
|
let(:app) { Hanami.app }
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
RSpec.configure do |config|
|
|
11
10
|
config.include Rack::Test::Methods, type: :request
|
|
12
|
-
config.include_context "
|
|
11
|
+
config.include_context "Hanami app", type: :request
|
|
13
12
|
end
|
|
@@ -1,61 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.configure do |config|
|
|
4
|
-
# Use the recommended non-monkey patched syntax.
|
|
5
|
-
config.disable_monkey_patching!
|
|
6
|
-
|
|
7
|
-
# Use and configure rspec-expectations.
|
|
8
4
|
config.expect_with :rspec do |expectations|
|
|
9
|
-
# This option will default to `true` in RSpec 4.
|
|
10
5
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
11
6
|
end
|
|
12
7
|
|
|
13
|
-
# Use and configure rspec-mocks.
|
|
14
8
|
config.mock_with :rspec do |mocks|
|
|
15
|
-
# Prevents you from mocking or stubbing a method that does not exist on a
|
|
16
|
-
# real object.
|
|
17
9
|
mocks.verify_partial_doubles = true
|
|
18
10
|
end
|
|
19
11
|
|
|
20
|
-
# This option will default to `:apply_to_host_groups` in RSpec 4.
|
|
21
12
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
22
13
|
|
|
23
|
-
# Limit a spec run to individual examples or groups you care about by tagging
|
|
24
|
-
# them with `:focus` metadata. When nothing is tagged with `:focus`, all
|
|
25
|
-
# examples get run.
|
|
26
|
-
#
|
|
27
|
-
# RSpec also provides aliases for `it`, `describe`, and `context` that include
|
|
28
|
-
# `:focus` metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
29
14
|
config.filter_run_when_matching :focus
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# configure your source control system to ignore this file.
|
|
34
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
35
|
-
|
|
36
|
-
# Uncomment this to enable warnings. This is recommended, but in some cases
|
|
37
|
-
# may be too noisy due to issues in dependencies.
|
|
38
|
-
# config.warnings = true
|
|
16
|
+
config.disable_monkey_patching!
|
|
17
|
+
config.warnings = true
|
|
39
18
|
|
|
40
|
-
# Show more verbose output when running an individual spec file.
|
|
41
19
|
if config.files_to_run.one?
|
|
42
20
|
config.default_formatter = "doc"
|
|
43
21
|
end
|
|
44
22
|
|
|
45
|
-
# Print the 10 slowest examples and example groups at the end of the spec run,
|
|
46
|
-
# to help surface which specs are running particularly slow.
|
|
47
23
|
config.profile_examples = 10
|
|
48
24
|
|
|
49
|
-
# Run specs in random order to surface order dependencies. If you find an
|
|
50
|
-
# order dependency and want to debug it, you can fix the order by providing
|
|
51
|
-
# the seed, which is printed after each run:
|
|
52
|
-
#
|
|
53
|
-
# --seed 1234
|
|
54
25
|
config.order = :random
|
|
55
|
-
|
|
56
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
|
57
|
-
# This allows you to use `--seed` to deterministically reproduce test failures
|
|
58
|
-
# related to randomization by passing the same `--seed` value as the one that
|
|
59
|
-
# triggered the failure.
|
|
60
26
|
Kernel.srand config.seed
|
|
61
27
|
end
|
data/lib/hanami/rspec/version.rb
CHANGED
data/lib/hanami/rspec.rb
CHANGED
|
@@ -1,47 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "hanami/cli"
|
|
4
|
-
require "zeitwerk"
|
|
5
|
-
|
|
6
|
-
# @see Hanami::RSpec
|
|
7
|
-
# @since 2.0.0
|
|
8
3
|
module Hanami
|
|
9
|
-
# RSpec and testing support for Hanami applications.
|
|
10
|
-
#
|
|
11
|
-
# @since 2.0.0
|
|
12
|
-
# @api private
|
|
13
4
|
module RSpec
|
|
14
|
-
# @since 2.0.0
|
|
15
|
-
# @api private
|
|
16
|
-
def self.gem_loader
|
|
17
|
-
@gem_loader ||= Zeitwerk::Loader.new.tap do |loader|
|
|
18
|
-
root = File.expand_path("..", __dir__)
|
|
19
|
-
loader.tag = "hanami-rspec"
|
|
20
|
-
loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami-rspec.rb")
|
|
21
|
-
loader.push_dir(root)
|
|
22
|
-
loader.ignore(
|
|
23
|
-
"#{root}/hanami-rspec.rb",
|
|
24
|
-
"#{root}/hanami/rspec/{rake_tasks,version}.rb"
|
|
25
|
-
)
|
|
26
|
-
loader.inflector.inflect("rspec" => "RSpec")
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
gem_loader.setup
|
|
31
5
|
require_relative "rspec/version"
|
|
6
|
+
require_relative "rspec/error"
|
|
7
|
+
require_relative "rspec/commands"
|
|
32
8
|
require_relative "rspec/rake_tasks"
|
|
33
|
-
|
|
34
|
-
if Hanami::CLI.within_hanami_app?
|
|
35
|
-
Hanami::CLI.before "install", Commands::Install
|
|
36
|
-
Hanami::CLI.after "generate slice", Commands::Generate::Slice
|
|
37
|
-
|
|
38
|
-
if Hanami.bundled?("hanami-controller")
|
|
39
|
-
Hanami::CLI.after "generate action", Commands::Generate::Action
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
if Hanami.bundled?("hanami-view")
|
|
43
|
-
Hanami::CLI.after "generate part", Commands::Generate::Part
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
9
|
end
|
|
47
10
|
end
|
data/lib/hanami-rspec.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hanami-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.11.0.beta1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luca Guidi
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: hanami-cli
|
|
@@ -15,28 +16,28 @@ dependencies:
|
|
|
15
16
|
requirements:
|
|
16
17
|
- - "~>"
|
|
17
18
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
19
|
+
version: 2.0.0.alpha
|
|
19
20
|
type: :runtime
|
|
20
21
|
prerelease: false
|
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
23
|
requirements:
|
|
23
24
|
- - "~>"
|
|
24
25
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.
|
|
26
|
+
version: 2.0.0.alpha
|
|
26
27
|
- !ruby/object:Gem::Dependency
|
|
27
28
|
name: rspec
|
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
|
29
30
|
requirements:
|
|
30
31
|
- - "~>"
|
|
31
32
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '3.
|
|
33
|
+
version: '3.11'
|
|
33
34
|
type: :runtime
|
|
34
35
|
prerelease: false
|
|
35
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
37
|
requirements:
|
|
37
38
|
- - "~>"
|
|
38
39
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '3.
|
|
40
|
+
version: '3.11'
|
|
40
41
|
- !ruby/object:Gem::Dependency
|
|
41
42
|
name: rake
|
|
42
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -51,20 +52,6 @@ dependencies:
|
|
|
51
52
|
- - "~>"
|
|
52
53
|
- !ruby/object:Gem::Version
|
|
53
54
|
version: '13.0'
|
|
54
|
-
- !ruby/object:Gem::Dependency
|
|
55
|
-
name: zeitwerk
|
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '2.6'
|
|
61
|
-
type: :runtime
|
|
62
|
-
prerelease: false
|
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '2.6'
|
|
68
55
|
- !ruby/object:Gem::Dependency
|
|
69
56
|
name: rubocop
|
|
70
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -93,7 +80,7 @@ files:
|
|
|
93
80
|
- CHANGELOG.md
|
|
94
81
|
- CODE_OF_CONDUCT.md
|
|
95
82
|
- Gemfile
|
|
96
|
-
- LICENSE.
|
|
83
|
+
- LICENSE.txt
|
|
97
84
|
- README.md
|
|
98
85
|
- Rakefile
|
|
99
86
|
- bin/console
|
|
@@ -102,27 +89,17 @@ files:
|
|
|
102
89
|
- lib/hanami-rspec.rb
|
|
103
90
|
- lib/hanami/rspec.rb
|
|
104
91
|
- lib/hanami/rspec/commands.rb
|
|
105
|
-
- lib/hanami/rspec/
|
|
92
|
+
- lib/hanami/rspec/error.rb
|
|
93
|
+
- lib/hanami/rspec/generators.rb
|
|
106
94
|
- lib/hanami/rspec/generators/dotrspec
|
|
107
95
|
- lib/hanami/rspec/generators/gemfile
|
|
108
|
-
- lib/hanami/rspec/generators/gemfile_db
|
|
109
|
-
- lib/hanami/rspec/generators/gitignore
|
|
110
96
|
- lib/hanami/rspec/generators/helper.rb
|
|
111
|
-
- lib/hanami/rspec/generators/part.rb
|
|
112
|
-
- lib/hanami/rspec/generators/part/part_base_spec.erb
|
|
113
|
-
- lib/hanami/rspec/generators/part/part_slice_base_spec.erb
|
|
114
|
-
- lib/hanami/rspec/generators/part/part_slice_spec.erb
|
|
115
|
-
- lib/hanami/rspec/generators/part/part_spec.erb
|
|
116
97
|
- lib/hanami/rspec/generators/request.rb
|
|
117
98
|
- lib/hanami/rspec/generators/slice.rb
|
|
118
99
|
- lib/hanami/rspec/generators/slice/action_spec.erb
|
|
119
100
|
- lib/hanami/rspec/generators/slice/keep.erb
|
|
120
101
|
- lib/hanami/rspec/generators/slice/repository_spec.erb
|
|
121
102
|
- lib/hanami/rspec/generators/slice/view_spec.erb
|
|
122
|
-
- lib/hanami/rspec/generators/support_db.rb
|
|
123
|
-
- lib/hanami/rspec/generators/support_db_cleaning.rb
|
|
124
|
-
- lib/hanami/rspec/generators/support_features.rb
|
|
125
|
-
- lib/hanami/rspec/generators/support_operations.rb
|
|
126
103
|
- lib/hanami/rspec/generators/support_requests.rb
|
|
127
104
|
- lib/hanami/rspec/generators/support_rspec.rb
|
|
128
105
|
- lib/hanami/rspec/rake_tasks.rb
|
|
@@ -136,6 +113,7 @@ metadata:
|
|
|
136
113
|
source_code_uri: https://github.com/hanami/rspec
|
|
137
114
|
changelog_uri: https://github.com/hanami/rspec/blob/master/CHANGELOG.md
|
|
138
115
|
rubygems_mfa_required: 'true'
|
|
116
|
+
post_install_message:
|
|
139
117
|
rdoc_options: []
|
|
140
118
|
require_paths:
|
|
141
119
|
- lib
|
|
@@ -143,14 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
143
121
|
requirements:
|
|
144
122
|
- - ">="
|
|
145
123
|
- !ruby/object:Gem::Version
|
|
146
|
-
version:
|
|
124
|
+
version: 3.0.0
|
|
147
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
126
|
requirements:
|
|
149
|
-
- - "
|
|
127
|
+
- - ">"
|
|
150
128
|
- !ruby/object:Gem::Version
|
|
151
|
-
version:
|
|
129
|
+
version: 1.3.1
|
|
152
130
|
requirements: []
|
|
153
|
-
rubygems_version: 3.
|
|
131
|
+
rubygems_version: 3.3.3
|
|
132
|
+
signing_key:
|
|
154
133
|
specification_version: 4
|
|
155
134
|
summary: Hanami RSpec
|
|
156
135
|
test_files: []
|
data/LICENSE.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright © 2014 Hanami Team
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "hanami/cli/generators/app/ruby_class_file"
|
|
4
|
-
|
|
5
|
-
module Hanami
|
|
6
|
-
module RSpec
|
|
7
|
-
module Generators
|
|
8
|
-
# @since 2.0.0
|
|
9
|
-
# @api private
|
|
10
|
-
class Action
|
|
11
|
-
# @since 2.0.0
|
|
12
|
-
# @api private
|
|
13
|
-
def initialize(fs:, inflector:)
|
|
14
|
-
@fs = fs
|
|
15
|
-
@inflector = inflector
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# @since 2.0.0
|
|
19
|
-
# @api private
|
|
20
|
-
def call(key:, namespace:, base_path:)
|
|
21
|
-
ruby_class_file = action_ruby_class_file(key: key, namespace: namespace, base_path: base_path)
|
|
22
|
-
spec_file_path = ruby_class_file.path.gsub(/\.rb$/, "_spec.rb")
|
|
23
|
-
action_class_name = ruby_class_file.fully_qualified_name
|
|
24
|
-
|
|
25
|
-
fs.write(spec_file_path, spec_content(action_class_name))
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
attr_reader :fs, :inflector
|
|
31
|
-
|
|
32
|
-
def action_ruby_class_file(key:, namespace:, base_path:)
|
|
33
|
-
Hanami::CLI::Generators::App::RubyClassFile.new(
|
|
34
|
-
fs: fs,
|
|
35
|
-
inflector: inflector,
|
|
36
|
-
namespace: namespace,
|
|
37
|
-
key: inflector.underscore(key),
|
|
38
|
-
base_path: base_path,
|
|
39
|
-
extra_namespace: "Actions",
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def spec_content(class_name)
|
|
44
|
-
<<~RUBY
|
|
45
|
-
# frozen_string_literal: true
|
|
46
|
-
|
|
47
|
-
RSpec.describe #{class_name} do
|
|
48
|
-
let(:params) { Hash[] }
|
|
49
|
-
|
|
50
|
-
it "works" do
|
|
51
|
-
response = subject.call(params)
|
|
52
|
-
expect(response).to be_successful
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
RUBY
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
spec/examples.txt
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe <%= camelized_slice_name %>::Views::Parts::<%= camelized_name %> do
|
|
4
|
-
subject { described_class.new(value:) }
|
|
5
|
-
let(:value) { double("<%= underscored_name %>") }
|
|
6
|
-
|
|
7
|
-
it "works" do
|
|
8
|
-
expect(subject).to be_kind_of(described_class)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe <%= camelized_app_name %>::Views::Parts::<%= camelized_name %> do
|
|
4
|
-
subject { described_class.new(value:) }
|
|
5
|
-
let(:value) { double("<%= underscored_name %>") }
|
|
6
|
-
|
|
7
|
-
it "works" do
|
|
8
|
-
expect(subject).to be_kind_of(described_class)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "erb"
|
|
4
|
-
|
|
5
|
-
module Hanami
|
|
6
|
-
module RSpec
|
|
7
|
-
module Generators
|
|
8
|
-
# @since 2.1.0
|
|
9
|
-
# @api private
|
|
10
|
-
class Part
|
|
11
|
-
# @since 2.1.0
|
|
12
|
-
# @api private
|
|
13
|
-
def initialize(fs:, inflector:)
|
|
14
|
-
@fs = fs
|
|
15
|
-
@inflector = inflector
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# @since 2.1.0
|
|
19
|
-
# @api private
|
|
20
|
-
def call(app, slice, name)
|
|
21
|
-
context = Struct.new(
|
|
22
|
-
:camelized_app_name,
|
|
23
|
-
:camelized_slice_name,
|
|
24
|
-
:camelized_name,
|
|
25
|
-
:underscored_name
|
|
26
|
-
).new(
|
|
27
|
-
inflector.camelize(app),
|
|
28
|
-
slice ? inflector.camelize(slice) : nil,
|
|
29
|
-
inflector.camelize(name),
|
|
30
|
-
inflector.underscore(name)
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
if slice
|
|
34
|
-
generate_for_slice(slice, context)
|
|
35
|
-
else
|
|
36
|
-
generate_for_app(context)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
# @since 2.1.0
|
|
43
|
-
# @api private
|
|
44
|
-
def generate_for_slice(slice, context)
|
|
45
|
-
generate_base_part_for_app(context)
|
|
46
|
-
generate_base_part_for_slice(context, slice)
|
|
47
|
-
|
|
48
|
-
fs.write(
|
|
49
|
-
"spec/slices/#{slice}/views/parts/#{context.underscored_name}_spec.rb",
|
|
50
|
-
t("part_slice_spec.erb", context)
|
|
51
|
-
)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# @since 2.1.0
|
|
55
|
-
# @api private
|
|
56
|
-
def generate_for_app(context)
|
|
57
|
-
generate_base_part_for_app(context)
|
|
58
|
-
|
|
59
|
-
fs.write(
|
|
60
|
-
"spec/views/parts/#{context.underscored_name}_spec.rb",
|
|
61
|
-
t("part_spec.erb", context)
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# @since 2.1.0
|
|
66
|
-
# @api private
|
|
67
|
-
def generate_base_part_for_app(context)
|
|
68
|
-
path = fs.join("spec", "views", "part_spec.rb")
|
|
69
|
-
return if fs.exist?(path)
|
|
70
|
-
|
|
71
|
-
fs.write(
|
|
72
|
-
path,
|
|
73
|
-
t("part_base_spec.erb", context)
|
|
74
|
-
)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# @since 2.1.0
|
|
78
|
-
# @api private
|
|
79
|
-
def generate_base_part_for_slice(context, slice)
|
|
80
|
-
path = "spec/slices/#{slice}/views/part_spec.rb"
|
|
81
|
-
return if fs.exist?(path)
|
|
82
|
-
|
|
83
|
-
fs.write(
|
|
84
|
-
path,
|
|
85
|
-
t("part_slice_base_spec.erb", context)
|
|
86
|
-
)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# @since 2.1.0
|
|
90
|
-
# @api private
|
|
91
|
-
attr_reader :fs
|
|
92
|
-
|
|
93
|
-
# @since 2.1.0
|
|
94
|
-
# @api private
|
|
95
|
-
attr_reader :inflector
|
|
96
|
-
|
|
97
|
-
# @since 2.1.0
|
|
98
|
-
# @api private
|
|
99
|
-
def template(path, context)
|
|
100
|
-
require "erb"
|
|
101
|
-
|
|
102
|
-
ERB.new(
|
|
103
|
-
File.read(__dir__ + "/part/#{path}"),
|
|
104
|
-
trim_mode: "-"
|
|
105
|
-
).result(context.instance_eval { binding })
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# @since 2.1.0
|
|
109
|
-
# @api private
|
|
110
|
-
alias_method :t, :template
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Tag feature spec examples as `:db`
|
|
4
|
-
#
|
|
5
|
-
# See support/db/cleaning.rb for how the database is cleaned around these `:db` examples.
|
|
6
|
-
RSpec.configure do |config|
|
|
7
|
-
config.define_derived_metadata(type: :feature) do |metadata|
|
|
8
|
-
metadata[:db] = true
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "database_cleaner/sequel"
|
|
4
|
-
|
|
5
|
-
# Clean the databases between tests tagged as `:db`
|
|
6
|
-
RSpec.configure do |config|
|
|
7
|
-
# Returns all the configured databases across the app and its slices.
|
|
8
|
-
#
|
|
9
|
-
# Used in the before/after hooks below to ensure each database is cleaned between examples.
|
|
10
|
-
#
|
|
11
|
-
# Modify this proc (or any code below) if you only need specific databases cleaned.
|
|
12
|
-
all_databases = -> {
|
|
13
|
-
slices = [Hanami.app] + Hanami.app.slices.with_nested
|
|
14
|
-
|
|
15
|
-
slices.each_with_object([]) { |slice, dbs|
|
|
16
|
-
next unless slice.key?("db.rom")
|
|
17
|
-
|
|
18
|
-
dbs.concat slice["db.rom"].gateways.values.map(&:connection)
|
|
19
|
-
}.uniq
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
config.before :suite do
|
|
23
|
-
all_databases.call.each do |db|
|
|
24
|
-
DatabaseCleaner[:sequel, db: db].clean_with :truncation, except: ["schema_migrations"]
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
config.before :each, :db do |example|
|
|
29
|
-
strategy = example.metadata[:js] ? :truncation : :transaction
|
|
30
|
-
|
|
31
|
-
all_databases.call.each do |db|
|
|
32
|
-
DatabaseCleaner[:sequel, db: db].strategy = strategy
|
|
33
|
-
DatabaseCleaner[:sequel, db: db].start
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
config.after :each, :db do
|
|
38
|
-
all_databases.call.each do |db|
|
|
39
|
-
DatabaseCleaner[:sequel, db: db].clean
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|