hanami-rspec 3.11.0.beta2 → 3.11.0.beta4
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 +11 -1
- data/CHANGELOG.md +13 -0
- data/lib/hanami/rspec/commands.rb +14 -0
- data/lib/hanami/rspec/generators/action/action_slice_spec.erb +10 -0
- data/lib/hanami/rspec/generators/action/action_spec.erb +10 -0
- data/lib/hanami/rspec/generators/action.rb +53 -0
- data/lib/hanami/rspec/generators/slice/action_spec.erb +1 -1
- 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 +10 -10
- data/lib/hanami/rspec/generators.rb +1 -0
- data/lib/hanami/rspec/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee0769c05279751795a397b6905dd8ef7112de35f470b5dd04fdef9306aa7565
|
4
|
+
data.tar.gz: 4ade71c9080db5defd0a26e2311efdf95c65abeefe425e26d65f41032d08ad87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0286f30fd65aaa93c73a06274e39e79c01dcfd8a9751673bc7aad01d65bef6a2d0f62654b7f126ee1d58c9630225b7497f7860191dcf12d1704da1c47ddd1a68'
|
7
|
+
data.tar.gz: 5e40df011dd9d8d22dbd1478c93cc89c7f4d0bf1a2ca6a462789d3bac23d28850e66db1df78990212d095761cfe60807edd29c8430534ef3a613fea2c3de1fb7
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,7 +12,9 @@ name: ci
|
|
12
12
|
- '.rubocop.yml'
|
13
13
|
pull_request:
|
14
14
|
branches:
|
15
|
-
-
|
15
|
+
- main
|
16
|
+
schedule:
|
17
|
+
- cron: '30 4 * * *'
|
16
18
|
create:
|
17
19
|
|
18
20
|
jobs:
|
@@ -22,8 +24,16 @@ jobs:
|
|
22
24
|
fail-fast: false
|
23
25
|
matrix:
|
24
26
|
ruby:
|
27
|
+
- '3.1'
|
25
28
|
- '3.0'
|
26
29
|
steps:
|
30
|
+
- uses: ravsamhq/notify-slack-action@v1
|
31
|
+
if: always()
|
32
|
+
with:
|
33
|
+
status: ${{ job.status }}
|
34
|
+
notify_when: 'failure'
|
35
|
+
env:
|
36
|
+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
27
37
|
- uses: actions/checkout@v1
|
28
38
|
- name: Install package dependencies
|
29
39
|
run: '[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## v3.11.0.beta4 - 2022-10-24
|
2
|
+
|
3
|
+
## Changed
|
4
|
+
|
5
|
+
- [Luca Guidi] Generate slice specs under `spec/slices/[slice_name]/` (#9)
|
6
|
+
|
7
|
+
## v3.11.0.beta3 - 2022-09-21
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- [Luca Guidi] Hook into `hanami new` and `hanami generate` to respect name pluralization
|
12
|
+
- [Luca Guidi] Hook into `hanami generate action` to generate action specs
|
13
|
+
|
1
14
|
## v3.11.0.beta2 - 2022-08-16
|
2
15
|
|
3
16
|
### Added
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "hanami/cli"
|
4
4
|
require "shellwords"
|
5
|
+
require "hanami/cli/commands/app/command"
|
5
6
|
require "hanami/cli/generators/context"
|
6
7
|
require_relative "./generators"
|
7
8
|
|
@@ -76,6 +77,18 @@ module Hanami
|
|
76
77
|
generator.call(slice)
|
77
78
|
end
|
78
79
|
end
|
80
|
+
|
81
|
+
class Action < Hanami::CLI::Commands::App::Command
|
82
|
+
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
83
|
+
def call(options, **)
|
84
|
+
slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
|
85
|
+
name = inflector.underscore(Shellwords.shellescape(options[:name]))
|
86
|
+
*controller, action = name.split(ACTION_SEPARATOR)
|
87
|
+
|
88
|
+
generator = Generators::Action.new(fs: fs, inflector: inflector)
|
89
|
+
generator.call(app.namespace, slice, controller, action)
|
90
|
+
end
|
91
|
+
end
|
79
92
|
end
|
80
93
|
end
|
81
94
|
end
|
@@ -84,4 +97,5 @@ end
|
|
84
97
|
if Hanami::CLI.within_hanami_app?
|
85
98
|
Hanami::CLI.after "install", Hanami::RSpec::Commands::Install
|
86
99
|
Hanami::CLI.after "generate slice", Hanami::RSpec::Commands::Generate::Slice
|
100
|
+
Hanami::CLI.after "generate action", Hanami::RSpec::Commands::Generate::Action
|
87
101
|
end
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "erb"
|
4
|
+
require "hanami/cli/generators/app/action_context"
|
5
|
+
|
6
|
+
module Hanami
|
7
|
+
module RSpec
|
8
|
+
module Generators
|
9
|
+
class Action
|
10
|
+
def initialize(fs:, inflector:)
|
11
|
+
@fs = fs
|
12
|
+
@inflector = inflector
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(app, slice, controller, action, context: Hanami::CLI::Generators::App::ActionContext.new(inflector, app, slice, controller, action)) # rubocop:disable Layout/LineLength
|
16
|
+
if slice
|
17
|
+
fs.write(
|
18
|
+
"spec/slices/#{slice}/actions/#{controller_directory(controller)}/#{action}_spec.rb",
|
19
|
+
t("action_slice_spec.erb", context)
|
20
|
+
)
|
21
|
+
else
|
22
|
+
fs.write(
|
23
|
+
"spec/actions/#{controller_directory(controller)}/#{action}_spec.rb",
|
24
|
+
t("action_spec.erb", context)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :fs
|
32
|
+
|
33
|
+
attr_reader :inflector
|
34
|
+
|
35
|
+
# @api private
|
36
|
+
# @param controller [Array<String>]
|
37
|
+
def controller_directory(controller)
|
38
|
+
fs.join(controller)
|
39
|
+
end
|
40
|
+
|
41
|
+
def template(path, context)
|
42
|
+
require "erb"
|
43
|
+
|
44
|
+
ERB.new(
|
45
|
+
File.read(__dir__ + "/action/#{path}")
|
46
|
+
).result(context.ctx)
|
47
|
+
end
|
48
|
+
|
49
|
+
alias_method :t, :template
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -13,16 +13,16 @@ module Hanami
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(slice, context: Hanami::CLI::Generators::App::SliceContext.new(inflector, nil, slice, nil))
|
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))
|
16
|
+
fs.write("spec/slices/#{slice}/action_spec.rb", t("action_spec.erb", context))
|
17
|
+
# fs.write("spec/slices/#{slice}/view_spec.rb", t("view_spec.erb", context))
|
18
|
+
# fs.write("spec/slices/#{slice}/repository_spec.rb", t("repository_spec.erb", context))
|
19
|
+
|
20
|
+
fs.write("spec/slices/#{slice}/actions/.keep", t("keep.erb", context))
|
21
|
+
# fs.write("spec/slices/#{slice}/views/.keep", t("keep.erb", context))
|
22
|
+
# fs.write("spec/slices/#{slice}/templates/.keep", t("keep.erb", context))
|
23
|
+
# fs.write("spec/slices/#{slice}/templates/layouts/.keep", t("keep.erb", context))
|
24
|
+
# fs.write("spec/slices/#{slice}/entities/.keep", t("keep.erb", context))
|
25
|
+
# fs.write("spec/slices/#{slice}/repositories/.keep", t("keep.erb", context))
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
data/lib/hanami/rspec/version.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: 3.11.0.
|
4
|
+
version: 3.11.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-cli
|
@@ -91,6 +91,9 @@ files:
|
|
91
91
|
- lib/hanami/rspec/commands.rb
|
92
92
|
- lib/hanami/rspec/error.rb
|
93
93
|
- lib/hanami/rspec/generators.rb
|
94
|
+
- lib/hanami/rspec/generators/action.rb
|
95
|
+
- lib/hanami/rspec/generators/action/action_slice_spec.erb
|
96
|
+
- lib/hanami/rspec/generators/action/action_spec.erb
|
94
97
|
- lib/hanami/rspec/generators/dotrspec
|
95
98
|
- lib/hanami/rspec/generators/gemfile
|
96
99
|
- lib/hanami/rspec/generators/helper.rb
|