hanami-rspec 2.2.0.beta2 → 2.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/hanami-rspec.gemspec +1 -1
- data/lib/hanami/rspec/commands.rb +18 -1
- data/lib/hanami/rspec/generators/gemfile +1 -0
- data/lib/hanami/rspec/generators/gemfile_db +9 -0
- data/lib/hanami/rspec/generators/support_db.rb +10 -0
- data/lib/hanami/rspec/generators/support_db_cleaning.rb +42 -0
- data/lib/hanami/rspec/version.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2626a7d2645ea7f228d3aab1371d3b6de2593ecfb0da40a9f7d8c574d03d660
|
4
|
+
data.tar.gz: 6042163a6b58014d0a9409190af9f9ed1d076284b48c00635f448e45d33e9de6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722af505347e5353d8a4063444c18d221d14e8f1eef642b776c67b96adf539928986d126eb0eb9aebda2731fbaafcb7edea1acfb2c69b70a162efdaac4abdecc
|
7
|
+
data.tar.gz: ecb15f711f61ed8c2d6289aee506c0580aedcbaf13b38ba507a6c90972b03d2adb88c87b252d87c772f2260ce63720d0bd94ce81cd1089d28a693804d0204c5f
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
RSpec support for Hanami
|
4
4
|
|
5
|
+
## v2.2.0.rc1 - 2024-10-29
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- [Tim Riley] As part of `hanami install`, add `database_cleaner-sequel` to the `Gemfile` and generate DatabaseCleaner configuration in `spec/support/db.rb` and `spec/support/db/cleaning.rb` (#28)
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- [Seb Wilgosz] Only enhance `generate` CLI commands if the relevant gems are bundled (#26)
|
14
|
+
|
5
15
|
## v2.2.0.beta1 - 2024-07-16
|
6
16
|
|
7
17
|
### Changed
|
data/hanami-rspec.gemspec
CHANGED
@@ -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.2.
|
32
|
+
spec.add_dependency "hanami-cli", "~> 2.2.rc"
|
33
33
|
spec.add_dependency "rspec", "~> 3.12"
|
34
34
|
spec.add_dependency "rake", "~> 13.0"
|
35
35
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
@@ -18,6 +18,7 @@ module Hanami
|
|
18
18
|
copy_dotrspec
|
19
19
|
copy_spec_helper
|
20
20
|
copy_support_rspec
|
21
|
+
copy_support_db
|
21
22
|
copy_support_features
|
22
23
|
copy_support_operations
|
23
24
|
copy_support_requests
|
@@ -28,9 +29,11 @@ module Hanami
|
|
28
29
|
private
|
29
30
|
|
30
31
|
def append_gemfile
|
32
|
+
gemfile_template = Hanami.bundled?("hanami-db") ? "gemfile_db" : "gemfile"
|
33
|
+
|
31
34
|
fs.append(
|
32
35
|
fs.expand_path("Gemfile"),
|
33
|
-
fs.read(fs.expand_path(fs.join("generators",
|
36
|
+
fs.read(fs.expand_path(fs.join("generators", gemfile_template), __dir__))
|
34
37
|
)
|
35
38
|
end
|
36
39
|
|
@@ -62,6 +65,20 @@ module Hanami
|
|
62
65
|
)
|
63
66
|
end
|
64
67
|
|
68
|
+
def copy_support_db
|
69
|
+
return unless Hanami.bundled?("hanami-db")
|
70
|
+
|
71
|
+
fs.cp(
|
72
|
+
fs.expand_path(fs.join("generators/support_db.rb"), __dir__),
|
73
|
+
fs.expand_path(fs.join("spec", "support", "db.rb"))
|
74
|
+
)
|
75
|
+
|
76
|
+
fs.cp(
|
77
|
+
fs.expand_path(fs.join("generators/support_db_cleaning.rb"), __dir__),
|
78
|
+
fs.expand_path(fs.join("spec", "support", "db", "cleaning.rb"))
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
65
82
|
def copy_support_features
|
66
83
|
fs.cp(
|
67
84
|
fs.expand_path(fs.join("generators", "support_features.rb"), __dir__),
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -0,0 +1,42 @@
|
|
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
|
data/lib/hanami/rspec/version.rb
CHANGED
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: 2.2.0.
|
4
|
+
version: 2.2.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-cli
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.rc
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2.
|
26
|
+
version: 2.2.rc
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/hanami/rspec/generators/action/action_spec.erb
|
109
109
|
- lib/hanami/rspec/generators/dotrspec
|
110
110
|
- lib/hanami/rspec/generators/gemfile
|
111
|
+
- lib/hanami/rspec/generators/gemfile_db
|
111
112
|
- lib/hanami/rspec/generators/gitignore
|
112
113
|
- lib/hanami/rspec/generators/helper.rb
|
113
114
|
- lib/hanami/rspec/generators/part.rb
|
@@ -121,6 +122,8 @@ files:
|
|
121
122
|
- lib/hanami/rspec/generators/slice/keep.erb
|
122
123
|
- lib/hanami/rspec/generators/slice/repository_spec.erb
|
123
124
|
- lib/hanami/rspec/generators/slice/view_spec.erb
|
125
|
+
- lib/hanami/rspec/generators/support_db.rb
|
126
|
+
- lib/hanami/rspec/generators/support_db_cleaning.rb
|
124
127
|
- lib/hanami/rspec/generators/support_features.rb
|
125
128
|
- lib/hanami/rspec/generators/support_operations.rb
|
126
129
|
- lib/hanami/rspec/generators/support_requests.rb
|
@@ -151,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
154
|
- !ruby/object:Gem::Version
|
152
155
|
version: '0'
|
153
156
|
requirements: []
|
154
|
-
rubygems_version: 3.5.
|
157
|
+
rubygems_version: 3.5.22
|
155
158
|
signing_key:
|
156
159
|
specification_version: 4
|
157
160
|
summary: Hanami RSpec
|