pseudo_cleaner 0.0.29 → 0.0.30
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 +8 -8
- data/lib/pseudo_cleaner/configuration.rb +4 -4
- data/lib/pseudo_cleaner/cucumber.rb +76 -13
- 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
|
+
OWQ1NjM5ZjVhZThkYTAwMzBmMGUzYjNjZjg1OTI5ODdhZTg0ZWY3Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODFkNjg4NWJmZTNkZGI0MDdhYWE0MjYyMTI2YjQ4M2RjYWJlYWJiYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjBlMGFjN2E2MzVjMGI5NmIzOGM2MzU1NWVjMTE2NjA0YWVhYWM3NDdhNThh
|
10
|
+
MGViMTMxZTQyYmI3YzUxOTcxYTcxMDgyZDlmZjI4NjBlNDlhZGNmOGM1MTMy
|
11
|
+
NDY3YmQ0MTkxYWRhNWU1NWRmY2I4MTIzMjliMjcwZjI1ZGFlM2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGNhYWY0Y2M0YmY3YWY0YjllMzllY2U4NDY2Njg3YjEyMTcxMmY1ZjdiMWMw
|
14
|
+
M2Q4OWRiYzk0MzFhOGVjMTFiMjY1NDE1MDI0MzU2MmMyNWRjMDZmZmRmNzVm
|
15
|
+
MDU5NGRlZGQyYzM2NTRiMWI3ZjUwZDA3NjFkZTA3M2Y3MDBmZjA=
|
@@ -18,11 +18,11 @@ module PseudoCleaner
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def initialize
|
21
|
-
@output_diagnostics
|
21
|
+
@output_diagnostics = false # false to keep the noise level down...
|
22
22
|
@clean_database_before_tests = false # false because I think it will annoy developers...
|
23
|
-
@reset_auto_increment
|
24
|
-
@single_cleaner_set
|
25
|
-
@post_transaction_analysis
|
23
|
+
@reset_auto_increment = true # true because I think it should be done
|
24
|
+
@single_cleaner_set = true # true because I hope it will improve performance
|
25
|
+
@post_transaction_analysis = false # should only be set true if you are searching for a problem
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.db_connection=(connection)
|
@@ -3,6 +3,10 @@ require "singleton"
|
|
3
3
|
# turn off Cucumber's default usage of DatabaseCleaner
|
4
4
|
Cucumber::Rails::Database.autorun_database_cleaner = false
|
5
5
|
|
6
|
+
AfterConfiguration do |config|
|
7
|
+
CucumberHook.instance.init_pseudo
|
8
|
+
end
|
9
|
+
|
6
10
|
class CucumberHook
|
7
11
|
include Singleton
|
8
12
|
|
@@ -12,7 +16,7 @@ class CucumberHook
|
|
12
16
|
@first_test_run = false
|
13
17
|
end
|
14
18
|
|
15
|
-
def
|
19
|
+
def init_pseudo
|
16
20
|
unless first_test_run
|
17
21
|
@first_test_run = true
|
18
22
|
# before tests run...
|
@@ -26,31 +30,90 @@ class CucumberHook
|
|
26
30
|
|
27
31
|
DatabaseCleaner.strategy = :transaction
|
28
32
|
end
|
33
|
+
end
|
29
34
|
|
35
|
+
def start_test(scenario, strategy)
|
30
36
|
PseudoCleaner::MasterCleaner.start_example(scenario, strategy)
|
37
|
+
end
|
38
|
+
|
39
|
+
def end_test(scenario)
|
40
|
+
PseudoCleaner::MasterCleaner.end_example(scenario)
|
41
|
+
end
|
42
|
+
|
43
|
+
def run_test(scenario, strategy, block)
|
44
|
+
start_test(scenario, strategy)
|
31
45
|
|
32
46
|
begin
|
33
47
|
block.call
|
34
48
|
ensure
|
35
|
-
|
49
|
+
end_test(scenario)
|
36
50
|
end
|
37
51
|
end
|
38
52
|
end
|
39
53
|
|
40
|
-
|
41
|
-
|
42
|
-
|
54
|
+
##
|
55
|
+
# Most testing systems do tests as:
|
56
|
+
# * Around
|
57
|
+
# * Before
|
58
|
+
# * After
|
59
|
+
#
|
60
|
+
# Cucumber doesn't. It does it:
|
61
|
+
# * Before
|
62
|
+
# * Around
|
63
|
+
# * After
|
64
|
+
#
|
65
|
+
# What is more, it is WAY worse than that.
|
66
|
+
#
|
67
|
+
# If your Feature has a Background block:
|
68
|
+
# Feature my feature
|
69
|
+
#
|
70
|
+
# Background
|
71
|
+
# Scenario
|
72
|
+
#
|
73
|
+
# Then the Before happens before the Background whereas the Around is only around the
|
74
|
+
# Scenario part of the feature.
|
75
|
+
#
|
76
|
+
# I hope that this gets fixed, but until it does, we can't use Around for database cleaning.
|
77
|
+
#
|
78
|
+
# This is fixed in Cucumber 2.0.
|
43
79
|
|
44
|
-
Around("@truncation") do |scenario, block|
|
45
|
-
CucumberHook.instance.run_test(scenario, :truncation, block)
|
46
|
-
end
|
47
80
|
|
48
|
-
|
49
|
-
|
50
|
-
|
81
|
+
if Cucumber::VERSION.split[0].to_i >= 2
|
82
|
+
Around("~@truncation", "~@deletion") do |scenario, block|
|
83
|
+
CucumberHook.instance.run_test(scenario, :pseudo_delete, block)
|
84
|
+
end
|
51
85
|
|
52
|
-
Around("@
|
53
|
-
|
86
|
+
Around("@truncation") do |scenario, block|
|
87
|
+
CucumberHook.instance.run_test(scenario, :truncation, block)
|
88
|
+
end
|
89
|
+
|
90
|
+
Around("@deletion", "~@truncation") do |scenario, block|
|
91
|
+
CucumberHook.instance.run_test(scenario, :deletion, block)
|
92
|
+
end
|
93
|
+
|
94
|
+
Around("@none") do |scenario, block|
|
95
|
+
CucumberHook.instance.run_test(scenario, :none, block)
|
96
|
+
end
|
97
|
+
else
|
98
|
+
Before("~@truncation", "~@deletion") do |scenario|
|
99
|
+
CucumberHook.instance.start_test(scenario, :pseudo_delete)
|
100
|
+
end
|
101
|
+
|
102
|
+
Before("@truncation") do |scenario|
|
103
|
+
CucumberHook.instance.start_test(scenario, :truncation)
|
104
|
+
end
|
105
|
+
|
106
|
+
Before("@deletion", "~@truncation") do |scenario|
|
107
|
+
CucumberHook.instance.start_test(scenario, :deletion)
|
108
|
+
end
|
109
|
+
|
110
|
+
Before("@none") do |scenario|
|
111
|
+
CucumberHook.instance.start_test(scenario, :none)
|
112
|
+
end
|
113
|
+
|
114
|
+
After do |scenario|
|
115
|
+
CucumberHook.instance.end_test(scenario)
|
116
|
+
end
|
54
117
|
end
|
55
118
|
|
56
119
|
at_exit do
|