hanami-rspec 2.3.1 → 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 +23 -16
- data/.rubocop.yml +0 -2
- data/CHANGELOG.md +4 -170
- data/Gemfile +5 -5
- data/LICENSE.txt +21 -0
- data/README.md +17 -7
- data/hanami-rspec.gemspec +5 -6
- data/lib/hanami/rspec/commands.rb +24 -121
- 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 -5
- data/lib/hanami/rspec.rb +2 -39
- data/lib/hanami-rspec.rb +1 -1
- metadata +20 -38
- data/LICENSE.md +0 -22
- data/lib/hanami/rspec/generators/gemfile_db +0 -9
- data/lib/hanami/rspec/generators/gitignore +0 -1
- 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 -42
- data/lib/hanami/rspec/generators/support_features.rb +0 -5
- data/lib/hanami/rspec/generators/support_operations.rb +0 -8
|
@@ -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,42 +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
|
-
slices = [Hanami.app] + Hanami.app.slices.with_nested
|
|
14
|
-
|
|
15
|
-
slices.each_with_object([]) { |slice, dbs|
|
|
16
|
-
next unless slice.key?("db.rom")
|
|
17
|
-
|
|
18
|
-
dbs.concat slice["db.rom"].gateways.values.map(&:connection)
|
|
19
|
-
}.uniq
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
config.before :suite do
|
|
23
|
-
all_databases.call.each do |db|
|
|
24
|
-
DatabaseCleaner[:sequel, db: db].clean_with :truncation, except: ["schema_migrations"]
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
config.before :each, :db do |example|
|
|
29
|
-
strategy = example.metadata[:js] ? :truncation : :transaction
|
|
30
|
-
|
|
31
|
-
all_databases.call.each do |db|
|
|
32
|
-
DatabaseCleaner[:sequel, db: db].strategy = strategy
|
|
33
|
-
DatabaseCleaner[:sequel, db: db].start
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
config.after :each, :db do
|
|
38
|
-
all_databases.call.each do |db|
|
|
39
|
-
DatabaseCleaner[:sequel, db: db].clean
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|