sniff 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
data/lib/sniff/database.rb
CHANGED
@@ -24,8 +24,6 @@ module Sniff
|
|
24
24
|
fixtures_path = File.join(Sniff.root, 'lib', 'test_support', 'db', 'fixtures')
|
25
25
|
environments << init_environment(Sniff.root, :fixtures_path => fixtures_path)
|
26
26
|
end
|
27
|
-
|
28
|
-
environments.each { |e| e.populate_fixtures }
|
29
27
|
end
|
30
28
|
|
31
29
|
def init_environment(root, options = {})
|
data/lib/sniff/fixture.rb
CHANGED
@@ -4,6 +4,8 @@ module Sniff
|
|
4
4
|
module Fixture
|
5
5
|
extend self
|
6
6
|
|
7
|
+
# FIXME TODO this doesn't work for models where the model name is different from the table name
|
8
|
+
# (e.g. PetroleumAdministrationForDefenseDistrict, ResidentialEnergyConsumptionSurveyResponse)
|
7
9
|
def load_fixtures(fixtures_path)
|
8
10
|
Encoding.default_external = 'UTF-8' if Object.const_defined?('Encoding')
|
9
11
|
Dir.glob(File.join(fixtures_path, '**/*.csv')) do |fixture_file|
|
data/lib/sniff/version.rb
CHANGED
@@ -49,12 +49,14 @@ Then /^the conclusion should not comply with standards? "(.*)"$/ do |standard_li
|
|
49
49
|
end
|
50
50
|
|
51
51
|
Then /^the conclusion of the committee should be "(.*)"$/ do |conclusion|
|
52
|
-
|
52
|
+
conclusion = @report.try(:conclusion)
|
53
|
+
conclusion = conclusion.respond_to?(:value) ? conclusion.value : conclusion
|
54
|
+
compare_values(conclusion, coerce_value(conclusion))
|
53
55
|
end
|
54
56
|
|
55
57
|
Then /^the conclusion of the committee should be timeframe "(.*)"$/ do |conclusion|
|
56
58
|
timeframe = Timeframe.interval(conclusion)
|
57
|
-
compare_values(@report.try(:conclusion), timeframe)
|
59
|
+
compare_values(@report.try(:conclusion), coerce_value(timeframe))
|
58
60
|
end
|
59
61
|
|
60
62
|
Then /^the conclusion of the committee should be nil$/ do
|
@@ -69,16 +71,17 @@ Then /^the conclusion of the committee should include a key of "(.*)" and value
|
|
69
71
|
end
|
70
72
|
|
71
73
|
if value.present?
|
74
|
+
string_keyed_hash = {}
|
72
75
|
@report.conclusion.each do |k, v|
|
73
|
-
|
76
|
+
string_keyed_hash[k.to_s] = v
|
74
77
|
end
|
75
|
-
compare_values(
|
78
|
+
compare_values(string_keyed_hash[key.to_s], coerce_value(value))
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
79
82
|
Then /^the conclusion of the committee should have "(.*)" of "(.*)"$/ do |attribute, value|
|
80
83
|
report_value = coerce_value @report.conclusion.send(attribute)
|
81
|
-
compare_values report_value, value
|
84
|
+
compare_values report_value, coerce_value(value)
|
82
85
|
end
|
83
86
|
|
84
87
|
Then /^the conclusion of the committee should include "(.*)"$/ do |value|
|
@@ -96,7 +99,7 @@ Then /^the conclusion of the committee should have a( single)? record identified
|
|
96
99
|
records = @report.conclusion
|
97
100
|
record = records.to_a.find { |r| equality? r.send(id_field), id }
|
98
101
|
record.should_not be_nil
|
99
|
-
compare_values record.send(field), value
|
102
|
+
compare_values record.send(field), coerce_value(value)
|
100
103
|
if single
|
101
104
|
records.count.should == 1
|
102
105
|
end
|
@@ -111,16 +114,16 @@ end
|
|
111
114
|
|
112
115
|
Then /^the conclusion of the committee should have a record with "([^"]*)" equal to "([^"]*)"$/ do |field, value|
|
113
116
|
record = @report.conclusion
|
114
|
-
compare_values(coerce_value(record.send(field)),value)
|
117
|
+
compare_values(coerce_value(record.send(field)), coerce_value(value))
|
115
118
|
end
|
116
119
|
|
117
120
|
Then /^the conclusion of the committee should include a key of "(.*)" and subvalue "(.*)" of "(.*)" and subvalue "(.*)" of "(.*)"$/ do |key, subkey1, subvalue1, subkey2, subvalue2|
|
118
121
|
if key.present?
|
119
122
|
@report.conclusion.keys.map(&:to_s).should include(key)
|
120
123
|
actual_subvalue1 = coerce_value(@report.conclusion[key.to_s][subkey1.to_sym].to_s)
|
121
|
-
compare_values(actual_subvalue1, subvalue1)
|
124
|
+
compare_values(actual_subvalue1, coerce_value(subvalue1))
|
122
125
|
actual_subvalue2 = coerce_value(@report.conclusion[key.to_s][subkey2.to_sym].to_s)
|
123
|
-
compare_values(actual_subvalue2, subvalue2)
|
126
|
+
compare_values(actual_subvalue2, coerce_value(subvalue2))
|
124
127
|
else
|
125
128
|
@report.conclusion.keys.map(&:to_s).should be_blank
|
126
129
|
end
|
@@ -30,23 +30,13 @@ module CucumberValueParser
|
|
30
30
|
|
31
31
|
def compare_values(a, b)
|
32
32
|
if b.blank?
|
33
|
-
a.
|
33
|
+
a.blank?
|
34
|
+
elsif a.is_a?(Float)
|
35
|
+
a.should be_within(0.00001).of(b)
|
36
|
+
elsif a.is_a? Date
|
37
|
+
a.strftime('%Y-%m-%d').should == b.strftime('%Y-%m-%d')
|
34
38
|
elsif a.is_a? Time
|
35
|
-
|
36
|
-
a.should == b
|
37
|
-
elsif a.is_a? Date
|
38
|
-
b = Date.parse b unless b.is_a?(Date)
|
39
|
-
a.should == b
|
40
|
-
elsif b =~ /\d+.*,.*\d/
|
41
|
-
a.should == b
|
42
|
-
elsif b =~ /\d+\.\d+/
|
43
|
-
b = b.to_f
|
44
|
-
a.to_f.should be_within(0.00001).of(b)
|
45
|
-
elsif b =~ /^0/
|
46
|
-
a.to_s.should == b
|
47
|
-
elsif b =~ /^\d+$/
|
48
|
-
b = b.to_i
|
49
|
-
a.to_i.should == b
|
39
|
+
a.strftime('%Y-%m-%d %H:%M:%s').should == b.strftime('%Y-%m-%d %H:%M:%s')
|
50
40
|
else
|
51
41
|
a.should == b
|
52
42
|
end
|