hanami-rspec 2.1.0.beta1 → 3.11.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -12
- data/CHANGELOG.md +0 -44
- data/Gemfile +0 -2
- data/LICENSE.txt +21 -0
- data/README.md +10 -6
- data/hanami-rspec.gemspec +2 -3
- data/lib/hanami/rspec/commands.rb +9 -26
- data/lib/hanami/rspec/error.rb +8 -0
- 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 +12 -17
- 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 -32
- data/lib/hanami-rspec.rb +1 -1
- metadata +10 -25
- data/LICENSE.md +0 -22
- data/lib/hanami/rspec/generators/action/action_slice_spec.erb +0 -10
- data/lib/hanami/rspec/generators/action/action_spec.erb +0 -10
- data/lib/hanami/rspec/generators/action.rb +0 -58
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
@@ -12,9 +12,7 @@ name: ci
|
|
12
12
|
- '.rubocop.yml'
|
13
13
|
pull_request:
|
14
14
|
branches:
|
15
|
-
-
|
16
|
-
schedule:
|
17
|
-
- cron: '30 4 * * *'
|
15
|
+
- master
|
18
16
|
create:
|
19
17
|
|
20
18
|
jobs:
|
@@ -24,17 +22,8 @@ jobs:
|
|
24
22
|
fail-fast: false
|
25
23
|
matrix:
|
26
24
|
ruby:
|
27
|
-
- '3.2'
|
28
|
-
- '3.1'
|
29
25
|
- '3.0'
|
30
26
|
steps:
|
31
|
-
- uses: ravsamhq/notify-slack-action@v1
|
32
|
-
if: always()
|
33
|
-
with:
|
34
|
-
status: ${{ job.status }}
|
35
|
-
notify_when: 'failure'
|
36
|
-
env:
|
37
|
-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
38
27
|
- uses: actions/checkout@v1
|
39
28
|
- name: Install package dependencies
|
40
29
|
run: '[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS'
|
data/CHANGELOG.md
CHANGED
@@ -1,47 +1,3 @@
|
|
1
|
-
# Hanami::RSpec
|
2
|
-
|
3
|
-
RSpec support for Hanami
|
4
|
-
|
5
|
-
## v2.1.0.beta1 - 2023-06-29
|
6
|
-
|
7
|
-
## v2.0.1 - 2022-12-25
|
8
|
-
|
9
|
-
### Added
|
10
|
-
|
11
|
-
- [Luca Guidi] Official support for Ruby 3.2
|
12
|
-
|
13
|
-
## v2.0.0 - 2022-11-22
|
14
|
-
|
15
|
-
### Added
|
16
|
-
|
17
|
-
- [Tim Riley] Use Zeitwerk to autoload the gem
|
18
|
-
- [Luca Guidi] Support RSpec 3.12
|
19
|
-
|
20
|
-
## v2.0.0.rc1 - 2022-11-08
|
21
|
-
|
22
|
-
### Changed
|
23
|
-
|
24
|
-
- [Luca Guidi] Follow `hanami` versioning
|
25
|
-
|
26
|
-
## v3.11.0.beta4 - 2022-10-24
|
27
|
-
|
28
|
-
### Changed
|
29
|
-
|
30
|
-
- [Luca Guidi] Generate slice specs under `spec/slices/[slice_name]/` (#9)
|
31
|
-
|
32
|
-
## v3.11.0.beta3 - 2022-09-21
|
33
|
-
|
34
|
-
### Added
|
35
|
-
|
36
|
-
- [Luca Guidi] Hook into `hanami new` and `hanami generate` to respect name pluralization
|
37
|
-
- [Luca Guidi] Hook into `hanami generate action` to generate action specs
|
38
|
-
|
39
|
-
## v3.11.0.beta2 - 2022-08-16
|
40
|
-
|
41
|
-
### Added
|
42
|
-
|
43
|
-
- [Luca Guidi] Hook into `hanami generate slice` to generate a slice directory in spec/ along with a placeholder base action spec [#5]
|
44
|
-
|
45
1
|
## v3.11.0.beta1 - 2022-07-20
|
46
2
|
|
47
3
|
### Added
|
data/Gemfile
CHANGED
@@ -9,7 +9,5 @@ unless ENV["CI"]
|
|
9
9
|
end
|
10
10
|
|
11
11
|
gem "dry-files", require: false, git: "https://github.com/dry-rb/dry-files.git", branch: "main"
|
12
|
-
gem "dry-logger", require: false, git: "https://github.com/dry-rb/dry-logger.git", branch: "main"
|
13
|
-
gem "hanami-utils", require: false, git: "https://github.com/hanami/utils.git", branch: "main"
|
14
12
|
gem "hanami-cli", require: false, git: "https://github.com/hanami/cli.git", branch: "main"
|
15
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,6 +1,6 @@
|
|
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
|
|
@@ -8,6 +8,10 @@ RSpec and testing support for [Hanami applications](https://github.com/hanami/ha
|
|
8
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
9
|
[![Depfu](https://badges.depfu.com/badges/a8545fb67cf32a2c75b6227bc0821027/overview.svg)](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
|
@@ -32,10 +36,10 @@ end
|
|
32
36
|
|
33
37
|
And then execute:
|
34
38
|
|
35
|
-
|
36
|
-
$ bundle
|
37
|
-
|
38
|
-
|
39
|
+
$ bundle install
|
40
|
+
$ bundle exec hanami setup
|
41
|
+
|
42
|
+
## Usage
|
39
43
|
|
40
44
|
## Development
|
41
45
|
|
@@ -57,4 +61,4 @@ Everyone interacting in the `Hanami::RSpec` project's codebases, issue trackers,
|
|
57
61
|
|
58
62
|
## Copyright
|
59
63
|
|
60
|
-
Copyright © 2014 Hanami Team – Released under MIT License
|
64
|
+
Copyright © 2014-2022 Hanami Team – Released under MIT License
|
data/hanami-rspec.gemspec
CHANGED
@@ -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.0"
|
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,17 +1,14 @@
|
|
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
14
|
copy_dotrspec
|
@@ -69,37 +66,23 @@ module Hanami
|
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
72
|
-
# @since 2.0.0
|
73
|
-
# @api private
|
74
69
|
module Generate
|
75
|
-
# @since 2.0.0
|
76
|
-
# @api private
|
77
70
|
class Slice < Hanami::CLI::Command
|
78
71
|
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
79
72
|
def call(options, **)
|
80
73
|
slice = inflector.underscore(Shellwords.shellescape(options[:name]))
|
81
74
|
|
75
|
+
out.puts "generating #{slice} (rspec)"
|
82
76
|
generator = Generators::Slice.new(fs: fs, inflector: inflector)
|
83
77
|
generator.call(slice)
|
84
78
|
end
|
85
79
|
end
|
86
|
-
|
87
|
-
# @since 2.0.0
|
88
|
-
# @api private
|
89
|
-
class Action < Hanami::CLI::Commands::App::Command
|
90
|
-
# @since 2.0.0
|
91
|
-
# @api private
|
92
|
-
def call(options, **)
|
93
|
-
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
94
|
-
slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
|
95
|
-
name = inflector.underscore(Shellwords.shellescape(options[:name]))
|
96
|
-
*controller, action = name.split(ACTION_SEPARATOR)
|
97
|
-
|
98
|
-
generator = Generators::Action.new(fs: fs, inflector: inflector)
|
99
|
-
generator.call(app.namespace, slice, controller, action)
|
100
|
-
end
|
101
|
-
end
|
102
80
|
end
|
103
81
|
end
|
104
82
|
end
|
105
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,33 +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
|
-
fs.write("spec
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
fs.write("spec
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# fs.write("spec/slices/#{slice}/entities/.keep", t("keep.erb", context))
|
30
|
-
# 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))
|
31
26
|
end
|
32
27
|
|
33
28
|
private
|
data/lib/hanami/rspec/version.rb
CHANGED
data/lib/hanami/rspec.rb
CHANGED
@@ -1,40 +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.after "install", Commands::Install
|
36
|
-
Hanami::CLI.after "generate slice", Commands::Generate::Slice
|
37
|
-
Hanami::CLI.after "generate action", Commands::Generate::Action
|
38
|
-
end
|
39
9
|
end
|
40
10
|
end
|
data/lib/hanami-rspec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +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
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-cli
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0.alpha
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0.alpha
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.11'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: zeitwerk
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.6'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.6'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rubocop
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +80,7 @@ files:
|
|
94
80
|
- CHANGELOG.md
|
95
81
|
- CODE_OF_CONDUCT.md
|
96
82
|
- Gemfile
|
97
|
-
- LICENSE.
|
83
|
+
- LICENSE.txt
|
98
84
|
- README.md
|
99
85
|
- Rakefile
|
100
86
|
- bin/console
|
@@ -103,9 +89,8 @@ files:
|
|
103
89
|
- lib/hanami-rspec.rb
|
104
90
|
- lib/hanami/rspec.rb
|
105
91
|
- lib/hanami/rspec/commands.rb
|
106
|
-
- lib/hanami/rspec/
|
107
|
-
- lib/hanami/rspec/generators
|
108
|
-
- lib/hanami/rspec/generators/action/action_spec.erb
|
92
|
+
- lib/hanami/rspec/error.rb
|
93
|
+
- lib/hanami/rspec/generators.rb
|
109
94
|
- lib/hanami/rspec/generators/dotrspec
|
110
95
|
- lib/hanami/rspec/generators/gemfile
|
111
96
|
- lib/hanami/rspec/generators/helper.rb
|
@@ -143,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
128
|
- !ruby/object:Gem::Version
|
144
129
|
version: 1.3.1
|
145
130
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.3.3
|
147
132
|
signing_key:
|
148
133
|
specification_version: 4
|
149
134
|
summary: Hanami RSpec
|
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,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe <%= camelized_slice_name %>::Actions::<%= camelized_controller_name %>::<%= camelized_action_name %> do
|
4
|
-
let(:params) { Hash[] }
|
5
|
-
|
6
|
-
it "works" do
|
7
|
-
response = subject.call(params)
|
8
|
-
expect(response).to be_successful
|
9
|
-
end
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe <%= camelized_app_name %>::Actions::<%= camelized_controller_name %>::<%= camelized_action_name %> do
|
4
|
-
let(:params) { Hash[] }
|
5
|
-
|
6
|
-
it "works" do
|
7
|
-
response = subject.call(params)
|
8
|
-
expect(response).to be_successful
|
9
|
-
end
|
10
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "erb"
|
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(app, slice, controller, action, context: Hanami::CLI::Generators::App::ActionContext.new(inflector, app, slice, controller, action)) # rubocop:disable Layout/LineLength
|
21
|
-
if slice
|
22
|
-
fs.write(
|
23
|
-
"spec/slices/#{slice}/actions/#{controller_directory(controller)}/#{action}_spec.rb",
|
24
|
-
t("action_slice_spec.erb", context)
|
25
|
-
)
|
26
|
-
else
|
27
|
-
fs.write(
|
28
|
-
"spec/actions/#{controller_directory(controller)}/#{action}_spec.rb",
|
29
|
-
t("action_spec.erb", context)
|
30
|
-
)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
attr_reader :fs
|
37
|
-
|
38
|
-
attr_reader :inflector
|
39
|
-
|
40
|
-
# @api private
|
41
|
-
# @param controller [Array<String>]
|
42
|
-
def controller_directory(controller)
|
43
|
-
fs.join(controller)
|
44
|
-
end
|
45
|
-
|
46
|
-
def template(path, context)
|
47
|
-
require "erb"
|
48
|
-
|
49
|
-
ERB.new(
|
50
|
-
File.read(__dir__ + "/action/#{path}")
|
51
|
-
).result(context.ctx)
|
52
|
-
end
|
53
|
-
|
54
|
-
alias_method :t, :template
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|