initial-test-data 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6721d973f28cf59c8bf8bc3018f514be62745a2
4
- data.tar.gz: 90d123ca554811506d4e7c50abbe99c7d7e3e194
3
+ metadata.gz: 61d3e869ddd51d5bf3a99beb4d37ef4d1c827bd7
4
+ data.tar.gz: 5d01a799a3b693079041dcb5595a3497e350a0f4
5
5
  SHA512:
6
- metadata.gz: ad2e4f4a141f0211bb45e90ff2e0c065d95a0a702e421a483931f79e425f5aa0a861f2145de0e14dd8db383cd982fe09b9a114eec9bdb8e928bac62cff2f4e6f
7
- data.tar.gz: 42c25ea8331b0a6b78c0331a4dba569412026ed9af2e18b1af8e291689224a5e28ee1a556c7430d15ea79d029001ef67e5aaf8b0036378cdd5c3e5cfb2a558ad
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 stores it to the `_initial_data_digest`
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
- If the generated md5 digest is equal to the previously stored value,
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
- ### Database Cleaner
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: initial-test-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsutomu KURODA