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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +50 -0
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.rubocop.yml +26 -0
- data/CHANGELOG.md +7 -208
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -17
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/hanami-rspec.gemspec +26 -26
- data/lib/hanami/rspec/commands.rb +25 -109
- data/lib/hanami/rspec/error.rb +8 -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 +29 -36
- data/lib/hanami/rspec/generators/gemfile +0 -2
- data/lib/hanami/rspec/generators/helper.rb +2 -1
- data/lib/hanami/rspec/generators/request.rb +4 -4
- data/lib/hanami/rspec/generators/slice.rb +13 -23
- data/lib/hanami/rspec/generators/support_requests.rb +2 -3
- data/lib/hanami/rspec/generators/support_rspec.rb +2 -36
- data/lib/hanami/rspec/generators.rb +10 -0
- data/lib/hanami/rspec/rake_tasks.rb +2 -0
- data/lib/hanami/rspec/version.rb +1 -4
- data/lib/hanami/rspec.rb +2 -47
- data/lib/hanami-rspec.rb +1 -1
- metadata +41 -41
- data/LICENSE +0 -20
- data/lib/hanami/rspec/generators/gemfile_db +0 -9
- data/lib/hanami/rspec/generators/gitignore +0 -1
- data/lib/hanami/rspec/generators/mailer.rb +0 -60
- data/lib/hanami/rspec/generators/operation.rb +0 -59
- data/lib/hanami/rspec/generators/part/part_base_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part/part_slice_base_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part/part_slice_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part/part_spec.erb +0 -10
- data/lib/hanami/rspec/generators/part.rb +0 -114
- data/lib/hanami/rspec/generators/support_db.rb +0 -10
- data/lib/hanami/rspec/generators/support_db_cleaning.rb +0 -40
- data/lib/hanami/rspec/generators/support_features.rb +0 -5
- data/lib/hanami/rspec/generators/support_mailers.rb +0 -20
- data/lib/hanami/rspec/generators/support_operations.rb +0 -9
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "hanami/cli"
|
|
3
4
|
require "shellwords"
|
|
5
|
+
require "hanami/cli/commands/app/command"
|
|
6
|
+
require "hanami/cli/generators/context"
|
|
7
|
+
require_relative "./generators"
|
|
4
8
|
|
|
5
9
|
module Hanami
|
|
6
10
|
module RSpec
|
|
7
|
-
# @api private
|
|
8
11
|
module Commands
|
|
9
12
|
class Install < Hanami::CLI::Command
|
|
10
13
|
def call(*, **)
|
|
11
14
|
append_gemfile
|
|
12
|
-
append_gitignore
|
|
13
15
|
copy_dotrspec
|
|
14
16
|
copy_spec_helper
|
|
15
17
|
copy_support_rspec
|
|
16
|
-
copy_support_db
|
|
17
|
-
copy_support_features
|
|
18
|
-
copy_support_operations
|
|
19
|
-
copy_support_mailers
|
|
20
18
|
copy_support_requests
|
|
21
19
|
|
|
22
20
|
generate_request_spec
|
|
@@ -25,25 +23,18 @@ module Hanami
|
|
|
25
23
|
private
|
|
26
24
|
|
|
27
25
|
def append_gemfile
|
|
28
|
-
gemfile_template = Hanami.bundled?("hanami-db") ? "gemfile_db" : "gemfile"
|
|
29
|
-
|
|
30
26
|
fs.append(
|
|
31
27
|
fs.expand_path("Gemfile"),
|
|
32
|
-
fs.read(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def append_gitignore
|
|
37
|
-
fs.append(
|
|
38
|
-
fs.expand_path(".gitignore"),
|
|
39
|
-
fs.read(fs.expand_path(fs.join("generators", "gitignore"), __dir__))
|
|
28
|
+
fs.read(
|
|
29
|
+
fs.expand_path(fs.join("generators", "gemfile"), __dir__)
|
|
30
|
+
),
|
|
40
31
|
)
|
|
41
32
|
end
|
|
42
33
|
|
|
43
34
|
def copy_dotrspec
|
|
44
35
|
fs.cp(
|
|
45
36
|
fs.expand_path(fs.join("generators", "dotrspec"), __dir__),
|
|
46
|
-
fs.expand_path(fs.join(".rspec"))
|
|
37
|
+
fs.expand_path(fs.join(".rspec")),
|
|
47
38
|
)
|
|
48
39
|
end
|
|
49
40
|
|
|
@@ -61,43 +52,6 @@ module Hanami
|
|
|
61
52
|
)
|
|
62
53
|
end
|
|
63
54
|
|
|
64
|
-
def copy_support_db
|
|
65
|
-
return unless Hanami.bundled?("hanami-db")
|
|
66
|
-
|
|
67
|
-
fs.cp(
|
|
68
|
-
fs.expand_path(fs.join("generators/support_db.rb"), __dir__),
|
|
69
|
-
fs.expand_path(fs.join("spec", "support", "db.rb"))
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
fs.cp(
|
|
73
|
-
fs.expand_path(fs.join("generators/support_db_cleaning.rb"), __dir__),
|
|
74
|
-
fs.expand_path(fs.join("spec", "support", "db", "cleaning.rb"))
|
|
75
|
-
)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def copy_support_features
|
|
79
|
-
fs.cp(
|
|
80
|
-
fs.expand_path(fs.join("generators", "support_features.rb"), __dir__),
|
|
81
|
-
fs.expand_path(fs.join("spec", "support", "features.rb"))
|
|
82
|
-
)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def copy_support_operations
|
|
86
|
-
fs.cp(
|
|
87
|
-
fs.expand_path(fs.join("generators", "support_operations.rb"), __dir__),
|
|
88
|
-
fs.expand_path(fs.join("spec", "support", "operations.rb"))
|
|
89
|
-
)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def copy_support_mailers
|
|
93
|
-
return unless Hanami.bundled?("hanami-mailer")
|
|
94
|
-
|
|
95
|
-
fs.cp(
|
|
96
|
-
fs.expand_path(fs.join("generators", "support_mailers.rb"), __dir__),
|
|
97
|
-
fs.expand_path(fs.join("spec", "support", "mailers.rb"))
|
|
98
|
-
)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
55
|
def copy_support_requests
|
|
102
56
|
fs.cp(
|
|
103
57
|
fs.expand_path(fs.join("generators", "support_requests.rb"), __dir__),
|
|
@@ -115,8 +69,9 @@ module Hanami
|
|
|
115
69
|
|
|
116
70
|
module Generate
|
|
117
71
|
class Slice < Hanami::CLI::Command
|
|
118
|
-
|
|
119
|
-
|
|
72
|
+
# FIXME: dry-cli kwargs aren't correctly forwarded in Ruby 3
|
|
73
|
+
def call(options, **)
|
|
74
|
+
slice = inflector.underscore(Shellwords.shellescape(options[:name]))
|
|
120
75
|
|
|
121
76
|
generator = Generators::Slice.new(fs: fs, inflector: inflector)
|
|
122
77
|
generator.call(slice)
|
|
@@ -124,62 +79,23 @@ module Hanami
|
|
|
124
79
|
end
|
|
125
80
|
|
|
126
81
|
class Action < Hanami::CLI::Commands::App::Command
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
generator = Generators::Action.new(fs:, inflector:)
|
|
137
|
-
generator.call(key:, namespace:, base_path:)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
class Part < Hanami::CLI::Commands::App::Command
|
|
142
|
-
def call(name: nil, slice: nil, skip_tests: false, **)
|
|
143
|
-
return if skip_tests
|
|
144
|
-
|
|
145
|
-
slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
|
|
146
|
-
name = inflector.underscore(Shellwords.shellescape(name))
|
|
147
|
-
|
|
148
|
-
generator = Generators::Part.new(fs: fs, inflector: inflector)
|
|
149
|
-
generator.call(app.namespace, slice, name)
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
class Operation < Hanami::CLI::Commands::App::Command
|
|
154
|
-
def call(name: nil, slice: nil, skip_tests: false, **)
|
|
155
|
-
return if skip_tests
|
|
156
|
-
|
|
157
|
-
slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
|
|
158
|
-
key = inflector.underscore(Shellwords.shellescape(name))
|
|
159
|
-
|
|
160
|
-
namespace = slice ? inflector.camelize(slice) : app.namespace
|
|
161
|
-
base_path = slice ? "spec/slices/#{slice}" : "spec"
|
|
162
|
-
|
|
163
|
-
generator = Generators::Operation.new(fs:, inflector:)
|
|
164
|
-
generator.call(key:, namespace:, base_path:)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
class Mailer < Hanami::CLI::Commands::App::Command
|
|
169
|
-
def call(name: nil, slice: nil, skip_tests: false, **)
|
|
170
|
-
return if skip_tests
|
|
171
|
-
|
|
172
|
-
slice = inflector.underscore(Shellwords.shellescape(slice)) if slice
|
|
173
|
-
key = inflector.underscore(Shellwords.shellescape(name))
|
|
174
|
-
|
|
175
|
-
namespace = slice ? inflector.camelize(slice) : app.namespace
|
|
176
|
-
base_path = slice ? "spec/slices/#{slice}" : "spec"
|
|
177
|
-
|
|
178
|
-
generator = Generators::Mailer.new(fs:, inflector:)
|
|
179
|
-
generator.call(key:, namespace:, base_path:)
|
|
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)
|
|
180
90
|
end
|
|
181
91
|
end
|
|
182
92
|
end
|
|
183
93
|
end
|
|
184
94
|
end
|
|
185
95
|
end
|
|
96
|
+
|
|
97
|
+
if Hanami::CLI.within_hanami_app?
|
|
98
|
+
Hanami::CLI.after "install", Hanami::RSpec::Commands::Install
|
|
99
|
+
Hanami::CLI.after "generate slice", Hanami::RSpec::Commands::Generate::Slice
|
|
100
|
+
Hanami::CLI.after "generate action", Hanami::RSpec::Commands::Generate::Action
|
|
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
|
|
@@ -1,59 +1,52 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "erb"
|
|
4
|
+
require "hanami/cli/generators/app/action_context"
|
|
4
5
|
|
|
5
6
|
module Hanami
|
|
6
7
|
module RSpec
|
|
7
8
|
module Generators
|
|
8
|
-
# @since 2.0.0
|
|
9
|
-
# @api private
|
|
10
9
|
class Action
|
|
11
|
-
# @since 2.0.0
|
|
12
|
-
# @api private
|
|
13
10
|
def initialize(fs:, inflector:)
|
|
14
11
|
@fs = fs
|
|
15
12
|
@inflector = inflector
|
|
16
13
|
end
|
|
17
14
|
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
private
|
|
29
30
|
|
|
30
|
-
attr_reader :fs
|
|
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
|
-
)
|
|
41
|
-
end
|
|
31
|
+
attr_reader :fs
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
<<~RUBY
|
|
45
|
-
# frozen_string_literal: true
|
|
33
|
+
attr_reader :inflector
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
# @api private
|
|
36
|
+
# @param controller [Array<String>]
|
|
37
|
+
def controller_directory(controller)
|
|
38
|
+
fs.join(controller)
|
|
39
|
+
end
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
def template(path, context)
|
|
42
|
+
require "erb"
|
|
43
|
+
|
|
44
|
+
ERB.new(
|
|
45
|
+
File.read(__dir__ + "/action/#{path}")
|
|
46
|
+
).result(context.ctx)
|
|
56
47
|
end
|
|
48
|
+
|
|
49
|
+
alias_method :t, :template
|
|
57
50
|
end
|
|
58
51
|
end
|
|
59
52
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.describe "Root", type: :request do
|
|
4
|
-
it "is
|
|
4
|
+
it "is successful" do
|
|
5
5
|
get "/"
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
expect(last_response.
|
|
7
|
+
# Find me in `config/routes.rb`
|
|
8
|
+
expect(last_response).to be_successful
|
|
9
|
+
expect(last_response.body).to eq("Hello from Hanami")
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -1,38 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "erb"
|
|
4
|
+
require "hanami/cli/generators/app/slice_context"
|
|
4
5
|
|
|
5
6
|
module Hanami
|
|
6
7
|
module RSpec
|
|
7
8
|
module Generators
|
|
8
|
-
# @since 2.0.0
|
|
9
|
-
# @api private
|
|
10
9
|
class Slice
|
|
11
|
-
# @since 2.0.0
|
|
12
|
-
# @api private
|
|
13
10
|
def initialize(fs:, inflector:)
|
|
14
11
|
@fs = fs
|
|
15
12
|
@inflector = inflector
|
|
16
13
|
end
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
fs.write("spec
|
|
27
|
-
# fs.write("spec
|
|
28
|
-
# fs.write("spec
|
|
29
|
-
|
|
30
|
-
fs.write("spec/slices/#{slice}/actions/.keep", t("keep.erb", context))
|
|
31
|
-
# fs.write("spec/slices/#{slice}/views/.keep", t("keep.erb", context))
|
|
32
|
-
# fs.write("spec/slices/#{slice}/templates/.keep", t("keep.erb", context))
|
|
33
|
-
# fs.write("spec/slices/#{slice}/templates/layouts/.keep", t("keep.erb", context))
|
|
34
|
-
# fs.write("spec/slices/#{slice}/entities/.keep", t("keep.erb", context))
|
|
35
|
-
# fs.write("spec/slices/#{slice}/repositories/.keep", t("keep.erb", context))
|
|
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))
|
|
36
26
|
end
|
|
37
27
|
|
|
38
28
|
private
|
|
@@ -46,7 +36,7 @@ module Hanami
|
|
|
46
36
|
|
|
47
37
|
ERB.new(
|
|
48
38
|
File.read(__dir__ + "/slice/#{path}")
|
|
49
|
-
).result(context.
|
|
39
|
+
).result(context.ctx)
|
|
50
40
|
end
|
|
51
41
|
|
|
52
42
|
alias_method :t, :template
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
require "rack/test"
|
|
4
4
|
|
|
5
|
-
RSpec.shared_context "
|
|
6
|
-
# Define the app for Rack::Test requests
|
|
5
|
+
RSpec.shared_context "Hanami app" do
|
|
7
6
|
let(:app) { Hanami.app }
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
RSpec.configure do |config|
|
|
11
10
|
config.include Rack::Test::Methods, type: :request
|
|
12
|
-
config.include_context "
|
|
11
|
+
config.include_context "Hanami app", type: :request
|
|
13
12
|
end
|
|
@@ -1,61 +1,27 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.configure do |config|
|
|
4
|
-
# Use the recommended non-monkey patched syntax.
|
|
5
|
-
config.disable_monkey_patching!
|
|
6
|
-
|
|
7
|
-
# Use and configure rspec-expectations.
|
|
8
4
|
config.expect_with :rspec do |expectations|
|
|
9
|
-
# This option will default to `true` in RSpec 4.
|
|
10
5
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
11
6
|
end
|
|
12
7
|
|
|
13
|
-
# Use and configure rspec-mocks.
|
|
14
8
|
config.mock_with :rspec do |mocks|
|
|
15
|
-
# Prevents you from mocking or stubbing a method that does not exist on a
|
|
16
|
-
# real object.
|
|
17
9
|
mocks.verify_partial_doubles = true
|
|
18
10
|
end
|
|
19
11
|
|
|
20
|
-
# This option will default to `:apply_to_host_groups` in RSpec 4.
|
|
21
12
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
22
13
|
|
|
23
|
-
# Limit a spec run to individual examples or groups you care about by tagging
|
|
24
|
-
# them with `:focus` metadata. When nothing is tagged with `:focus`, all
|
|
25
|
-
# examples get run.
|
|
26
|
-
#
|
|
27
|
-
# RSpec also provides aliases for `it`, `describe`, and `context` that include
|
|
28
|
-
# `:focus` metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
29
14
|
config.filter_run_when_matching :focus
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# configure your source control system to ignore this file.
|
|
34
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
35
|
-
|
|
36
|
-
# Uncomment this to enable warnings. This is recommended, but in some cases
|
|
37
|
-
# may be too noisy due to issues in dependencies.
|
|
38
|
-
# config.warnings = true
|
|
16
|
+
config.disable_monkey_patching!
|
|
17
|
+
config.warnings = true
|
|
39
18
|
|
|
40
|
-
# Show more verbose output when running an individual spec file.
|
|
41
19
|
if config.files_to_run.one?
|
|
42
20
|
config.default_formatter = "doc"
|
|
43
21
|
end
|
|
44
22
|
|
|
45
|
-
# Print the 10 slowest examples and example groups at the end of the spec run,
|
|
46
|
-
# to help surface which specs are running particularly slow.
|
|
47
23
|
config.profile_examples = 10
|
|
48
24
|
|
|
49
|
-
# Run specs in random order to surface order dependencies. If you find an
|
|
50
|
-
# order dependency and want to debug it, you can fix the order by providing
|
|
51
|
-
# the seed, which is printed after each run:
|
|
52
|
-
#
|
|
53
|
-
# --seed 1234
|
|
54
25
|
config.order = :random
|
|
55
|
-
|
|
56
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
|
57
|
-
# This allows you to use `--seed` to deterministically reproduce test failures
|
|
58
|
-
# related to randomization by passing the same `--seed` value as the one that
|
|
59
|
-
# triggered the failure.
|
|
60
26
|
Kernel.srand config.seed
|
|
61
27
|
end
|
data/lib/hanami/rspec/version.rb
CHANGED
data/lib/hanami/rspec.rb
CHANGED
|
@@ -1,55 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "hanami/cli"
|
|
4
|
-
require "zeitwerk"
|
|
5
|
-
|
|
6
|
-
# @see Hanami::RSpec
|
|
7
|
-
# @since 2.0.0
|
|
8
3
|
module Hanami
|
|
9
|
-
# RSpec and testing support for Hanami applications.
|
|
10
|
-
#
|
|
11
|
-
# @since 2.0.0
|
|
12
|
-
# @api private
|
|
13
4
|
module RSpec
|
|
14
|
-
# @since 2.0.0
|
|
15
|
-
# @api private
|
|
16
|
-
def self.gem_loader
|
|
17
|
-
@gem_loader ||= Zeitwerk::Loader.new.tap do |loader|
|
|
18
|
-
root = File.expand_path("..", __dir__)
|
|
19
|
-
loader.tag = "hanami-rspec"
|
|
20
|
-
loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami-rspec.rb")
|
|
21
|
-
loader.push_dir(root)
|
|
22
|
-
loader.ignore(
|
|
23
|
-
"#{root}/hanami-rspec.rb",
|
|
24
|
-
"#{root}/hanami/rspec/{rake_tasks,version}.rb"
|
|
25
|
-
)
|
|
26
|
-
loader.inflector.inflect("rspec" => "RSpec")
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
gem_loader.setup
|
|
31
5
|
require_relative "rspec/version"
|
|
6
|
+
require_relative "rspec/error"
|
|
7
|
+
require_relative "rspec/commands"
|
|
32
8
|
require_relative "rspec/rake_tasks"
|
|
33
|
-
|
|
34
|
-
if Hanami::CLI.within_hanami_app?
|
|
35
|
-
Hanami::CLI.before "install", Commands::Install
|
|
36
|
-
Hanami::CLI.after "generate slice", Commands::Generate::Slice
|
|
37
|
-
|
|
38
|
-
if Hanami.bundled?("dry-operation")
|
|
39
|
-
Hanami::CLI.after "generate operation", Commands::Generate::Operation
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
if Hanami.bundled?("hanami-action")
|
|
43
|
-
Hanami::CLI.after "generate action", Commands::Generate::Action
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
if Hanami.bundled?("hanami-view")
|
|
47
|
-
Hanami::CLI.after "generate part", Commands::Generate::Part
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
if Hanami.bundled?("hanami-mailer")
|
|
51
|
-
Hanami::CLI.after "generate mailer", Commands::Generate::Mailer
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
9
|
end
|
|
55
10
|
end
|
data/lib/hanami-rspec.rb
CHANGED