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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODhhODA3NTdjMDkxM2Q5MGIxMjAwMGMyNWMxYzI5NDBkYzJmMmRlYg==
4
+ OWQ1NjM5ZjVhZThkYTAwMzBmMGUzYjNjZjg1OTI5ODdhZTg0ZWY3Mw==
5
5
  data.tar.gz: !binary |-
6
- ZWZkM2E1YmI1ZjI3ZTAwMmY1NzgyMWI1YjRkYmQwNDFhMzY1MDE1NA==
6
+ ODFkNjg4NWJmZTNkZGI0MDdhYWE0MjYyMTI2YjQ4M2RjYWJlYWJiYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWZlYTk2ODUwNTQ3NTEyNzgyMWFhYjlhNThiYmIzOWEzYjQzODgzOTc4Y2Zi
10
- NTgwYmI5MGZkM2YwMDE0MGFlMGZkMDI5OGJmY2FmNmViNGJmZTFkMjgzN2U5
11
- ZjY2ZDdiNTQ4YzllZWIwYzNlOTQ5ZDI1M2I3ZThkY2ExMTZlNGE=
9
+ YjBlMGFjN2E2MzVjMGI5NmIzOGM2MzU1NWVjMTE2NjA0YWVhYWM3NDdhNThh
10
+ MGViMTMxZTQyYmI3YzUxOTcxYTcxMDgyZDlmZjI4NjBlNDlhZGNmOGM1MTMy
11
+ NDY3YmQ0MTkxYWRhNWU1NWRmY2I4MTIzMjliMjcwZjI1ZGFlM2E=
12
12
  data.tar.gz: !binary |-
13
- NGIxMGFkMWI3MWNmNWQzZTZhM2Q3NDBhMmY2ODUxYzk4YmZlZjM3ZWE4OGFj
14
- MWIxZjA5YjQ5ZTUyMzQ4MWQ2OGQ3YmUzNmIzZDEwMmE5ZDJlYjE5MjY1OTIw
15
- NjhhYjZlMmI0YzIzNWY1MTBmOThhY2Y4MjVhMDdlM2U4MGRlMDc=
13
+ NGNhYWY0Y2M0YmY3YWY0YjllMzllY2U4NDY2Njg3YjEyMTcxMmY1ZjdiMWMw
14
+ M2Q4OWRiYzk0MzFhOGVjMTFiMjY1NDE1MDI0MzU2MmMyNWRjMDZmZmRmNzVm
15
+ MDU5NGRlZGQyYzM2NTRiMWI3ZjUwZDA3NjFkZTA3M2Y3MDBmZjA=
@@ -18,11 +18,11 @@ module PseudoCleaner
18
18
  end
19
19
 
20
20
  def initialize
21
- @output_diagnostics = false # false to keep the noise level down...
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 = 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
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 run_test(scenario, strategy, block)
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
- PseudoCleaner::MasterCleaner.end_example(scenario)
49
+ end_test(scenario)
36
50
  end
37
51
  end
38
52
  end
39
53
 
40
- Around("~@truncation", "~@deletion") do |scenario, block|
41
- CucumberHook.instance.run_test(scenario, :pseudo_delete, block)
42
- end
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
- Around("@deletion", "~@truncation") do |scenario, block|
49
- CucumberHook.instance.run_test(scenario, :deletion, block)
50
- end
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("@none") do |scenario, block|
53
- CucumberHook.instance.run_test(scenario, :none, block)
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
@@ -1,3 +1,3 @@
1
1
  module PseudoCleaner
2
- VERSION = "0.0.29"
2
+ VERSION = "0.0.30"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pseudo_cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.29
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - RealNobody