initial-test-data 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +25 -4
- data/lib/initial-test-data/initial_test_data.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61d3e869ddd51d5bf3a99beb4d37ef4d1c827bd7
|
4
|
+
data.tar.gz: 5d01a799a3b693079041dcb5595a3497e350a0f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5192af3b5299ac030f60c1c56b460756c821569c6c5ba8082b8806ae5826f5f4dd905b782804c4903dfcf0f4a42e9257754ef5dd7b9411a5b2277a052e56632a
|
7
|
+
data.tar.gz: d740f02c057358f054d37fde8cb48f6b49dac5e9b5778d6c2285e6dacc6922eb745969c2f1b0c12504f8073c93000bbb21873572aa4b2cf0dc80eb1de7dee572
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# CHANGELOG - initial-test-data
|
2
2
|
|
3
|
+
## 0.3.0 (January 31, 2016)
|
4
|
+
|
5
|
+
* Monitor `app/models/**/*.rb`. When any modification is detected,
|
6
|
+
reinitialize the test data.
|
7
|
+
* The class method `InitialTestData.load` accepts `monitoring` option
|
8
|
+
to add the target directories of monitoring.
|
9
|
+
|
3
10
|
## 0.2.1 (January 31, 2016)
|
4
11
|
|
5
12
|
* Fix bug that the `_initial_data_digest` table gets truncated.
|
data/README.md
CHANGED
@@ -61,10 +61,10 @@ Usage
|
|
61
61
|
### Caching data
|
62
62
|
|
63
63
|
The `initial-test-data` generates the md5 digest of all ruby scripts in
|
64
|
-
the `initial_data` directory and
|
65
|
-
table of the test database.
|
64
|
+
the `initial_data` directory and `app/models` directory,
|
65
|
+
then stores it to the `_initial_data_digest` table of the test database.
|
66
66
|
|
67
|
-
|
67
|
+
When the generated md5 digest is equal to the previously stored value,
|
68
68
|
data initializing process will be skipped.
|
69
69
|
|
70
70
|
### Load Order
|
@@ -79,7 +79,9 @@ which has a content like this:
|
|
79
79
|
- orders
|
80
80
|
```
|
81
81
|
|
82
|
-
###
|
82
|
+
### Options for the `InitialTestData.load` method
|
83
|
+
|
84
|
+
#### `except`
|
83
85
|
|
84
86
|
The `initial-test-data` utilizes the `database_cleaner` gem to truncate
|
85
87
|
all tables except `_initial_data_digest` and `schema_migrations`.
|
@@ -96,6 +98,25 @@ end
|
|
96
98
|
|
97
99
|
This option is passed to the `DatabaseCleaner.strategy=` method.
|
98
100
|
|
101
|
+
#### `monitoring`
|
102
|
+
|
103
|
+
By default the `initial-test-data` monitors the `initial_data` directory
|
104
|
+
under the `test` directory (or the directory specified by the first argument)
|
105
|
+
and the `app/models` directory.
|
106
|
+
|
107
|
+
If you want to add monitoring target directories, specify `monitoring`
|
108
|
+
option to the `InitialTestData.load` method:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
RSpec.configure do |config|
|
112
|
+
config.before(:suite) do
|
113
|
+
InitialTestData.load('spec', monitoring: [ 'app/services', 'lib' ]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
118
|
+
You should use relative paths from the `Rails.root`.
|
119
|
+
|
99
120
|
Example
|
100
121
|
-------
|
101
122
|
|
@@ -18,6 +18,8 @@ class InitialTestData
|
|
18
18
|
|
19
19
|
unless md5_digest == md5_digest_cache
|
20
20
|
initialize_data
|
21
|
+
|
22
|
+
digest = klass.first
|
21
23
|
digest ||= klass.new
|
22
24
|
digest.md5_value = md5_digest
|
23
25
|
digest.save
|
@@ -41,10 +43,22 @@ class InitialTestData
|
|
41
43
|
|
42
44
|
def generate_md5_digest
|
43
45
|
md5 = Digest::MD5.new
|
46
|
+
|
44
47
|
Dir[Rails.root.join(@dir, 'initial_data', '*.rb')].each do |f|
|
45
48
|
md5.update File.new(f).read
|
46
49
|
end
|
47
50
|
|
51
|
+
dirs = [ 'app/models' ]
|
52
|
+
if @options[:monitoring].kind_of?(Array)
|
53
|
+
dirs += @options[:monitoring]
|
54
|
+
end
|
55
|
+
|
56
|
+
dirs.each do |d|
|
57
|
+
Dir[Rails.root.join(d, '**', '*.rb')].each do |f|
|
58
|
+
md5.update File.new(f).read
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
48
62
|
md5.hexdigest
|
49
63
|
end
|
50
64
|
|