squcumber-postgres 0.1.0 → 0.1.5

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
  SHA256:
3
- metadata.gz: '089d8a3f411ec32c7b5915819d3da2691b91404397c2601c0468a3bebb1eb3ec'
4
- data.tar.gz: 9842daf920c36ea783ba5e381993972cf71d323be275f4f47fed75729af05359
3
+ metadata.gz: 23fde2ac6689e3e38cb90410131d9f214c7541d341875886e664e0e136e6dbc6
4
+ data.tar.gz: 021bcd824e130d9e0b6042e12b40d182610235242c784de12bcd9d9b2e841ea8
5
5
  SHA512:
6
- metadata.gz: 698c9109d441bed70308522ed173a458ab78644127a56d610f1283bce68fe574a31a974873d1b303f97e01b5bc131e7d60c08b8e5be7fd6683302a5f473f66ea
7
- data.tar.gz: 30cf3e31073c6fdf1fdc8d3051f19fde1c65545d75ad8b835d2535fe0332f3a2a92e59be22da5c72c1724a1e72d11ad287f7fe8986273016275139700d33de77
6
+ metadata.gz: 9320112c56ba18a66c9ca765c03255f5f4a59056f9b7125476ba2d3200062dc8b6f4966f344c757bf76fc00a8b9dfc9786f7afc220cd69376bb5004ac64d1347
7
+ data.tar.gz: f57cf9ff57f707e8a92f81189bf20f1da470f67cae228f44ccf0466bdf907a6a9ea4d729cb9a809b02a543495ca24609588b5db7411416c32f3ddd17c3e1d88a
@@ -58,6 +58,10 @@ Given(/^the following defaults for "?([^\s"]+)"? \(if not stated otherwise\):$/)
58
58
  @defaults[table] = data.hashes[0]
59
59
  end
60
60
 
61
+ Given(/^"([^\s"]+)" as null value$/) do |null_placeholder|
62
+ @null ||= null_placeholder
63
+ end
64
+
61
65
  Given(/a clean environment/) do
62
66
  silence_streams(STDERR) do
63
67
  TESTING_DATABASE.truncate_all_tables()
@@ -74,6 +78,7 @@ Given(/^the existing table "?([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)"?( with date place
74
78
  end
75
79
 
76
80
  mock_data = convert_mock_values(mock_data) if placeholder
81
+ mock_data = convert_null_values(mock_data, @null) if @null
77
82
 
78
83
  TESTING_DATABASE.mock(
79
84
  Hash["#{schema}.#{table}", mock_data]
@@ -112,12 +117,13 @@ Then(/^the result( with date placeholders)? starts with.*$/) do |placeholder, da
112
117
  actual = @result[0..(data.hashes.length - 1)] || []
113
118
  expected = data.hashes || []
114
119
  expected = convert_mock_values(expected) if placeholder
120
+ expected = convert_null_values(expected, @null) if @null
115
121
 
116
122
  sanity_check_result(actual, expected)
117
123
 
118
124
  expected.each_with_index do |hash, i|
119
125
  raise("Does not start with expected result, got:\n#{format_error(data, actual)}") unless actual[i].all? do |key, value|
120
- values_match(value, hash[key]) # actual,expected
126
+ values_match(value, hash[key], null=@null) # actual,expected
121
127
  end
122
128
  end
123
129
  end
@@ -126,13 +132,14 @@ Then(/^the result( with date placeholders)? includes.*$/) do |placeholder, data|
126
132
  actual = @result || []
127
133
  expected = data.hashes || []
128
134
  expected = convert_mock_values(expected) if placeholder
135
+ expected = convert_null_values(expected, @null) if @null
129
136
 
130
137
  sanity_check_result(actual, expected)
131
138
 
132
139
  expected.each do |hash|
133
140
  raise("Result is not included, got:\n#{format_error(data, actual)}") unless actual.any? do |row|
134
141
  row.all? do |key, value|
135
- values_match(value, hash[key]) # actual, expected
142
+ values_match(value, hash[key], null=@null) # actual, expected
136
143
  end
137
144
  end
138
145
  end
@@ -142,13 +149,14 @@ Then(/^the result( with date placeholders)? does not include.*$/) do |placeholde
142
149
  actual = @result || []
143
150
  expected = data.hashes || []
144
151
  expected = convert_mock_values(expected) if placeholder
152
+ expected = convert_null_values(expected, @null) if @null
145
153
 
146
154
  sanity_check_result(actual, expected)
147
155
 
148
156
  expected.each do |hash|
149
157
  raise("Result is included, got:\n#{format_error(data, actual)}") if actual.any? do |row|
150
158
  row.all? do |key, value|
151
- values_match(value, hash[key]) # actual,expected
159
+ values_match(value, hash[key], null=@null) # actual,expected
152
160
  end
153
161
  end
154
162
  end
@@ -158,6 +166,7 @@ Then(/^the result( with date placeholders)? exactly matches.*$/) do |placeholder
158
166
  actual = @result || []
159
167
  expected = data.hashes || []
160
168
  expected = convert_mock_values(expected) if placeholder
169
+ expected = convert_null_values(expected, @null) if @null
161
170
 
162
171
  sanity_check_result(actual, expected)
163
172
 
@@ -165,13 +174,13 @@ Then(/^the result( with date placeholders)? exactly matches.*$/) do |placeholder
165
174
 
166
175
  actual.each_with_index do |row, i|
167
176
  raise("Does not match exactly, got:\n#{format_error(data, actual)}") unless (expected[i] || {}).all? do |key, value|
168
- values_match(row[key], value) # actual,expected
177
+ values_match(row[key], value, null=@null) # actual,expected
169
178
  end
170
179
  end
171
180
 
172
181
  expected.each_with_index do |hash, i|
173
182
  raise("Does not match exactly, got:\n#{format_error(data, actual)}") unless (actual[i] || {}).all? do |key, value|
174
- values_match(value, hash[key]) # actual,expected
183
+ values_match(value, hash[key], null=@null) # actual,expected
175
184
  end
176
185
  end
177
186
  end
@@ -10,7 +10,7 @@ module MatcherHelpers
10
10
  end
11
11
  end
12
12
 
13
- def values_match(actual, expected)
13
+ def values_match(actual, expected, null=nil)
14
14
  if expected.eql?('today')
15
15
  actual.match(/#{Regexp.quote(Date.today.to_s)}/)
16
16
  elsif expected.eql?('yesterday')
@@ -21,6 +21,8 @@ module MatcherHelpers
21
21
  actual.match(/^#{Regexp.quote(Date.today.to_s)} \d{2}:\d{2}:\d{2}$/)
22
22
  elsif expected.eql?('sometime yesterday')
23
23
  actual.match(/^#{Regexp.quote((Date.today - 1).to_s)} \d{2}:\d{2}:\d{2}$/)
24
+ elsif !null.nil? and !expected.nil? and expected.eql?(null)
25
+ actual.nil?
24
26
  elsif expected.eql?('any_string')
25
27
  true if actual.is_a?(String) or actual.nil?
26
28
  elsif expected.eql?('false') or expected.eql?('true')
@@ -33,6 +35,24 @@ module MatcherHelpers
33
35
  end
34
36
  end
35
37
 
38
+ def convert_null_values(mock_data, null)
39
+ mock_data.map do |entry|
40
+ entry.each do |key, value|
41
+ entry[key] = convert_null_value(value, null)
42
+ end
43
+ end
44
+ end
45
+
46
+ def convert_null_value(value, null)
47
+ if null.nil?
48
+ value
49
+ elsif value.eql?(null)
50
+ nil
51
+ else
52
+ value
53
+ end
54
+ end
55
+
36
56
  def convert_mock_values(mock_data)
37
57
  mock_data.map do |entry|
38
58
  entry.each do |key, value|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squcumber-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefanie Grunwald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -131,7 +131,7 @@ dependencies:
131
131
  - !ruby/object:Gem::Version
132
132
  version: '1.0'
133
133
  description:
134
- email: steffi@physics.org
134
+ email: hi@moer.tel
135
135
  executables: []
136
136
  extensions: []
137
137
  extra_rdoc_files: []