hanami-rspec 2.2.1 → 2.3.0.beta2
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 +1 -1
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +0 -4
- data/hanami-rspec.gemspec +2 -2
- data/lib/hanami/rspec/commands.rb +6 -4
- data/lib/hanami/rspec/generators/action.rb +30 -28
- data/lib/hanami/rspec/generators/part/part_base_spec.erb +0 -4
- data/lib/hanami/rspec/generators/part/part_slice_base_spec.erb +0 -4
- data/lib/hanami/rspec/generators/part/part_slice_spec.erb +0 -4
- data/lib/hanami/rspec/generators/part/part_spec.erb +0 -4
- data/lib/hanami/rspec/generators/part.rb +14 -2
- data/lib/hanami/rspec/generators/slice.rb +7 -2
- data/lib/hanami/rspec/generators/support_requests.rb +2 -2
- data/lib/hanami/rspec/version.rb +1 -1
- metadata +6 -11
- data/lib/hanami/rspec/generators/action/action_slice_spec.erb +0 -10
- data/lib/hanami/rspec/generators/action/action_spec.erb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0af8c0843959599de80bce86e2ab4f2352f331ba3e0c26cb809885d1578b13fb
|
|
4
|
+
data.tar.gz: 537e0134e03a4728452948791eb6c71e24db5354d5c28061ce31d2365e2ce479
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cad888bebd03004f2b1d3b6f792e346072f7c53584d7369c9dcaff91fbba5b7092459590285caa16f52838a3e300ed7ffc11daf6dc596d750b93f3a181437bb
|
|
7
|
+
data.tar.gz: d1987acefecac5d67439d5ebf91e1f80a955a683382129d40ded017eec29a498b9a817c49fb29c5bceba13c76c2fdf8a3e978327d34cac4664759fb92d9e8b92
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
RSpec support for Hanami
|
|
4
4
|
|
|
5
|
+
## v2.3.0.beta2 - 2025-10-17
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Drop support for Ruby 3.1
|
|
10
|
+
|
|
11
|
+
## v2.3.0.beta1 - 2025-10-03
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- [Aaron Allen] Change shared context name in generated `spec/support/requests.rb` to avoid a RuboCop RSpec offense (#40)
|
|
16
|
+
|
|
5
17
|
## v2.2.1 - 2024-11-12
|
|
6
18
|
|
|
7
19
|
### Changed
|
data/Gemfile
CHANGED
|
@@ -8,10 +8,6 @@ unless ENV["CI"]
|
|
|
8
8
|
gem "yard"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
gem "dry-files", github: "dry-rb/dry-files", branch: "main"
|
|
12
|
-
gem "dry-logger", github: "dry-rb/dry-logger", branch: "main"
|
|
13
|
-
gem "dry-system", github: "dry-rb/dry-system", branch: "main"
|
|
14
|
-
|
|
15
11
|
gem "hanami-utils", github: "hanami/utils", branch: "main"
|
|
16
12
|
gem "hanami-cli", github: "hanami/cli", branch: "main"
|
|
17
13
|
gem "hanami", github: "hanami/hanami", branch: "main"
|
data/hanami-rspec.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.description = "Hanami RSpec generators and Rake tasks"
|
|
13
13
|
spec.homepage = "https://hanamirb.org"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = ">= 3.
|
|
15
|
+
spec.required_ruby_version = ">= 3.2"
|
|
16
16
|
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
18
18
|
|
|
@@ -29,7 +29,7 @@ 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.
|
|
32
|
+
spec.add_dependency "hanami-cli", "~> 2.3.0.beta2"
|
|
33
33
|
spec.add_dependency "rspec", "~> 3.12"
|
|
34
34
|
spec.add_dependency "rake", "~> 13.0"
|
|
35
35
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
|
@@ -134,11 +134,13 @@ module Hanami
|
|
|
134
134
|
return if options[:skip_tests]
|
|
135
135
|
|
|
136
136
|
slice = inflector.underscore(Shellwords.shellescape(options[:slice])) if options[:slice]
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
key = inflector.underscore(Shellwords.shellescape(options[:name]))
|
|
138
|
+
|
|
139
|
+
namespace = slice ? inflector.camelize(slice) : app.namespace
|
|
140
|
+
base_path = slice ? "spec/slices/#{slice}" : "spec"
|
|
139
141
|
|
|
140
|
-
generator = Generators::Action.new(fs
|
|
141
|
-
generator.call(
|
|
142
|
+
generator = Generators::Action.new(fs:, inflector:)
|
|
143
|
+
generator.call(key:, namespace:, base_path:)
|
|
142
144
|
end
|
|
143
145
|
end
|
|
144
146
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "hanami/cli/generators/app/ruby_class_file"
|
|
4
4
|
|
|
5
5
|
module Hanami
|
|
6
6
|
module RSpec
|
|
@@ -17,41 +17,43 @@ module Hanami
|
|
|
17
17
|
|
|
18
18
|
# @since 2.0.0
|
|
19
19
|
# @api private
|
|
20
|
-
def call(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
else
|
|
27
|
-
fs.write(
|
|
28
|
-
"spec/actions/#{controller_directory(controller)}/#{action}_spec.rb",
|
|
29
|
-
t("action_spec.erb", context)
|
|
30
|
-
)
|
|
31
|
-
end
|
|
20
|
+
def call(key:, namespace:, base_path:)
|
|
21
|
+
ruby_class_file = action_ruby_class_file(key: key, namespace: namespace, base_path: base_path)
|
|
22
|
+
spec_file_path = ruby_class_file.path.gsub(/\.rb$/, "_spec.rb")
|
|
23
|
+
action_class_name = ruby_class_file.fully_qualified_name
|
|
24
|
+
|
|
25
|
+
fs.write(spec_file_path, spec_content(action_class_name))
|
|
32
26
|
end
|
|
33
27
|
|
|
34
28
|
private
|
|
35
29
|
|
|
36
|
-
attr_reader :fs
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
attr_reader :fs, :inflector
|
|
31
|
+
|
|
32
|
+
def action_ruby_class_file(key:, namespace:, base_path:)
|
|
33
|
+
Hanami::CLI::Generators::App::RubyClassFile.new(
|
|
34
|
+
fs: fs,
|
|
35
|
+
inflector: inflector,
|
|
36
|
+
namespace: namespace,
|
|
37
|
+
key: inflector.underscore(key),
|
|
38
|
+
base_path: base_path,
|
|
39
|
+
extra_namespace: "Actions",
|
|
40
|
+
)
|
|
44
41
|
end
|
|
45
42
|
|
|
46
|
-
def
|
|
47
|
-
|
|
43
|
+
def spec_content(class_name)
|
|
44
|
+
<<~RUBY
|
|
45
|
+
# frozen_string_literal: true
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
).result(context.ctx)
|
|
52
|
-
end
|
|
47
|
+
RSpec.describe #{class_name} do
|
|
48
|
+
let(:params) { Hash[] }
|
|
53
49
|
|
|
54
|
-
|
|
50
|
+
it "works" do
|
|
51
|
+
response = subject.call(params)
|
|
52
|
+
expect(response).to be_successful
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
RUBY
|
|
56
|
+
end
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
59
|
end
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe <%= camelized_app_name %>::Views::Part do
|
|
4
|
-
<%- if ruby_omit_hash_values? -%>
|
|
5
4
|
subject { described_class.new(value:) }
|
|
6
|
-
<%- else -%>
|
|
7
|
-
subject { described_class.new(value: value) }
|
|
8
|
-
<%- end -%>
|
|
9
5
|
let(:value) { double("value") }
|
|
10
6
|
|
|
11
7
|
it "works" do
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe <%= camelized_slice_name %>::Views::Part do
|
|
4
|
-
<%- if ruby_omit_hash_values? -%>
|
|
5
4
|
subject { described_class.new(value:) }
|
|
6
|
-
<%- else -%>
|
|
7
|
-
subject { described_class.new(value: value) }
|
|
8
|
-
<%- end -%>
|
|
9
5
|
let(:value) { double("value") }
|
|
10
6
|
|
|
11
7
|
it "works" do
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe <%= camelized_slice_name %>::Views::Parts::<%= camelized_name %> do
|
|
4
|
-
<%- if ruby_omit_hash_values? -%>
|
|
5
4
|
subject { described_class.new(value:) }
|
|
6
|
-
<%- else -%>
|
|
7
|
-
subject { described_class.new(value: value) }
|
|
8
|
-
<%- end -%>
|
|
9
5
|
let(:value) { double("<%= underscored_name %>") }
|
|
10
6
|
|
|
11
7
|
it "works" do
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe <%= camelized_app_name %>::Views::Parts::<%= camelized_name %> do
|
|
4
|
-
<%- if ruby_omit_hash_values? -%>
|
|
5
4
|
subject { described_class.new(value:) }
|
|
6
|
-
<%- else -%>
|
|
7
|
-
subject { described_class.new(value: value) }
|
|
8
|
-
<%- end -%>
|
|
9
5
|
let(:value) { double("<%= underscored_name %>") }
|
|
10
6
|
|
|
11
7
|
it "works" do
|
|
@@ -17,7 +17,19 @@ module Hanami
|
|
|
17
17
|
|
|
18
18
|
# @since 2.1.0
|
|
19
19
|
# @api private
|
|
20
|
-
def call(app, slice, name
|
|
20
|
+
def call(app, slice, name)
|
|
21
|
+
context = Struct.new(
|
|
22
|
+
:camelized_app_name,
|
|
23
|
+
:camelized_slice_name,
|
|
24
|
+
:camelized_name,
|
|
25
|
+
:underscored_name
|
|
26
|
+
).new(
|
|
27
|
+
inflector.camelize(app),
|
|
28
|
+
slice ? inflector.camelize(slice) : nil,
|
|
29
|
+
inflector.camelize(name),
|
|
30
|
+
inflector.underscore(name)
|
|
31
|
+
)
|
|
32
|
+
|
|
21
33
|
if slice
|
|
22
34
|
generate_for_slice(slice, context)
|
|
23
35
|
else
|
|
@@ -90,7 +102,7 @@ module Hanami
|
|
|
90
102
|
ERB.new(
|
|
91
103
|
File.read(__dir__ + "/part/#{path}"),
|
|
92
104
|
trim_mode: "-"
|
|
93
|
-
).result(context.
|
|
105
|
+
).result(context.instance_eval { binding })
|
|
94
106
|
end
|
|
95
107
|
|
|
96
108
|
# @since 2.1.0
|
|
@@ -17,7 +17,12 @@ module Hanami
|
|
|
17
17
|
|
|
18
18
|
# @since 2.0.0
|
|
19
19
|
# @api private
|
|
20
|
-
def call(slice
|
|
20
|
+
def call(slice)
|
|
21
|
+
context = Struct.new(:slice, :camelized_slice_name).new(
|
|
22
|
+
slice,
|
|
23
|
+
inflector.camelize(slice)
|
|
24
|
+
)
|
|
25
|
+
|
|
21
26
|
fs.write("spec/slices/#{slice}/action_spec.rb", t("action_spec.erb", context))
|
|
22
27
|
# fs.write("spec/slices/#{slice}/view_spec.rb", t("view_spec.erb", context))
|
|
23
28
|
# fs.write("spec/slices/#{slice}/repository_spec.rb", t("repository_spec.erb", context))
|
|
@@ -41,7 +46,7 @@ module Hanami
|
|
|
41
46
|
|
|
42
47
|
ERB.new(
|
|
43
48
|
File.read(__dir__ + "/slice/#{path}")
|
|
44
|
-
).result(context.
|
|
49
|
+
).result(context.instance_eval { binding })
|
|
45
50
|
end
|
|
46
51
|
|
|
47
52
|
alias_method :t, :template
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
require "rack/test"
|
|
4
4
|
|
|
5
|
-
RSpec.shared_context "Rack::Test" do
|
|
5
|
+
RSpec.shared_context "with Rack::Test" do
|
|
6
6
|
# Define the app for Rack::Test requests
|
|
7
7
|
let(:app) { Hanami.app }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
RSpec.configure do |config|
|
|
11
11
|
config.include Rack::Test::Methods, type: :request
|
|
12
|
-
config.include_context "Rack::Test", type: :request
|
|
12
|
+
config.include_context "with Rack::Test", type: :request
|
|
13
13
|
end
|
data/lib/hanami/rspec/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hanami-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0.beta2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Luca Guidi
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: hanami-cli
|
|
@@ -16,14 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 2.3.0.beta2
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
25
|
+
version: 2.3.0.beta2
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: rspec
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -104,8 +103,6 @@ files:
|
|
|
104
103
|
- lib/hanami/rspec.rb
|
|
105
104
|
- lib/hanami/rspec/commands.rb
|
|
106
105
|
- lib/hanami/rspec/generators/action.rb
|
|
107
|
-
- lib/hanami/rspec/generators/action/action_slice_spec.erb
|
|
108
|
-
- lib/hanami/rspec/generators/action/action_spec.erb
|
|
109
106
|
- lib/hanami/rspec/generators/dotrspec
|
|
110
107
|
- lib/hanami/rspec/generators/gemfile
|
|
111
108
|
- lib/hanami/rspec/generators/gemfile_db
|
|
@@ -139,7 +136,6 @@ metadata:
|
|
|
139
136
|
source_code_uri: https://github.com/hanami/rspec
|
|
140
137
|
changelog_uri: https://github.com/hanami/rspec/blob/master/CHANGELOG.md
|
|
141
138
|
rubygems_mfa_required: 'true'
|
|
142
|
-
post_install_message:
|
|
143
139
|
rdoc_options: []
|
|
144
140
|
require_paths:
|
|
145
141
|
- lib
|
|
@@ -147,15 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
147
143
|
requirements:
|
|
148
144
|
- - ">="
|
|
149
145
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: '3.
|
|
146
|
+
version: '3.2'
|
|
151
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
148
|
requirements:
|
|
153
149
|
- - ">="
|
|
154
150
|
- !ruby/object:Gem::Version
|
|
155
151
|
version: '0'
|
|
156
152
|
requirements: []
|
|
157
|
-
rubygems_version: 3.
|
|
158
|
-
signing_key:
|
|
153
|
+
rubygems_version: 3.6.9
|
|
159
154
|
specification_version: 4
|
|
160
155
|
summary: Hanami RSpec
|
|
161
156
|
test_files: []
|
|
@@ -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
|