fixturex 0.1.4 → 0.1.6
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/ruby.yml +3 -6
- data/Gemfile.lock +3 -3
- data/lib/fixturex/tree_builder.rb +16 -12
- data/lib/fixturex/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba442689cba33d6a107a78f02cce97607f69b122f14e7a47ed71466ebfb3ef51
|
4
|
+
data.tar.gz: 6aaa1d21d83b24a0346caf5d49df17954f08f5da559e8f1a897038d90e01c3dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa6003d12a1e64a1b680b8780e468e5e54fe05fc6992887b7c1eacb408bb113f5510d738dd8020727607667a5728fb5b9109e3c89fba587a607ba5294c15196
|
7
|
+
data.tar.gz: 6f21761a41d8802e638121fae5051f6a69a6754eabcd3479a841e2a88668e80c94eb7ef390fcfe3627793a596cad741aabad8e9e4a134e1bceaf9128c0296d52
|
data/.github/workflows/ruby.yml
CHANGED
@@ -21,15 +21,12 @@ jobs:
|
|
21
21
|
runs-on: ubuntu-latest
|
22
22
|
strategy:
|
23
23
|
matrix:
|
24
|
-
ruby-version: ['
|
24
|
+
ruby-version: ['3.3']
|
25
25
|
|
26
26
|
steps:
|
27
|
-
- uses: actions/checkout@
|
27
|
+
- uses: actions/checkout@v4
|
28
28
|
- name: Set up Ruby
|
29
|
-
|
30
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
31
|
-
# uses: ruby/setup-ruby@v1
|
32
|
-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
29
|
+
uses: ruby/setup-ruby@v1
|
33
30
|
with:
|
34
31
|
ruby-version: ${{ matrix.ruby-version }}
|
35
32
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fixturex (0.1.
|
4
|
+
fixturex (0.1.6)
|
5
5
|
rails (>= 6.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -118,7 +118,7 @@ GEM
|
|
118
118
|
mini_mime (1.1.5)
|
119
119
|
mini_portile2 (2.8.8)
|
120
120
|
minitest (5.25.5)
|
121
|
-
net-imap (0.5.
|
121
|
+
net-imap (0.5.9)
|
122
122
|
date
|
123
123
|
net-protocol
|
124
124
|
net-pop (0.1.2)
|
@@ -240,7 +240,7 @@ GEM
|
|
240
240
|
unicode-emoji (4.0.4)
|
241
241
|
uri (1.0.3)
|
242
242
|
useragent (0.16.11)
|
243
|
-
websocket-driver (0.
|
243
|
+
websocket-driver (0.8.0)
|
244
244
|
base64
|
245
245
|
websocket-extensions (>= 0.1.0)
|
246
246
|
websocket-extensions (0.1.5)
|
@@ -15,27 +15,31 @@ module Fixturex
|
|
15
15
|
fixtures_paths(model_class).each_with_object([]) do |path, acc|
|
16
16
|
fixtures = YAML.load_file(path)
|
17
17
|
fixtures.select! do |_name, attributes|
|
18
|
-
|
19
|
-
attributes['type'].nil? || attributes['type'] == model_class.name
|
18
|
+
attributes['type'].nil? || attributes['type'].constantize <= model_class
|
20
19
|
end
|
21
20
|
acc.concat(fixtures.map { |name, attributes| Fixture.new(name, path, attributes) })
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.fixtures_paths(model_class)
|
26
|
-
fixtures_paths = []
|
27
25
|
# TODO: is there a better way to find out fixtures root directory?
|
28
26
|
fixtures_root = ActiveRecord::Tasks::DatabaseTasks.fixtures_path
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
# Make subclasses/ancestors discoverable
|
29
|
+
Rails.application.eager_load!
|
30
|
+
|
31
|
+
superclasses = model_class.ancestors.select do |ancestor|
|
32
|
+
ancestor < ActiveRecord::Base
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
+
(
|
36
|
+
superclasses + [model_class] + model_class.subclasses
|
37
|
+
).filter_map do |klass|
|
38
|
+
fixture_file = "#{klass.to_s.tableize}.yml"
|
39
|
+
path = File.join(fixtures_root, *fixture_file.split('/'))
|
35
40
|
|
36
|
-
|
41
|
+
path if File.exist?(path)
|
37
42
|
end
|
38
|
-
fixtures_paths
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -91,11 +95,11 @@ module Fixturex
|
|
91
95
|
# rubocop:enable Metrics/AbcSize
|
92
96
|
|
93
97
|
def association_model_class(association)
|
94
|
-
|
98
|
+
namespace = association.active_record.name.split('::')[0..-2].join('::')
|
99
|
+
class_name = [namespace, association.class_name].filter(&:present?).join('::')
|
95
100
|
|
96
101
|
unless Object.const_defined?(class_name)
|
97
|
-
|
98
|
-
class_name = "#{namespace}::#{class_name}"
|
102
|
+
class_name = association.class_name
|
99
103
|
end
|
100
104
|
|
101
105
|
class_name.constantize
|
data/lib/fixturex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixturex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- artemave
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|