hanami-rspec 3.0.0 → 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.

Potentially problematic release.


This version of hanami-rspec might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +50 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +26 -0
  6. data/CHANGELOG.md +7 -208
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +13 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +32 -17
  11. data/Rakefile +12 -0
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/hanami-rspec.gemspec +26 -26
  15. data/lib/hanami/rspec/commands.rb +25 -109
  16. data/lib/hanami/rspec/error.rb +8 -0
  17. data/lib/hanami/rspec/generators/action/action_slice_spec.erb +10 -0
  18. data/lib/hanami/rspec/generators/action/action_spec.erb +10 -0
  19. data/lib/hanami/rspec/generators/action.rb +29 -36
  20. data/lib/hanami/rspec/generators/gemfile +0 -2
  21. data/lib/hanami/rspec/generators/helper.rb +2 -1
  22. data/lib/hanami/rspec/generators/request.rb +4 -4
  23. data/lib/hanami/rspec/generators/slice.rb +13 -23
  24. data/lib/hanami/rspec/generators/support_requests.rb +2 -3
  25. data/lib/hanami/rspec/generators/support_rspec.rb +2 -36
  26. data/lib/hanami/rspec/generators.rb +10 -0
  27. data/lib/hanami/rspec/rake_tasks.rb +2 -0
  28. data/lib/hanami/rspec/version.rb +1 -4
  29. data/lib/hanami/rspec.rb +2 -47
  30. data/lib/hanami-rspec.rb +1 -1
  31. metadata +41 -41
  32. data/LICENSE +0 -20
  33. data/lib/hanami/rspec/generators/gemfile_db +0 -9
  34. data/lib/hanami/rspec/generators/gitignore +0 -1
  35. data/lib/hanami/rspec/generators/mailer.rb +0 -60
  36. data/lib/hanami/rspec/generators/operation.rb +0 -59
  37. data/lib/hanami/rspec/generators/part/part_base_spec.erb +0 -10
  38. data/lib/hanami/rspec/generators/part/part_slice_base_spec.erb +0 -10
  39. data/lib/hanami/rspec/generators/part/part_slice_spec.erb +0 -10
  40. data/lib/hanami/rspec/generators/part/part_spec.erb +0 -10
  41. data/lib/hanami/rspec/generators/part.rb +0 -114
  42. data/lib/hanami/rspec/generators/support_db.rb +0 -10
  43. data/lib/hanami/rspec/generators/support_db_cleaning.rb +0 -40
  44. data/lib/hanami/rspec/generators/support_features.rb +0 -5
  45. data/lib/hanami/rspec/generators/support_mailers.rb +0 -20
  46. data/lib/hanami/rspec/generators/support_operations.rb +0 -9
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.11.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
- - Hanakai team
7
+ - Luca Guidi
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: hanami-cli
@@ -15,28 +16,28 @@ dependencies:
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: 3.0.0
19
+ version: 2.0.0.beta
19
20
  type: :runtime
20
21
  prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
- version: 3.0.0
26
+ version: 2.0.0.beta
26
27
  - !ruby/object:Gem::Dependency
27
28
  name: rspec
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: '3.12'
33
+ version: '3.11'
33
34
  type: :runtime
34
35
  prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
38
  - - "~>"
38
39
  - !ruby/object:Gem::Version
39
- version: '3.12'
40
+ version: '3.11'
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: rake
42
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,60 +53,56 @@ dependencies:
52
53
  - !ruby/object:Gem::Version
53
54
  version: '13.0'
54
55
  - !ruby/object:Gem::Dependency
55
- name: zeitwerk
56
+ name: rubocop
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
- version: '2.6'
61
- type: :runtime
61
+ version: '1.11'
62
+ type: :development
62
63
  prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - "~>"
66
67
  - !ruby/object:Gem::Version
67
- version: '2.6'
68
- description: Hanami RSpec generators and CLI commands
68
+ version: '1.11'
69
+ description: Hanami RSpec generators and Rake tasks
69
70
  email:
70
- - info@hanakai.org
71
+ - me@lucaguidi.com
71
72
  executables: []
72
73
  extensions: []
73
- extra_rdoc_files:
74
- - CHANGELOG.md
75
- - LICENSE
76
- - README.md
74
+ extra_rdoc_files: []
77
75
  files:
76
+ - ".github/workflows/ci.yml"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".rubocop.yml"
78
80
  - CHANGELOG.md
79
- - LICENSE
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
80
84
  - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
81
88
  - hanami-rspec.gemspec
82
89
  - lib/hanami-rspec.rb
83
90
  - lib/hanami/rspec.rb
84
91
  - lib/hanami/rspec/commands.rb
92
+ - lib/hanami/rspec/error.rb
93
+ - lib/hanami/rspec/generators.rb
85
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
86
97
  - lib/hanami/rspec/generators/dotrspec
87
98
  - lib/hanami/rspec/generators/gemfile
88
- - lib/hanami/rspec/generators/gemfile_db
89
- - lib/hanami/rspec/generators/gitignore
90
99
  - lib/hanami/rspec/generators/helper.rb
91
- - lib/hanami/rspec/generators/mailer.rb
92
- - lib/hanami/rspec/generators/operation.rb
93
- - lib/hanami/rspec/generators/part.rb
94
- - lib/hanami/rspec/generators/part/part_base_spec.erb
95
- - lib/hanami/rspec/generators/part/part_slice_base_spec.erb
96
- - lib/hanami/rspec/generators/part/part_slice_spec.erb
97
- - lib/hanami/rspec/generators/part/part_spec.erb
98
100
  - lib/hanami/rspec/generators/request.rb
99
101
  - lib/hanami/rspec/generators/slice.rb
100
102
  - lib/hanami/rspec/generators/slice/action_spec.erb
101
103
  - lib/hanami/rspec/generators/slice/keep.erb
102
104
  - lib/hanami/rspec/generators/slice/repository_spec.erb
103
105
  - lib/hanami/rspec/generators/slice/view_spec.erb
104
- - lib/hanami/rspec/generators/support_db.rb
105
- - lib/hanami/rspec/generators/support_db_cleaning.rb
106
- - lib/hanami/rspec/generators/support_features.rb
107
- - lib/hanami/rspec/generators/support_mailers.rb
108
- - lib/hanami/rspec/generators/support_operations.rb
109
106
  - lib/hanami/rspec/generators/support_requests.rb
110
107
  - lib/hanami/rspec/generators/support_rspec.rb
111
108
  - lib/hanami/rspec/rake_tasks.rb
@@ -114,10 +111,12 @@ homepage: https://hanamirb.org
114
111
  licenses:
115
112
  - MIT
116
113
  metadata:
117
- changelog_uri: https://github.com/hanami/hanami-rspec/blob/main/CHANGELOG.md
118
- source_code_uri: https://github.com/hanami/hanami-rspec
119
- bug_tracker_uri: https://github.com/hanami/hanami-rspec/issues
120
- funding_uri: https://github.com/sponsors/hanami
114
+ allowed_push_host: https://rubygems.org
115
+ homepage_uri: https://hanamirb.org
116
+ source_code_uri: https://github.com/hanami/rspec
117
+ changelog_uri: https://github.com/hanami/rspec/blob/master/CHANGELOG.md
118
+ rubygems_mfa_required: 'true'
119
+ post_install_message:
121
120
  rdoc_options: []
122
121
  require_paths:
123
122
  - lib
@@ -125,14 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
124
  requirements:
126
125
  - - ">="
127
126
  - !ruby/object:Gem::Version
128
- version: '3.3'
127
+ version: 3.0.0
129
128
  required_rubygems_version: !ruby/object:Gem::Requirement
130
129
  requirements:
131
- - - ">="
130
+ - - ">"
132
131
  - !ruby/object:Gem::Version
133
- version: '0'
132
+ version: 1.3.1
134
133
  requirements: []
135
- rubygems_version: 3.6.9
134
+ rubygems_version: 3.3.3
135
+ signing_key:
136
136
  specification_version: 4
137
- summary: Hanami RSpec generators and CLI commands
137
+ summary: Hanami RSpec
138
138
  test_files: []
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015-2026 Hanakai team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,9 +0,0 @@
1
-
2
- group :test do
3
- # Database
4
- gem "database_cleaner-sequel"
5
-
6
- # Web integration
7
- gem "capybara"
8
- gem "rack-test"
9
- end
@@ -1 +0,0 @@
1
- spec/examples.txt
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hanami/cli/generators/app/ruby_class_file"
4
-
5
- module Hanami
6
- module RSpec
7
- module Generators
8
- # @api private
9
- class Mailer
10
- attr_reader :fs, :inflector
11
-
12
- def initialize(fs:, inflector:)
13
- @fs = fs
14
- @inflector = inflector
15
- end
16
-
17
- def call(key:, namespace:, base_path:)
18
- mailer_class_file = mailer_class_file(key:, namespace:, base_path:)
19
- spec_file_path = mailer_class_file.path.gsub(/\.rb$/, "_spec.rb")
20
- mailer_class_name = mailer_class_file.fully_qualified_name
21
-
22
- fs.write(spec_file_path, spec_content(mailer_class_name))
23
- end
24
-
25
- private
26
-
27
- def mailer_class_file(key:, namespace:, base_path:)
28
- Hanami::CLI::Generators::App::RubyClassFile.new(
29
- fs:, inflector:, namespace:,
30
- key: inflector.underscore(key),
31
- base_path: base_path,
32
- extra_namespace: "Mailers"
33
- )
34
- end
35
-
36
- def spec_content(class_name)
37
- <<~RUBY
38
- # frozen_string_literal: true
39
-
40
- RSpec.describe #{class_name}, :mailers do
41
- subject(:mailer) { described_class.new }
42
-
43
- # Inspect the delivered message to set expectations on its contents:
44
- #
45
- # expect(result.message.to).to eq(["recipient@example.com"])
46
- # expect(result.message.subject).to eq("Welcome")
47
- # expect(result.message.html_body).to include("...")
48
-
49
- xit "delivers" do
50
- result = mailer.deliver
51
-
52
- expect(result).to be_success
53
- end
54
- end
55
- RUBY
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hanami/cli/generators/app/ruby_class_file"
4
-
5
- module Hanami
6
- module RSpec
7
- module Generators
8
- # @api private
9
- class Operation
10
- attr_reader :fs, :inflector
11
-
12
- def initialize(fs:, inflector:)
13
- @fs = fs
14
- @inflector = inflector
15
- end
16
-
17
- def call(key:, namespace:, base_path:)
18
- operation_class_file = operation_class_file(key:, namespace:, base_path:)
19
- spec_file_path = operation_class_file.path.gsub(/\.rb$/, "_spec.rb")
20
- operation_class_name = operation_class_file.fully_qualified_name
21
-
22
- fs.write(spec_file_path, spec_content(operation_class_name))
23
- end
24
-
25
- private
26
-
27
- def operation_class_file(key:, namespace:, base_path:)
28
- Hanami::CLI::Generators::App::RubyClassFile.new(
29
- fs:, inflector:, namespace:,
30
- key: inflector.underscore(key),
31
- base_path: base_path
32
- )
33
- end
34
-
35
- def spec_content(class_name)
36
- <<~RUBY
37
- # frozen_string_literal: true
38
-
39
- RSpec.describe #{class_name} do
40
- subject(:operation) { described_class.new }
41
-
42
- # Use `be_success` and `be_failure` (from spec/support/operations.rb) to set expectations on an
43
- # operation's result:
44
- #
45
- # expect(result).to be_success(expected_value)
46
- # expect(result).to be_failure(:some_error)
47
-
48
- xit "succeeds" do
49
- result = operation.call
50
-
51
- expect(result).to be_success
52
- end
53
- end
54
- RUBY
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe <%= camelized_app_name %>::Views::Part do
4
- subject { described_class.new(value:) }
5
- let(:value) { double("value") }
6
-
7
- it "works" do
8
- expect(subject).to be_kind_of(described_class)
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe <%= camelized_slice_name %>::Views::Part do
4
- subject { described_class.new(value:) }
5
- let(:value) { double("value") }
6
-
7
- it "works" do
8
- expect(subject).to be_kind_of(described_class)
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe <%= camelized_slice_name %>::Views::Parts::<%= camelized_name %> do
4
- subject { described_class.new(value:) }
5
- let(:value) { double("<%= underscored_name %>") }
6
-
7
- it "works" do
8
- expect(subject).to be_kind_of(described_class)
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe <%= camelized_app_name %>::Views::Parts::<%= camelized_name %> do
4
- subject { described_class.new(value:) }
5
- let(:value) { double("<%= underscored_name %>") }
6
-
7
- it "works" do
8
- expect(subject).to be_kind_of(described_class)
9
- end
10
- end
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "erb"
4
-
5
- module Hanami
6
- module RSpec
7
- module Generators
8
- # @since 2.1.0
9
- # @api private
10
- class Part
11
- # @since 2.1.0
12
- # @api private
13
- def initialize(fs:, inflector:)
14
- @fs = fs
15
- @inflector = inflector
16
- end
17
-
18
- # @since 2.1.0
19
- # @api private
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
-
33
- if slice
34
- generate_for_slice(slice, context)
35
- else
36
- generate_for_app(context)
37
- end
38
- end
39
-
40
- private
41
-
42
- # @since 2.1.0
43
- # @api private
44
- def generate_for_slice(slice, context)
45
- generate_base_part_for_app(context)
46
- generate_base_part_for_slice(context, slice)
47
-
48
- fs.write(
49
- "spec/slices/#{slice}/views/parts/#{context.underscored_name}_spec.rb",
50
- t("part_slice_spec.erb", context)
51
- )
52
- end
53
-
54
- # @since 2.1.0
55
- # @api private
56
- def generate_for_app(context)
57
- generate_base_part_for_app(context)
58
-
59
- fs.write(
60
- "spec/views/parts/#{context.underscored_name}_spec.rb",
61
- t("part_spec.erb", context)
62
- )
63
- end
64
-
65
- # @since 2.1.0
66
- # @api private
67
- def generate_base_part_for_app(context)
68
- path = fs.join("spec", "views", "part_spec.rb")
69
- return if fs.exist?(path)
70
-
71
- fs.write(
72
- path,
73
- t("part_base_spec.erb", context)
74
- )
75
- end
76
-
77
- # @since 2.1.0
78
- # @api private
79
- def generate_base_part_for_slice(context, slice)
80
- path = "spec/slices/#{slice}/views/part_spec.rb"
81
- return if fs.exist?(path)
82
-
83
- fs.write(
84
- path,
85
- t("part_slice_base_spec.erb", context)
86
- )
87
- end
88
-
89
- # @since 2.1.0
90
- # @api private
91
- attr_reader :fs
92
-
93
- # @since 2.1.0
94
- # @api private
95
- attr_reader :inflector
96
-
97
- # @since 2.1.0
98
- # @api private
99
- def template(path, context)
100
- require "erb"
101
-
102
- ERB.new(
103
- File.read(__dir__ + "/part/#{path}"),
104
- trim_mode: "-"
105
- ).result(context.instance_eval { binding })
106
- end
107
-
108
- # @since 2.1.0
109
- # @api private
110
- alias_method :t, :template
111
- end
112
- end
113
- end
114
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Tag feature spec examples as `:db`
4
- #
5
- # See support/db/cleaning.rb for how the database is cleaned around these `:db` examples.
6
- RSpec.configure do |config|
7
- config.define_derived_metadata(type: :feature) do |metadata|
8
- metadata[:db] = true
9
- end
10
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "database_cleaner/sequel"
4
-
5
- # Clean the databases between tests tagged as `:db`
6
- RSpec.configure do |config|
7
- # Returns all the configured databases across the app and its slices.
8
- #
9
- # Used in the before/after hooks below to ensure each database is cleaned between examples.
10
- #
11
- # Modify this proc (or any code below) if you only need specific databases cleaned.
12
- all_databases = -> {
13
- Hanami.app.with_slices.each_with_object([]) { |slice, dbs|
14
- next unless slice.key?("db.rom")
15
-
16
- dbs.concat slice["db.rom"].gateways.values.map(&:connection)
17
- }.uniq
18
- }
19
-
20
- config.before :suite do
21
- all_databases.call.each do |db|
22
- DatabaseCleaner[:sequel, db: db].clean_with :truncation, except: ["schema_migrations"]
23
- end
24
- end
25
-
26
- config.prepend_before :each, :db do |example|
27
- strategy = example.metadata[:js] ? :truncation : :transaction
28
-
29
- all_databases.call.each do |db|
30
- DatabaseCleaner[:sequel, db: db].strategy = strategy
31
- DatabaseCleaner[:sequel, db: db].start
32
- end
33
- end
34
-
35
- config.after :each, :db do
36
- all_databases.call.each do |db|
37
- DatabaseCleaner[:sequel, db: db].clean
38
- end
39
- end
40
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "capybara/rspec"
4
-
5
- Capybara.app = Hanami.app
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Reset recorded mail deliveries between examples tagged `:mailers`
4
- #
5
- # In the test env, mail is delivered via a shared test delivery method, so recorded deliveries
6
- # accumulate across examples. Tag any example that sends mail with `:mailers` to start with a clean
7
- # slate:
8
- #
9
- # RSpec.describe Mailers::Welcome, :mailers do
10
- # # ...
11
- # end
12
- RSpec.configure do |config|
13
- config.prepend_before :each, :mailers do
14
- Hanami.app.with_slices.each do |slice|
15
- next unless slice.key?("mailers.delivery_method")
16
-
17
- slice["mailers.delivery_method"].clear
18
- end
19
- end
20
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/monads"
4
-
5
- # Load Dry Monads' RSpec extension.
6
- #
7
- # This provides `be_success` and `be_failure` matchers for operation results, along with `Success`
8
- # and `Failure` constructors for use within your examples.
9
- Dry::Monads.load_extensions(:rspec)