hanami-rspec 3.11.0.beta2 → 3.11.0.beta3
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 +11 -1
- data/CHANGELOG.md +7 -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.rb +1 -0
- data/lib/hanami/rspec/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3c622f62aeded6a152396460f0bb462d1abc6e1c46e8f009ff7c5defb80f6d0
|
4
|
+
data.tar.gz: b473be9664791e51a31c58604f4040df018c82dec2bb4eb1abc9a0da0284629f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac3a26f68ab3ecff9b292ff9a94159547792b5f2c035c9dfd1d92ed30504f39c49f980da62754e6a21d43d9dead44c56b652ad746bb19497d06a42551c6e4cca
|
7
|
+
data.tar.gz: f947e767c88960d73e51761b4367f4028d74036d62176c933f160f73274a588ef64cd3b14f44a3ec24f9fe32f214e2acd953924b9ca5a5a976d7e75b7494a295
|
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,10 @@
|
|
1
|
+
## v3.11.0.beta3 - 2022-09-21
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
- [Luca Guidi] Hook into `hanami new` and `hanami generate` to respect name pluralization
|
6
|
+
- [Luca Guidi] Hook into `hanami generate action` to generate action specs
|
7
|
+
|
1
8
|
## v3.11.0.beta2 - 2022-08-16
|
2
9
|
|
3
10
|
### 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/#{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
|
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.beta3
|
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-09-21 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
|
@@ -128,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
131
|
- !ruby/object:Gem::Version
|
129
132
|
version: 1.3.1
|
130
133
|
requirements: []
|
131
|
-
rubygems_version: 3.3.
|
134
|
+
rubygems_version: 3.3.3
|
132
135
|
signing_key:
|
133
136
|
specification_version: 4
|
134
137
|
summary: Hanami RSpec
|