pseudo_cleaner 0.0.37 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/pseudo_cleaner/cucumber.rb +19 -4
- data/lib/pseudo_cleaner/master_cleaner.rb +27 -18
- data/lib/pseudo_cleaner/redis_cleaner.rb +8 -6
- data/lib/pseudo_cleaner/rspec.rb +15 -6
- data/lib/pseudo_cleaner/spinach.rb +9 -6
- data/lib/pseudo_cleaner/table_cleaner.rb +2 -2
- data/lib/pseudo_cleaner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTk2NTg5N2FhYmRiYjJmYzkyMzA5NGE1YjhmZTNlYTE4MjhlODk1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjgwZDExYmRhNWE5YjE5OTAyZTY3OGIzNjdkZjEwMTFkOGVlYTNlNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWUwMDhlY2FjYzVjOWNiYjc4ZWEwMGY3NmU2YjA4MjRhMjg5MDkwNTkwNzFl
|
10
|
+
NWUyZjA2MjdhMTg1NDJhYjgwNGY0MDAxZGYwMDg1OWJjN2RmNDdkYmMyNTVl
|
11
|
+
OThiODEwYWZmZmFiM2MxZjBiY2RjYTQxYTAyMTVhZTVkMTczNjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjhjNjI1MmVmOTRjYWE1MTY1OTg2Y2EwZDg4Zjk5ZDRhZTk1ZDg2NWU4MDU2
|
14
|
+
NDhjZWFmY2JmNGRjZGQxN2Q5MTljYmVhMGRjYTNkNGFjZDI0MTAyMmMwMDZh
|
15
|
+
YjdlNGQ0NmI2NGFiNzQ1MDZlNTg5YWZhNjA2YjQxNTllNmQxODk=
|
@@ -33,11 +33,24 @@ class CucumberHook
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def start_test(scenario, strategy)
|
36
|
-
PseudoCleaner::MasterCleaner.start_example(scenario,
|
36
|
+
PseudoCleaner::MasterCleaner.start_example(scenario,
|
37
|
+
strategy,
|
38
|
+
description: "PseudoCleaner::start_test - #{report_name(scenario)}",
|
39
|
+
location: test_location(scenario))
|
37
40
|
end
|
38
41
|
|
39
42
|
def end_test(scenario)
|
40
|
-
PseudoCleaner::MasterCleaner.end_example(scenario,
|
43
|
+
PseudoCleaner::MasterCleaner.end_example(scenario,
|
44
|
+
description: "PseudoCleaner::end_test - #{report_name (scenario)}",
|
45
|
+
location: test_location(scenario))
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_location(scenario)
|
49
|
+
if scenario.respond_to?(:feature)
|
50
|
+
"#{scenario.location.file}:#{scenario.location.line}"
|
51
|
+
elsif scenario.respond_to?(:scenario_outline)
|
52
|
+
"#{scenario.scenario_outline.instance_variable_get(:@example_sections)[0][0][0].file}:#{scenario.scenario_outline.instance_variable_get(:@example_sections)[0][0][0].line}"
|
53
|
+
end
|
41
54
|
end
|
42
55
|
|
43
56
|
def report_name(scenario)
|
@@ -60,11 +73,13 @@ class CucumberHook
|
|
60
73
|
end
|
61
74
|
|
62
75
|
def peek_data_inline(scenario)
|
63
|
-
PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name(scenario)}"
|
76
|
+
PseudoCleaner::MasterCleaner.peek_data_inline(description: "PseudoCleaner::peek_data - #{report_name(scenario)}",
|
77
|
+
location: test_location(scenario))
|
64
78
|
end
|
65
79
|
|
66
80
|
def peek_data_new_test(scenario)
|
67
|
-
PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name(scenario)}"
|
81
|
+
PseudoCleaner::MasterCleaner.peek_data_new_test(description: "PseudoCleaner::peek_data - #{report_name(scenario)}",
|
82
|
+
location: test_location(scenario))
|
68
83
|
end
|
69
84
|
end
|
70
85
|
|
@@ -32,16 +32,20 @@ module PseudoCleaner
|
|
32
32
|
@@report_error = true
|
33
33
|
end
|
34
34
|
|
35
|
-
def within_report_block(
|
35
|
+
def within_report_block(options, &block)
|
36
36
|
@@report_error = false
|
37
37
|
@@report_table = nil
|
38
38
|
|
39
39
|
if Object.const_defined?("Cornucopia", false) &&
|
40
40
|
Cornucopia.const_defined?("Util", false) &&
|
41
41
|
Cornucopia::Util.const_defined?("ReportBuilder", false)
|
42
|
-
Cornucopia::Util::ReportBuilder.current_report.within_test(description) do
|
43
|
-
Cornucopia::Util::ReportBuilder.current_report.within_section(description) do |report|
|
42
|
+
Cornucopia::Util::ReportBuilder.current_report.within_test(options[:description]) do
|
43
|
+
Cornucopia::Util::ReportBuilder.current_report.within_section(options[:description]) do |report|
|
44
44
|
report.within_table do |report_table|
|
45
|
+
if options[:location]
|
46
|
+
report_table.write_stats "location", options[:location]
|
47
|
+
end
|
48
|
+
|
45
49
|
@@report_table = report_table
|
46
50
|
|
47
51
|
block.yield
|
@@ -62,7 +66,7 @@ module PseudoCleaner
|
|
62
66
|
def start_suite(description = nil)
|
63
67
|
description ||= "PseudoCleaner::MasterCleaner.start_suite"
|
64
68
|
|
65
|
-
within_report_block(description) do
|
69
|
+
within_report_block(description: description) do
|
66
70
|
if @@suite_cleaner
|
67
71
|
@@suite_cleaner.reset_suite
|
68
72
|
end
|
@@ -85,10 +89,10 @@ module PseudoCleaner
|
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
88
|
-
def start_example(example_class, strategy,
|
89
|
-
description ||= "PseudoCleaner::MasterCleaner.start_example"
|
92
|
+
def start_example(example_class, strategy, options = {})
|
93
|
+
options[:description] ||= "PseudoCleaner::MasterCleaner.start_example"
|
90
94
|
|
91
|
-
within_report_block(
|
95
|
+
within_report_block(options) do
|
92
96
|
pseudo_cleaner_data = {}
|
93
97
|
pseudo_cleaner_data[:test_strategy] = strategy
|
94
98
|
|
@@ -107,10 +111,10 @@ module PseudoCleaner
|
|
107
111
|
end
|
108
112
|
end
|
109
113
|
|
110
|
-
def end_example(example_class,
|
111
|
-
description ||= "PseudoCleaner::MasterCleaner.end_example"
|
114
|
+
def end_example(example_class, options = {})
|
115
|
+
options[:description] ||= "PseudoCleaner::MasterCleaner.end_example"
|
112
116
|
|
113
|
-
within_report_block(
|
117
|
+
within_report_block(options) do
|
114
118
|
pseudo_cleaner_data = example_class.instance_variable_get(:@pseudo_cleaner_data)
|
115
119
|
|
116
120
|
unless pseudo_cleaner_data[:test_strategy] == :none
|
@@ -131,7 +135,7 @@ module PseudoCleaner
|
|
131
135
|
def end_suite(description = nil)
|
132
136
|
description ||= "PseudoCleaner::MasterCleaner.end_suite"
|
133
137
|
|
134
|
-
within_report_block(description) do
|
138
|
+
within_report_block(description: description) do
|
135
139
|
@@suite_cleaner.end test_strategy: :pseudo_delete if @@suite_cleaner
|
136
140
|
end
|
137
141
|
end
|
@@ -171,7 +175,7 @@ module PseudoCleaner
|
|
171
175
|
def reset_database(description = nil)
|
172
176
|
description ||= "PseudoCleaner::MasterCleaner.reset_database"
|
173
177
|
|
174
|
-
within_report_block(description) do
|
178
|
+
within_report_block(description: description) do
|
175
179
|
PseudoCleaner::MasterCleaner.database_cleaner.clean_with(:truncation)
|
176
180
|
|
177
181
|
PseudoCleaner::MasterCleaner.database_reset
|
@@ -340,18 +344,23 @@ module PseudoCleaner
|
|
340
344
|
@@suite_cleaner.review_rows(&block)
|
341
345
|
end
|
342
346
|
|
343
|
-
def peek_data_inline(
|
347
|
+
def peek_data_inline(options = {})
|
344
348
|
@@report_error = false
|
345
349
|
@@report_table = nil
|
346
350
|
|
347
351
|
if Object.const_defined?("Cornucopia", false) &&
|
348
352
|
Cornucopia.const_defined?("Util", false) &&
|
349
353
|
Cornucopia::Util.const_defined?("ReportBuilder", false)
|
350
|
-
Cornucopia::Util::ReportBuilder.current_report.within_section(description) do |report|
|
354
|
+
Cornucopia::Util::ReportBuilder.current_report.within_section(options[:description]) do |report|
|
351
355
|
report.within_hidden_table do |outer_report_table|
|
352
356
|
Cornucopia::Util::ReportTable.new(
|
353
357
|
nested_table: outer_report_table,
|
354
358
|
suppress_blank_table: true) do |report_table|
|
359
|
+
# redundant, but I like it because it is consistent.
|
360
|
+
if options[:location]
|
361
|
+
report_table.write_stats "location", options[:location]
|
362
|
+
end
|
363
|
+
|
355
364
|
@@report_table = report_table
|
356
365
|
|
357
366
|
peek_values
|
@@ -361,16 +370,16 @@ module PseudoCleaner
|
|
361
370
|
|
362
371
|
@@report_table = nil
|
363
372
|
else
|
364
|
-
PseudoCleaner::Logger.write(description)
|
373
|
+
PseudoCleaner::Logger.write(options[:description])
|
365
374
|
|
366
375
|
peek_values
|
367
376
|
end
|
368
377
|
end
|
369
378
|
|
370
|
-
def peek_data_new_test(
|
371
|
-
description ||= "PseudoCleaner::MasterCleaner.peek_data"
|
379
|
+
def peek_data_new_test(options = {})
|
380
|
+
options[:description] ||= "PseudoCleaner::MasterCleaner.peek_data"
|
372
381
|
|
373
|
-
within_report_block(
|
382
|
+
within_report_block(options) do
|
374
383
|
peek_values
|
375
384
|
end
|
376
385
|
end
|
@@ -241,7 +241,9 @@ module PseudoCleaner
|
|
241
241
|
@multi_commands = []
|
242
242
|
elsif ["exec", "pipelined"].include?(args[0])
|
243
243
|
begin
|
244
|
-
|
244
|
+
if (!response && @multi_commands.length > 0) || (response && response.length != @multi_commands.length)
|
245
|
+
raise "exec response does not match sent commands.\n response: #{response}\n commands: #{@multi_commands}"
|
246
|
+
end
|
245
247
|
|
246
248
|
response.each_with_index do |command_response, index|
|
247
249
|
process_command(command_response, *(@multi_commands[index]))
|
@@ -389,7 +391,7 @@ module PseudoCleaner
|
|
389
391
|
updated_values.each do |value|
|
390
392
|
if initial_keys.include?(value)
|
391
393
|
report_keys << value
|
392
|
-
@suite_altered_keys << value
|
394
|
+
@suite_altered_keys << value unless ignore_key(value)
|
393
395
|
else
|
394
396
|
redis.del(value)
|
395
397
|
end
|
@@ -448,20 +450,20 @@ module PseudoCleaner
|
|
448
450
|
Cornucopia::Util::ReportTable.new(nested_table: PseudoCleaner::MasterCleaner.report_table,
|
449
451
|
nested_table_label: redis_name,
|
450
452
|
suppress_blank_table: true) do |report_table|
|
451
|
-
updated_values.
|
453
|
+
updated_values.each_with_index do |updated_value, index|
|
452
454
|
unless ignore_key(updated_value)
|
453
455
|
output_values = true
|
454
|
-
report_table.write_stats
|
456
|
+
report_table.write_stats index.to_s, report_record(updated_value)
|
455
457
|
end
|
456
458
|
end
|
457
459
|
end
|
458
460
|
else
|
459
461
|
PseudoCleaner::Logger.write(" #{redis_name}")
|
460
462
|
|
461
|
-
updated_values.
|
463
|
+
updated_values.each_with_index do |updated_value, index|
|
462
464
|
unless ignore_key(updated_value)
|
463
465
|
output_values = true
|
464
|
-
PseudoCleaner::Logger.write(" #{
|
466
|
+
PseudoCleaner::Logger.write(" #{index}: #{report_record(updated_value)}")
|
465
467
|
end
|
466
468
|
end
|
467
469
|
end
|
data/lib/pseudo_cleaner/rspec.rb
CHANGED
@@ -48,7 +48,10 @@ RSpec.configure do |config|
|
|
48
48
|
new_strategy ||= :transaction
|
49
49
|
|
50
50
|
report_name = test_example.full_description
|
51
|
-
PseudoCleaner::MasterCleaner.start_example(test_example,
|
51
|
+
PseudoCleaner::MasterCleaner.start_example(test_example,
|
52
|
+
new_strategy,
|
53
|
+
description: "PseudoCleaner::start_test - #{report_name}",
|
54
|
+
location: test_example.location)
|
52
55
|
end
|
53
56
|
|
54
57
|
config.after(:each) do |example|
|
@@ -61,26 +64,32 @@ RSpec.configure do |config|
|
|
61
64
|
if (test_example.exception)
|
62
65
|
if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
|
63
66
|
PseudoCleaner::Configuration.instance.peek_data_on_error
|
64
|
-
PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}"
|
67
|
+
PseudoCleaner::MasterCleaner.peek_data_inline(description: "PseudoCleaner::peek_data - #{report_name}",
|
68
|
+
location: test_example.location)
|
65
69
|
end
|
66
70
|
else
|
67
71
|
if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
|
68
72
|
PseudoCleaner::Configuration.instance.peek_data_not_on_error
|
69
|
-
PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}"
|
73
|
+
PseudoCleaner::MasterCleaner.peek_data_new_test(description: "PseudoCleaner::peek_data - #{report_name}",
|
74
|
+
location: test_example.location)
|
70
75
|
end
|
71
76
|
end
|
72
77
|
else
|
73
78
|
if (test_example.exception)
|
74
79
|
if PseudoCleaner::Configuration.instance.peek_data_on_error
|
75
|
-
PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}"
|
80
|
+
PseudoCleaner::MasterCleaner.peek_data_inline(description: "PseudoCleaner::peek_data - #{report_name}",
|
81
|
+
location: test_example.location)
|
76
82
|
end
|
77
83
|
else
|
78
84
|
if PseudoCleaner::Configuration.instance.peek_data_not_on_error
|
79
|
-
PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}"
|
85
|
+
PseudoCleaner::MasterCleaner.peek_data_new_test(description: "PseudoCleaner::peek_data - #{report_name}",
|
86
|
+
location: test_example.location)
|
80
87
|
end
|
81
88
|
end
|
82
89
|
end
|
83
90
|
|
84
|
-
PseudoCleaner::MasterCleaner.end_example(test_example,
|
91
|
+
PseudoCleaner::MasterCleaner.end_example(test_example,
|
92
|
+
description: "PseudoCleaner::end_test - #{report_name}",
|
93
|
+
location: test_example.location)
|
85
94
|
end
|
86
95
|
end
|
@@ -38,7 +38,9 @@ Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
|
38
38
|
else
|
39
39
|
:pseudo_delete
|
40
40
|
end
|
41
|
-
PseudoCleaner::MasterCleaner.start_example(scenario_data,
|
41
|
+
PseudoCleaner::MasterCleaner.start_example(scenario_data,
|
42
|
+
strategy,
|
43
|
+
description: "PseudoCleaner::start_test - #{report_name}")
|
42
44
|
|
43
45
|
begin
|
44
46
|
block.call
|
@@ -47,27 +49,28 @@ Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
|
47
49
|
if PseudoCleaner::SpinachErrorHandler.exception
|
48
50
|
if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
|
49
51
|
PseudoCleaner::Configuration.instance.peek_data_on_error
|
50
|
-
PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}")
|
52
|
+
PseudoCleaner::MasterCleaner.peek_data_inline(description: "PseudoCleaner::peek_data - #{report_name}")
|
51
53
|
end
|
52
54
|
else
|
53
55
|
if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
|
54
56
|
PseudoCleaner::Configuration.instance.peek_data_not_on_error
|
55
|
-
PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}")
|
57
|
+
PseudoCleaner::MasterCleaner.peek_data_new_test(description: "PseudoCleaner::peek_data - #{report_name}")
|
56
58
|
end
|
57
59
|
end
|
58
60
|
else
|
59
61
|
if PseudoCleaner::SpinachErrorHandler.exception
|
60
62
|
if PseudoCleaner::Configuration.instance.peek_data_on_error
|
61
|
-
PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}")
|
63
|
+
PseudoCleaner::MasterCleaner.peek_data_inline(description: "PseudoCleaner::peek_data - #{report_name}")
|
62
64
|
end
|
63
65
|
else
|
64
66
|
if PseudoCleaner::Configuration.instance.peek_data_not_on_error
|
65
|
-
PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}")
|
67
|
+
PseudoCleaner::MasterCleaner.peek_data_new_test(description: "PseudoCleaner::peek_data - #{report_name}")
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
|
-
PseudoCleaner::MasterCleaner.end_example(scenario_data,
|
72
|
+
PseudoCleaner::MasterCleaner.end_example(scenario_data,
|
73
|
+
description: "PseudoCleaner::end_test - #{report_name}")
|
71
74
|
PseudoCleaner::SpinachErrorHandler.exception = nil
|
72
75
|
end
|
73
76
|
end
|
@@ -736,8 +736,8 @@ module PseudoCleaner
|
|
736
736
|
else
|
737
737
|
PseudoCleaner::Logger.write(" #{peek_name}")
|
738
738
|
|
739
|
-
row_data.
|
740
|
-
PseudoCleaner::Logger.write(" #{updated_value}")
|
739
|
+
row_data.each_with_index do |updated_value, index|
|
740
|
+
PseudoCleaner::Logger.write(" #{index}: #{updated_value}")
|
741
741
|
end
|
742
742
|
end
|
743
743
|
|