fixture_farm 0.2.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72792ee8f5bca838e5fda1e5ec3088e4c97ec40e740b732734cc0529304afdf4
4
- data.tar.gz: c14d543f77631a323abbcee6ce81d1d52afbb04785a2ba82d611f29ebd6e39b8
3
+ metadata.gz: 9e4fa3f5f217235e3e58daee4b86bdc73ef09e4f76e734aa04febf16a426d582
4
+ data.tar.gz: f40780e8cce2ea4e2c0cbb9d59bbb7df0023c26d0641ab3c1fa5b60ddb6f9ced
5
5
  SHA512:
6
- metadata.gz: af76dc042d9d51ede677265a6da0cf0203d2934db1bd7b2d218569519df5cdf34a5b1951ce958b90efa2955df5dae6e3fda25a059df2cad31969cece715743c7
7
- data.tar.gz: 1ddc003eade3440055aa754290ffea23cca62c0c71c72c3e38e2a4f783255828ad2860400415e33aa1f7f97b4a7e0b7e14a7d969f8e7544aaf39bbd7ecd9c899
6
+ metadata.gz: dd1a5b198b030b279fa0db95d823b8b6306866cf4440438eea24d2feb8bb25d034f9e136358ad3875e7d59fce384dfce03271ceb7476262625fe5d178a6a465c
7
+ data.tar.gz: 66d3463eb28a3e77500307a6cac81ef84a0fccfa977bc3151683685d7c6f7e69f5ee629f3f4c523ff413b3740615fd40a14c8e7bc9b290c4a372699786a7bfa2
data/README.md CHANGED
@@ -104,7 +104,9 @@ test 'authors fixtures must have at least one post' do
104
104
  end
105
105
  ```
106
106
 
107
- Now let's the option to automatically record missing fixtures:
107
+ Let's say this test is currently failing.
108
+
109
+ Now let's add the option to automatically record missing fixtures:
108
110
 
109
111
  ```ruby
110
112
  test 'authors fixtures must have at least one post' do
@@ -116,12 +118,13 @@ test 'authors fixtures must have at least one post' do
116
118
  author.posts.create!(text: 'some text')
117
119
  end
118
120
  end
119
- else
120
- assert_empty offending_records
121
121
  end
122
+
123
+ assert_empty offending_records
122
124
  end
123
125
  ```
124
126
 
127
+ Running this test with `RECORD_FIXTURES=1` will generate missing fixture entries in `test/fixtures/posts.yml`. Now re-run the test again and it's passing.
125
128
 
126
129
  ## License
127
130
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -7,7 +7,7 @@ module FixtureFarm
7
7
 
8
8
  return nil unless File.exist?(fixtures_file_path)
9
9
 
10
- fixtures = YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess])
10
+ fixtures = YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) || {}
11
11
  fixtures.keys.find do |key|
12
12
  ActiveRecord::FixtureSet.identify(key) == id
13
13
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FixtureFarm
4
- mattr_accessor :parent_models_to_ignore_when_naming_fixtures
4
+ mattr_accessor :parent_models_to_ignore_when_naming_fixtures, default: []
5
5
 
6
6
  class FixtureRecorder
7
7
  STORE_PATH = Rails.root.join('tmp', 'fixture_farm_store.json')
@@ -157,7 +157,11 @@ module FixtureFarm
157
157
 
158
158
  fixtures_file_path = model_instance.fixtures_file_path
159
159
 
160
- fixtures = File.exist?(fixtures_file_path) ? YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) : {}
160
+ fixtures = if File.exist?(fixtures_file_path)
161
+ YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) || {}
162
+ else
163
+ {}
164
+ end
161
165
  fixtures[new_fixture_name] = yaml_attributes
162
166
 
163
167
  FileUtils.mkdir_p(fixtures_file_path.dirname)
@@ -1,3 +1,3 @@
1
1
  module FixtureFarm
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixture_farm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - artemave
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-13 00:00:00.000000000 Z
11
+ date: 2025-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails