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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 632c3ecceacf60792f86496711c48a6970860f21ec2f1e8b7f2f7fd279215af5
4
- data.tar.gz: e7841892ea75c9bbfe55c89b32b3352174249e7fb91f3ad7377355c5186233c4
3
+ metadata.gz: ee0769c05279751795a397b6905dd8ef7112de35f470b5dd04fdef9306aa7565
4
+ data.tar.gz: 4ade71c9080db5defd0a26e2311efdf95c65abeefe425e26d65f41032d08ad87
5
5
  SHA512:
6
- metadata.gz: e1f200c7285c7aec4cdc3d8bea19d0b58d0598b0f66dc107971e703b7216a2c2e4e3f28394e28301053fc0cca69ec52367f1b1914d08a11b68425ae303f1be59
7
- data.tar.gz: c37b3d3a39c84027341ae56deb74c1122d1a495b5bef35dc0723bfd0eda9c28a6064878c88d5efe800551deaf0e3496583cb6714da83e6bddb685c5ed3e81f70
6
+ metadata.gz: '0286f30fd65aaa93c73a06274e39e79c01dcfd8a9751673bc7aad01d65bef6a2d0f62654b7f126ee1d58c9630225b7497f7860191dcf12d1704da1c47ddd1a68'
7
+ data.tar.gz: 5e40df011dd9d8d22dbd1478c93cc89c7f4d0bf1a2ca6a462789d3bac23d28850e66db1df78990212d095761cfe60807edd29c8430534ef3a613fea2c3de1fb7
@@ -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,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
@@ -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
@@ -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
@@ -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.beta4"
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.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-08-16 00:00:00.000000000 Z
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