data_sanity 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,6 +22,8 @@
22
22
  * You can add a sample criteria file using rake data_sanity:criteria
23
23
  * To Investigate your data use rake data_sanity:investigate
24
24
  - By default it runs for all data
25
+ : If criteria file is specifies then picks model from file and validates only those
26
+ : Note: For any criteria mentioned except model names is ignored
25
27
  - rake data_sanity:investigate[random,2]
26
28
  : parameter 1: random: show you want random selection
27
29
  : parameter 2: lets you add as many random records you want to verify [default is 1]
@@ -15,7 +15,8 @@ module DataSanity
15
15
 
16
16
  def investigate
17
17
  if @all
18
- @models.each do |model_string|
18
+ considered_models = @criteria ? @criteria.keys : @models
19
+ considered_models.each do |model_string|
19
20
  model = model_string.constantize
20
21
  log_start(model)
21
22
  validate_all(model)
@@ -1,3 +1,3 @@
1
1
  module DataSanity
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -63,6 +63,29 @@ describe "DataSanity::Inspector" do
63
63
 
64
64
  YAML.load(DataInspector.first.validation_errors).should_not be_blank
65
65
  end
66
+
67
+ describe "criteria" do
68
+ before :each do
69
+ setup_data_sanity_criteria
70
+ end
71
+
72
+ it "should check for errors on model based on criteria models picked from data_sanity_criteria.yml, also ignores options under model" do
73
+ inspector = DataSanity::Inspector.new
74
+
75
+ 2.times { Person.new(:name => "Raju").save(:validate => false) }
76
+ 2.times { Person.new(:name => "Saju").save(:validate => false) }
77
+ 2.times { Person.new(:name => "Also Taken").save(:validate => false) }
78
+ 2.times { Car.new(:name => "Santro").save(:validate => false) }
79
+
80
+ inspector.investigate
81
+ DataInspector.count.should == 6
82
+ DataInspector.all.collect(&:table_name).uniq.should == ["Person"]
83
+ end
84
+
85
+ after :each do
86
+ cleanup_data_sanity_criteria
87
+ end
88
+ end
66
89
  end
67
90
 
68
91
  describe "random" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Habibullah, Rahul, Jigyasa, Jyotsna, Hephzibah, Garima