easy_reference_data 0.1.0 → 1.2.0
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 +7 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +7 -0
- data/BUILD.md +18 -0
- data/ChangeLog +31 -0
- data/README.md +19 -3
- data/Rakefile +4 -0
- data/easy_reference_data.gemspec +4 -0
- data/lib/easy/reference_data/refresh.rb +41 -8
- data/lib/easy/reference_data/version.rb +2 -2
- data/lib/tasks/easy_reference_data.rake +4 -10
- data/spec/easy/reference_data/refresh_spec.rb +122 -0
- data/spec/spec_helper.rb +121 -0
- data/spec/support/models.rb +5 -0
- data/spec/support/schema.rb +11 -0
- metadata +64 -17
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f98e724b8d7d645fba3e31b1b5063bdad8a48dd7fd886a18176322c5aa963ba0
|
|
4
|
+
data.tar.gz: b4cf4cbb36e876f950e6b7448e6707f4b8a50d4f4232059fd42d2df0c56f378c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9c4009145e6aa23048edae9e02edcaae860f425973c0e7ef791adb514681a84f923285956c42879973326fc004650a0cebf46cfe4764d31da7f7fbabe8291a09
|
|
7
|
+
data.tar.gz: 51fd5e66df3981df0a7a8f836357361cb4d9949d2835704fb457602dfb2348db8e0bf5088ac40c1fbaccef348e05411d5a0cef69917ebba5cf89df0c38d8d5b2
|
data/.gitignore
CHANGED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
data/BUILD.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Build instructions
|
|
2
|
+
------------------
|
|
3
|
+
|
|
4
|
+
1. Update `lib/easy/reference_data/version.rb` with new version number
|
|
5
|
+
2. Update `ChangeLog` with description of changes
|
|
6
|
+
3. Commit and tag with new version. Eg: `v1.1.0`
|
|
7
|
+
4. Run: `gem build easy_reference_data`
|
|
8
|
+
5. Run: `gem push easy_reference_data-v<version>.gem`
|
|
9
|
+
6. Push commits and tags:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
git push origin master
|
|
13
|
+
git push origin --tags
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Finally, confirm that the published version is visible on RubyGems:
|
|
17
|
+
|
|
18
|
+
https://rubygems.org/gems/easy_reference_data
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
1.2.0 - 2021-05-27
|
|
2
|
+
|
|
3
|
+
Bug fixes
|
|
4
|
+
|
|
5
|
+
* Replace Rails 6.1 deprecated `update_attributes!` with `update!`
|
|
6
|
+
|
|
7
|
+
1.1.0 - 2019-02-05
|
|
8
|
+
|
|
9
|
+
Enhancements
|
|
10
|
+
|
|
11
|
+
* added option to wrap in a transaction
|
|
12
|
+
|
|
13
|
+
1.0.0 - 2017-07-18
|
|
14
|
+
|
|
15
|
+
Enhancements
|
|
16
|
+
|
|
17
|
+
* added .update_or_create method to replace the implementation of .refresh
|
|
18
|
+
.update_or_create allows you to use a combination of keys to identity records that have no single unique attribute.
|
|
19
|
+
|
|
20
|
+
0.1.2 - 2012-11-15
|
|
21
|
+
|
|
22
|
+
Bug fixes
|
|
23
|
+
|
|
24
|
+
* don't use mass assignment operation for creating new records
|
|
25
|
+
|
|
26
|
+
0.1.1 - 2012-11-15
|
|
27
|
+
|
|
28
|
+
Enhancements
|
|
29
|
+
|
|
30
|
+
* add extra output messages when creating/updating reference data
|
|
31
|
+
|
|
1
32
|
0.1.0 - 2012-11-14
|
|
2
33
|
|
|
3
34
|
Bug fixes
|
data/README.md
CHANGED
|
@@ -22,9 +22,18 @@ Place references in 'db/reference/'
|
|
|
22
22
|
|
|
23
23
|
References will be loaded in ascending order, so if an order is desired, prepend 000, 001, 002... etc to the filename.
|
|
24
24
|
|
|
25
|
+
If an unhandled error occurs during the loading of a specific file, then all the data loaded prior to the error will remain.
|
|
26
|
+
|
|
25
27
|
Run with:
|
|
28
|
+
|
|
26
29
|
rake easy:reference_data:refresh
|
|
27
30
|
|
|
31
|
+
To have all the reference data files loaded in one transaction, run with:
|
|
32
|
+
|
|
33
|
+
rake easy:reference_data:refresh[wrap_in_transaction]
|
|
34
|
+
|
|
35
|
+
The `wrap_in_transaction` parameter will wrap the entire load process in a single transaction. This means any unhandled errors will result in all the data loaded prior to the error being rolled back.
|
|
36
|
+
|
|
28
37
|
## Deployment
|
|
29
38
|
|
|
30
39
|
Add this line to your application's deploy.rb file:
|
|
@@ -36,9 +45,16 @@ Add this line to your application's deploy.rb file:
|
|
|
36
45
|
The below example ensures that there are 3 users existing in the database after running the 'rake reference_data:load'
|
|
37
46
|
|
|
38
47
|
### db/reference/000_users.rb
|
|
39
|
-
Easy::ReferenceData.
|
|
40
|
-
Easy::ReferenceData.
|
|
41
|
-
Easy::ReferenceData.
|
|
48
|
+
Easy::ReferenceData.update_or_create User, {system_code: 'nigel', name: 'Nigel Ramsay', email: 'nigel.ramsay@mailinator.com'}, keys: [:system_code]
|
|
49
|
+
Easy::ReferenceData.update_or_create User, {system_code: 'fred', name: 'Fred Schmitt', email: 'fred.schmitt@mailinator.com'}, keys: [:system_code]
|
|
50
|
+
Easy::ReferenceData.update_or_create User, {system_code: 'bert', name: 'Bert Symthe', email: 'bert.smythe@mailinator.com'}, keys: [:system_code]
|
|
51
|
+
|
|
52
|
+
Multiple keys can be used to identify records that would otherwise not have a unique attribute
|
|
53
|
+
|
|
54
|
+
### db/reference/000_prices.rb
|
|
55
|
+
Easy::ReferenceData.update_or_create Price, {product_id: 1, type: "Price::RetailPrice", price: 5}, keys: [:product_id, :type]
|
|
56
|
+
Easy::ReferenceData.update_or_create Price, {product_id: 1, type: "Price::CostPrice", price: 4}, keys: [:product_id, :type]
|
|
57
|
+
Easy::ReferenceData.update_or_create Price, {product_id: 2, type: "Price::RetailPrice", price: 5}, keys: [:product_id, :type]
|
|
42
58
|
|
|
43
59
|
## Contributing
|
|
44
60
|
|
data/Rakefile
CHANGED
data/easy_reference_data.gemspec
CHANGED
|
@@ -18,4 +18,8 @@ Gem::Specification.new do |gem|
|
|
|
18
18
|
gem.require_paths = ["lib"]
|
|
19
19
|
|
|
20
20
|
gem.add_runtime_dependency 'rails', '>= 3.0.0'
|
|
21
|
+
|
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3.6.0'
|
|
23
|
+
gem.add_development_dependency 'sqlite3', '~> 1.4.0'
|
|
24
|
+
gem.add_development_dependency 'database_cleaner', '~> 1.6'
|
|
21
25
|
end
|
|
@@ -1,24 +1,57 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
|
|
1
3
|
module Easy
|
|
2
4
|
module ReferenceData
|
|
5
|
+
|
|
3
6
|
def self.refresh(clazz, unique_attribute_symbol, unique_attribute_value, attributes)
|
|
4
|
-
|
|
7
|
+
self.update_or_create(clazz, attributes.merge(unique_attribute_symbol => unique_attribute_value), keys: [unique_attribute_symbol])
|
|
8
|
+
end
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
end
|
|
10
|
+
def self.update_or_create(clazz, attributes, options)
|
|
11
|
+
unique_attribute_keys = options.fetch(:keys)
|
|
9
12
|
|
|
10
|
-
attributes.
|
|
11
|
-
|
|
13
|
+
record = clazz.where(attributes.slice(*unique_attribute_keys)).first_or_initialize
|
|
14
|
+
|
|
15
|
+
if record.new_record?
|
|
16
|
+
$stderr.puts "..creating #{clazz}(#{attributes.slice(*unique_attribute_keys)})"
|
|
17
|
+
else
|
|
18
|
+
$stderr.puts "..updating #{clazz}(#{attributes.slice(*unique_attribute_keys)})"
|
|
12
19
|
end
|
|
13
20
|
|
|
14
21
|
begin
|
|
15
|
-
record.
|
|
22
|
+
record.update!(attributes)
|
|
16
23
|
rescue
|
|
17
|
-
puts "Save failed for #{record.class}
|
|
24
|
+
$stderr.puts "Save failed for #{record.class} with attributes #{attributes.inspect}"
|
|
18
25
|
raise
|
|
19
26
|
end
|
|
20
27
|
|
|
21
28
|
record
|
|
22
29
|
end
|
|
30
|
+
|
|
31
|
+
def self.load_files(wrap_in_transaction: false)
|
|
32
|
+
if wrap_in_transaction
|
|
33
|
+
ActiveRecord::Base.transaction do
|
|
34
|
+
load_the_files
|
|
35
|
+
end
|
|
36
|
+
else
|
|
37
|
+
load_the_files
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private_class_method
|
|
42
|
+
|
|
43
|
+
def self.files
|
|
44
|
+
files = Dir[File.join(Rails.root, 'db', 'reference', '*.rb')].sort
|
|
45
|
+
files += Dir[File.join(Rails.root, 'db', 'reference', Rails.env, '*.rb')].sort
|
|
46
|
+
files
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.load_the_files
|
|
50
|
+
files.each do |file|
|
|
51
|
+
puts "Populating reference #{file}"
|
|
52
|
+
load file
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
23
56
|
end
|
|
24
57
|
end
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
namespace :easy do
|
|
2
2
|
namespace :reference_data do
|
|
3
|
-
desc "Refreshes reference data values for the current environment."
|
|
4
|
-
task :refresh => :environment do
|
|
5
|
-
|
|
6
|
-
files += Dir[File.join(Rails.root, 'db', 'reference', Rails.env, '*.rb')].sort
|
|
7
|
-
|
|
8
|
-
files.each do |file|
|
|
9
|
-
puts "Populating reference #{file}"
|
|
10
|
-
load file
|
|
11
|
-
end
|
|
3
|
+
desc "Refreshes reference data values for the current environment. Pass the wrap_in_transaction flag to refresh in a transaction."
|
|
4
|
+
task :refresh, [:wrap_in_transaction] => :environment do |_task, args|
|
|
5
|
+
Easy::ReferenceData.load_files(wrap_in_transaction: args[:wrap_in_transaction] == "wrap_in_transaction")
|
|
12
6
|
end
|
|
13
7
|
end
|
|
14
|
-
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'easy/reference_data/refresh'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Easy::ReferenceData do
|
|
5
|
+
|
|
6
|
+
describe ".update_or_create" do
|
|
7
|
+
context "with a single unique attribute" do
|
|
8
|
+
context "and an existing record" do
|
|
9
|
+
|
|
10
|
+
it "does not change the record" do
|
|
11
|
+
user = User.create(system_code: 1)
|
|
12
|
+
|
|
13
|
+
expect{ Easy::ReferenceData.update_or_create(User, {system_code: 1}, keys: [:system_code])}.not_to change{ User.count }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "with additional attributes" do
|
|
17
|
+
it "updates the existing record" do
|
|
18
|
+
user = User.create(system_code: 1, name: "Jo")
|
|
19
|
+
|
|
20
|
+
expect{ Easy::ReferenceData.update_or_create(User, {system_code: 1, name: "Jane"}, keys: [:system_code])}.to change{ user.reload.name }.to "Jane"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "and no existing record" do
|
|
26
|
+
it "creates a new record" do
|
|
27
|
+
expect{ Easy::ReferenceData.update_or_create(User, {system_code: 1}, keys: [:system_code])}.to change{ User.count }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context "with multiple attributes" do
|
|
34
|
+
it "updates the matching record" do
|
|
35
|
+
jo_smith = User.create(system_code: 1, name: "Jo", email: "jo.smith@example.com")
|
|
36
|
+
jo_brown = User.create(system_code: 1, name: "Jo", email: "jo.brown@example.com")
|
|
37
|
+
|
|
38
|
+
expect{ Easy::ReferenceData.update_or_create(User, {name: "Jo", email: "jo.brown@example.com", system_code: 2}, keys: [:name, :email])}.to change{ jo_brown.reload.system_code }.to 2
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe ".refresh" do
|
|
45
|
+
|
|
46
|
+
context "with a unique attribute" do
|
|
47
|
+
context "and no existing record" do
|
|
48
|
+
|
|
49
|
+
it "creates a new record" do
|
|
50
|
+
expect{
|
|
51
|
+
Easy::ReferenceData.refresh User, :system_code, 1, name: "Jane", email: "jane@example.com"
|
|
52
|
+
}.to change{ User.count }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "and an existing record" do
|
|
58
|
+
it "updates the existing record" do
|
|
59
|
+
user = User.create(system_code: 1, name: "Jo")
|
|
60
|
+
|
|
61
|
+
expect{ Easy::ReferenceData.refresh User, :system_code, 1, name: "Jane", email: "jane@example.com" }.to change{ user.reload.name }.to "Jane"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "does not create duplicate records" do
|
|
65
|
+
user = User.create(system_code: 1, name: "Jo")
|
|
66
|
+
|
|
67
|
+
expect{ Easy::ReferenceData.refresh User, :system_code, 1, name: "Jo", email: "jane@example.com" }.not_to change{ User.count }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe ".load_files" do
|
|
75
|
+
before do
|
|
76
|
+
allow(subject).to receive(:files).and_return([@file1 = double(to_str: "easy/reference_data/refresh.rb")])
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "when the wrap_in_transaction argument is true" do
|
|
80
|
+
let(:call) {subject.load_files(wrap_in_transaction: true)}
|
|
81
|
+
|
|
82
|
+
it "starts a transaction" do
|
|
83
|
+
expect(ActiveRecord::Base).to receive(:transaction).and_call_original
|
|
84
|
+
call
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "loads all the files" do
|
|
88
|
+
allow(Kernel).to receive(:load).with(@file1)
|
|
89
|
+
call
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
context "when the wrap_in_transaction argument is false" do
|
|
95
|
+
let(:call) {subject.load_files(wrap_in_transaction: false)}
|
|
96
|
+
|
|
97
|
+
it "does not start a transaction" do
|
|
98
|
+
expect(ActiveRecord::Base).not_to receive(:transaction)
|
|
99
|
+
call
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "loads all the files" do
|
|
103
|
+
allow(Kernel).to receive(:load).with(@file1)
|
|
104
|
+
call
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context "if the wrap_in_transaction argument is not passed in" do
|
|
109
|
+
let(:call) {subject.load_files}
|
|
110
|
+
|
|
111
|
+
it "does not start a transaction" do
|
|
112
|
+
expect(ActiveRecord::Base).not_to receive(:transaction)
|
|
113
|
+
call
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "loads all the files" do
|
|
117
|
+
allow(Kernel).to receive(:load).with(@file1)
|
|
118
|
+
call
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
require 'active_record'
|
|
2
|
+
require 'database_cleaner'
|
|
3
|
+
|
|
4
|
+
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
|
5
|
+
|
|
6
|
+
require 'support/models'
|
|
7
|
+
|
|
8
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
10
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
11
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
|
12
|
+
# files.
|
|
13
|
+
#
|
|
14
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
15
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
16
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
17
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
18
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
19
|
+
# the additional setup, and require it from the spec files that actually need
|
|
20
|
+
# it.
|
|
21
|
+
#
|
|
22
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
23
|
+
RSpec.configure do |config|
|
|
24
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
25
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
26
|
+
# assertions if you prefer.
|
|
27
|
+
config.expect_with :rspec do |expectations|
|
|
28
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
29
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
30
|
+
# defined using `chain`, e.g.:
|
|
31
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
32
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
33
|
+
# ...rather than:
|
|
34
|
+
# # => "be bigger than 2"
|
|
35
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
39
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
40
|
+
config.mock_with :rspec do |mocks|
|
|
41
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
42
|
+
# a real object. This is generally recommended, and will default to
|
|
43
|
+
# `true` in RSpec 4.
|
|
44
|
+
mocks.verify_partial_doubles = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
|
48
|
+
# have no way to turn it off -- the option exists only for backwards
|
|
49
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
|
50
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
|
51
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
|
52
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
53
|
+
|
|
54
|
+
# The settings below are suggested to provide a good initial experience
|
|
55
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
56
|
+
=begin
|
|
57
|
+
# This allows you to limit a spec run to individual examples or groups
|
|
58
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
|
59
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
|
60
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
|
61
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
62
|
+
config.filter_run_when_matching :focus
|
|
63
|
+
|
|
64
|
+
# Allows RSpec to persist some state between runs in order to support
|
|
65
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
|
66
|
+
# you configure your source control system to ignore this file.
|
|
67
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
68
|
+
|
|
69
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
70
|
+
# recommended. For more details, see:
|
|
71
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
|
72
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
73
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
|
74
|
+
config.disable_monkey_patching!
|
|
75
|
+
|
|
76
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
77
|
+
# be too noisy due to issues in dependencies.
|
|
78
|
+
config.warnings = true
|
|
79
|
+
|
|
80
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
81
|
+
# file, and it's useful to allow more verbose output when running an
|
|
82
|
+
# individual spec file.
|
|
83
|
+
if config.files_to_run.one?
|
|
84
|
+
# Use the documentation formatter for detailed output,
|
|
85
|
+
# unless a formatter has already been configured
|
|
86
|
+
# (e.g. via a command-line flag).
|
|
87
|
+
config.default_formatter = "doc"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Print the 10 slowest examples and example groups at the
|
|
91
|
+
# end of the spec run, to help surface which specs are running
|
|
92
|
+
# particularly slow.
|
|
93
|
+
config.profile_examples = 10
|
|
94
|
+
|
|
95
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
96
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
97
|
+
# the seed, which is printed after each run.
|
|
98
|
+
# --seed 1234
|
|
99
|
+
config.order = :random
|
|
100
|
+
|
|
101
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
102
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
103
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
104
|
+
# as the one that triggered the failure.
|
|
105
|
+
Kernel.srand config.seed
|
|
106
|
+
=end
|
|
107
|
+
|
|
108
|
+
config.before(:suite) do
|
|
109
|
+
DatabaseCleaner.strategy = :transaction
|
|
110
|
+
DatabaseCleaner.clean_with(:transaction)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
config.before(:each) do
|
|
114
|
+
DatabaseCleaner.start
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
config.after(:each) do
|
|
118
|
+
DatabaseCleaner.clean
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
end
|
metadata
CHANGED
|
@@ -1,32 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easy_reference_data
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.2.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Nigel Ramsay
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rails
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - ">="
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: 3.0.0
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: 3.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 3.6.0
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 3.6.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: sqlite3
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 1.4.0
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 1.4.0
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: database_cleaner
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.6'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.6'
|
|
30
69
|
description: Used to create a predefined set of model instances
|
|
31
70
|
email:
|
|
32
71
|
- nigel.ramsay@abletech.co.nz
|
|
@@ -34,7 +73,10 @@ executables: []
|
|
|
34
73
|
extensions: []
|
|
35
74
|
extra_rdoc_files: []
|
|
36
75
|
files:
|
|
37
|
-
- .gitignore
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- ".travis.yml"
|
|
79
|
+
- BUILD.md
|
|
38
80
|
- ChangeLog
|
|
39
81
|
- Gemfile
|
|
40
82
|
- LICENSE.txt
|
|
@@ -47,29 +89,34 @@ files:
|
|
|
47
89
|
- lib/easy/reference_data/version.rb
|
|
48
90
|
- lib/easy_reference_data.rb
|
|
49
91
|
- lib/tasks/easy_reference_data.rake
|
|
92
|
+
- spec/easy/reference_data/refresh_spec.rb
|
|
93
|
+
- spec/spec_helper.rb
|
|
94
|
+
- spec/support/models.rb
|
|
95
|
+
- spec/support/schema.rb
|
|
50
96
|
homepage: http://github.com/AbleTech/easy_reference_data
|
|
51
97
|
licenses: []
|
|
98
|
+
metadata: {}
|
|
52
99
|
post_install_message:
|
|
53
100
|
rdoc_options: []
|
|
54
101
|
require_paths:
|
|
55
102
|
- lib
|
|
56
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
104
|
requirements:
|
|
59
|
-
- -
|
|
105
|
+
- - ">="
|
|
60
106
|
- !ruby/object:Gem::Version
|
|
61
107
|
version: '0'
|
|
62
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
|
-
none: false
|
|
64
109
|
requirements:
|
|
65
|
-
- -
|
|
110
|
+
- - ">="
|
|
66
111
|
- !ruby/object:Gem::Version
|
|
67
112
|
version: '0'
|
|
68
113
|
requirements: []
|
|
69
|
-
|
|
70
|
-
rubygems_version: 1.8.24
|
|
114
|
+
rubygems_version: 3.1.6
|
|
71
115
|
signing_key:
|
|
72
|
-
specification_version:
|
|
116
|
+
specification_version: 4
|
|
73
117
|
summary: Loads files from db/reference/*.rb
|
|
74
|
-
test_files:
|
|
75
|
-
|
|
118
|
+
test_files:
|
|
119
|
+
- spec/easy/reference_data/refresh_spec.rb
|
|
120
|
+
- spec/spec_helper.rb
|
|
121
|
+
- spec/support/models.rb
|
|
122
|
+
- spec/support/schema.rb
|