fixture_builder 0.5.2 → 0.5.3.rc2
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/README.markdown +1 -1
- data/lib/fixture_builder/builder.rb +1 -1
- data/lib/fixture_builder/configuration.rb +4 -2
- data/lib/fixture_builder/version.rb +1 -1
- data/test/fixture_builder_test.rb +18 -0
- 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: 6960984d23f57205013cfbeb21f7ca1f261b112a5fccdd1b6d08f6fc2dcc2e90
|
4
|
+
data.tar.gz: b484db209790fb4926306f42906ad706a7c548d50020d8883cab58536440213f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b73f1cad2d377dff0238ab09d049288e7c9133716d79ff82bf054a5ac559b2e7a8baadd0b343231b31815baa46d7eb2950d9c3b1222e1a300fe083e8e06caa3
|
7
|
+
data.tar.gz: 6e5af6db6d0597e7b2a7437bd0bf964d19ef34795d506367d0f9c583375b1948af3c364ec2ebd7d04a6e30d32e086877b5ec523fffa67a9cbf957c150cfc805e
|
data/README.markdown
CHANGED
@@ -99,7 +99,7 @@ module FixtureBuilder
|
|
99
99
|
table_klass = table_name.classify.constantize rescue nil
|
100
100
|
if table_klass && table_klass < ActiveRecord::Base
|
101
101
|
rows = table_klass.unscoped do
|
102
|
-
table_klass.all.collect do |obj|
|
102
|
+
table_klass.order(:id).all.collect do |obj|
|
103
103
|
attrs = obj.attributes.select { |attr_name| table_klass.column_names.include?(attr_name) }
|
104
104
|
attrs.inject({}) do |hash, (attr_name, value)|
|
105
105
|
hash[attr_name] = serialized_value_if_needed(table_klass, attr_name, value)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext'
|
2
2
|
require 'active_support/core_ext/string'
|
3
|
-
require 'digest
|
3
|
+
require 'digest'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'hashdiff'
|
6
6
|
|
@@ -24,6 +24,7 @@ module FixtureBuilder
|
|
24
24
|
|
25
25
|
def initialize(opts={})
|
26
26
|
@namer = Namer.new(self)
|
27
|
+
@use_sha1_digests = opts[:use_sha1_digests] || false
|
27
28
|
@file_hashes = file_hashes
|
28
29
|
@write_empty_files = true
|
29
30
|
end
|
@@ -115,8 +116,9 @@ module FixtureBuilder
|
|
115
116
|
private
|
116
117
|
|
117
118
|
def file_hashes
|
119
|
+
algorithm = @use_sha1_digests ? Digest::SHA1 : Digest::MD5
|
118
120
|
files_to_check.inject({}) do |hash, filename|
|
119
|
-
hash[filename] =
|
121
|
+
hash[filename] = algorithm.hexdigest(File.read(filename))
|
120
122
|
hash
|
121
123
|
end
|
122
124
|
end
|
@@ -97,4 +97,22 @@ class FixtureBuilderTest < Test::Unit::TestCase
|
|
97
97
|
generated_fixture = YAML.load(File.open(test_path("fixtures/magical_creatures.yml")))
|
98
98
|
assert_equal "---\n- shading\n- rooting\n- seeding\n", generated_fixture['enty']['powers']
|
99
99
|
end
|
100
|
+
|
101
|
+
def test_sha1_digests
|
102
|
+
create_and_blow_away_old_db
|
103
|
+
force_fixture_generation_due_to_differing_file_hashes
|
104
|
+
|
105
|
+
FixtureBuilder.configure(use_sha1_digests: true) do |fbuilder|
|
106
|
+
fbuilder.files_to_check += Dir[test_path("*.rb")]
|
107
|
+
fbuilder.factory do
|
108
|
+
@enty = MagicalCreature.create(:name => 'Enty', :species => 'ent',
|
109
|
+
:powers => %w{shading rooting seeding})
|
110
|
+
end
|
111
|
+
first_modified_time = File.mtime(test_path("fixtures/magical_creatures.yml"))
|
112
|
+
fbuilder.factory do
|
113
|
+
end
|
114
|
+
second_modified_time = File.mtime(test_path("fixtures/magical_creatures.yml"))
|
115
|
+
assert_equal first_modified_time, second_modified_time
|
116
|
+
end
|
117
|
+
end
|
100
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixture_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Dy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|