hanami-rspec 3.11.0.beta2 → 3.11.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 632c3ecceacf60792f86496711c48a6970860f21ec2f1e8b7f2f7fd279215af5
4
- data.tar.gz: e7841892ea75c9bbfe55c89b32b3352174249e7fb91f3ad7377355c5186233c4
3
+ metadata.gz: a3c622f62aeded6a152396460f0bb462d1abc6e1c46e8f009ff7c5defb80f6d0
4
+ data.tar.gz: b473be9664791e51a31c58604f4040df018c82dec2bb4eb1abc9a0da0284629f
5
5
  SHA512:
6
- metadata.gz: e1f200c7285c7aec4cdc3d8bea19d0b58d0598b0f66dc107971e703b7216a2c2e4e3f28394e28301053fc0cca69ec52367f1b1914d08a11b68425ae303f1be59
7
- data.tar.gz: c37b3d3a39c84027341ae56deb74c1122d1a495b5bef35dc0723bfd0eda9c28a6064878c88d5efe800551deaf0e3496583cb6714da83e6bddb685c5ed3e81f70
6
+ metadata.gz: ac3a26f68ab3ecff9b292ff9a94159547792b5f2c035c9dfd1d92ed30504f39c49f980da62754e6a21d43d9dead44c56b652ad746bb19497d06a42551c6e4cca
7
+ data.tar.gz: f947e767c88960d73e51761b4367f4028d74036d62176c933f160f73274a588ef64cd3b14f44a3ec24f9fe32f214e2acd953924b9ca5a5a976d7e75b7494a295
@@ -12,7 +12,9 @@ name: ci
12
12
  - '.rubocop.yml'
13
13
  pull_request:
14
14
  branches:
15
- - master
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe <%= classified_slice_name %>::Action do
3
+ RSpec.describe <%= camelized_slice_name %>::Action do
4
4
  xit "works"
5
5
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  require "slices/<%= underscored_slice_name %>/repository"
4
4
 
5
- RSpec.describe <%= classified_slice_name %>::Repository do
5
+ RSpec.describe <%= camelized_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 <%= classified_slice_name %>::View do
5
+ RSpec.describe <%= camelized_slice_name %>::View do
6
6
  end
@@ -4,6 +4,7 @@ module Hanami
4
4
  module RSpec
5
5
  module Generators
6
6
  require_relative "./generators/slice"
7
+ require_relative "./generators/action"
7
8
  end
8
9
  end
9
10
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Hanami
4
4
  module RSpec
5
- VERSION = "3.11.0.beta2"
5
+ VERSION = "3.11.0.beta3"
6
6
  end
7
7
  end
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.beta2
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-08-16 00:00:00.000000000 Z
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.7
134
+ rubygems_version: 3.3.3
132
135
  signing_key:
133
136
  specification_version: 4
134
137
  summary: Hanami RSpec