pseudo_cleaner 0.0.28 → 0.0.29
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 +38 -23
- data/lib/pseudo_cleaner/rspec.rb +13 -14
- data/lib/pseudo_cleaner/spinach.rb +6 -4
- data/lib/pseudo_cleaner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODhhODA3NTdjMDkxM2Q5MGIxMjAwMGMyNWMxYzI5NDBkYzJmMmRlYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWZkM2E1YmI1ZjI3ZTAwMmY1NzgyMWI1YjRkYmQwNDFhMzY1MDE1NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWZlYTk2ODUwNTQ3NTEyNzgyMWFhYjlhNThiYmIzOWEzYjQzODgzOTc4Y2Zi
|
10
|
+
NTgwYmI5MGZkM2YwMDE0MGFlMGZkMDI5OGJmY2FmNmViNGJmZTFkMjgzN2U5
|
11
|
+
ZjY2ZDdiNTQ4YzllZWIwYzNlOTQ5ZDI1M2I3ZThkY2ExMTZlNGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGIxMGFkMWI3MWNmNWQzZTZhM2Q3NDBhMmY2ODUxYzk4YmZlZjM3ZWE4OGFj
|
14
|
+
MWIxZjA5YjQ5ZTUyMzQ4MWQ2OGQ3YmUzNmIzZDEwMmE5ZDJlYjE5MjY1OTIw
|
15
|
+
NjhhYjZlMmI0YzIzNWY1MTBmOThhY2Y4MjVhMDdlM2U4MGRlMDc=
|
@@ -1,41 +1,56 @@
|
|
1
|
-
|
1
|
+
require "singleton"
|
2
2
|
|
3
3
|
# turn off Cucumber's default usage of DatabaseCleaner
|
4
4
|
Cucumber::Rails::Database.autorun_database_cleaner = false
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# We start suite in case a custom cleaner wants/needs to.
|
11
|
-
if PseudoCleaner::Configuration.current_instance.clean_database_before_tests
|
12
|
-
PseudoCleaner::MasterCleaner.reset_database
|
13
|
-
else
|
14
|
-
PseudoCleaner::MasterCleaner.start_suite
|
15
|
-
end
|
6
|
+
class CucumberHook
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
attr_accessor :first_test_run
|
16
10
|
|
17
|
-
|
11
|
+
def initialize
|
12
|
+
@first_test_run = false
|
18
13
|
end
|
19
|
-
end
|
20
14
|
|
21
|
-
|
22
|
-
|
15
|
+
def run_test(scenario, strategy, block)
|
16
|
+
unless first_test_run
|
17
|
+
@first_test_run = true
|
18
|
+
# before tests run...
|
19
|
+
# We start suite in case a custom cleaner wants/needs to.
|
20
|
+
|
21
|
+
if PseudoCleaner::Configuration.current_instance.clean_database_before_tests
|
22
|
+
PseudoCleaner::MasterCleaner.reset_database
|
23
|
+
else
|
24
|
+
PseudoCleaner::MasterCleaner.start_suite
|
25
|
+
end
|
26
|
+
|
27
|
+
DatabaseCleaner.strategy = :transaction
|
28
|
+
end
|
29
|
+
|
30
|
+
PseudoCleaner::MasterCleaner.start_example(scenario, strategy)
|
31
|
+
|
32
|
+
begin
|
33
|
+
block.call
|
34
|
+
ensure
|
35
|
+
PseudoCleaner::MasterCleaner.end_example(scenario)
|
36
|
+
end
|
37
|
+
end
|
23
38
|
end
|
24
39
|
|
25
|
-
|
26
|
-
|
40
|
+
Around("~@truncation", "~@deletion") do |scenario, block|
|
41
|
+
CucumberHook.instance.run_test(scenario, :pseudo_delete, block)
|
27
42
|
end
|
28
43
|
|
29
|
-
|
30
|
-
|
44
|
+
Around("@truncation") do |scenario, block|
|
45
|
+
CucumberHook.instance.run_test(scenario, :truncation, block)
|
31
46
|
end
|
32
47
|
|
33
|
-
|
34
|
-
|
48
|
+
Around("@deletion", "~@truncation") do |scenario, block|
|
49
|
+
CucumberHook.instance.run_test(scenario, :deletion, block)
|
35
50
|
end
|
36
51
|
|
37
|
-
|
38
|
-
|
52
|
+
Around("@none") do |scenario, block|
|
53
|
+
CucumberHook.instance.run_test(scenario, :none, block)
|
39
54
|
end
|
40
55
|
|
41
56
|
at_exit do
|
data/lib/pseudo_cleaner/rspec.rb
CHANGED
@@ -15,31 +15,30 @@ RSpec.configure do |config|
|
|
15
15
|
PseudoCleaner::MasterCleaner.end_suite
|
16
16
|
end
|
17
17
|
|
18
|
-
config.
|
19
|
-
|
18
|
+
config.around(:each) do |example|
|
19
|
+
test_example = example.example if example.respond_to?(:example)
|
20
|
+
test_example ||= self.example if self.respond_to?(:example)
|
20
21
|
|
21
|
-
|
22
|
-
clean_example = example.example if example.respond_to?(:example)
|
22
|
+
new_strategy = nil
|
23
23
|
|
24
|
-
new_strategy =
|
24
|
+
new_strategy = test_example.metadata[:strategy]
|
25
25
|
|
26
26
|
if new_strategy && !PseudoCleaner::MasterCleaner::CLEANING_STRATEGIES.include?(new_strategy)
|
27
|
-
PseudoCleaner::Logger.write "*** Unknown/invalid cleaning strategy #{
|
27
|
+
PseudoCleaner::Logger.write "*** Unknown/invalid cleaning strategy #{test_example.metadata[:strategy]}. Using default: :transaction ***".red.on_light_white
|
28
28
|
new_strategy = :transaction
|
29
29
|
end
|
30
|
-
if
|
30
|
+
if test_example.metadata[:js]
|
31
31
|
new_strategy ||= :pseudo_delete
|
32
32
|
new_strategy = :pseudo_delete if new_strategy == :transaction
|
33
33
|
end
|
34
34
|
new_strategy ||= :transaction
|
35
35
|
|
36
|
-
PseudoCleaner::MasterCleaner.start_example(
|
37
|
-
end
|
36
|
+
PseudoCleaner::MasterCleaner.start_example(test_example, new_strategy)
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
begin
|
39
|
+
example.run
|
40
|
+
ensure
|
41
|
+
PseudoCleaner::MasterCleaner.end_example(test_example)
|
42
|
+
end
|
44
43
|
end
|
45
44
|
end
|
@@ -2,7 +2,7 @@ first_test_run = false
|
|
2
2
|
|
3
3
|
# I haven't tested this fully yet, but I think that this should work.
|
4
4
|
|
5
|
-
Spinach.hooks.
|
5
|
+
Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
6
6
|
unless first_test_run
|
7
7
|
first_test_run = true
|
8
8
|
# before tests run...
|
@@ -26,10 +26,12 @@ Spinach.hooks.before_scenario do |scenario, step_definitions|
|
|
26
26
|
:pseudo_delete
|
27
27
|
end
|
28
28
|
PseudoCleaner::MasterCleaner.start_example(scenario, strategy)
|
29
|
-
end
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
begin
|
31
|
+
block.call
|
32
|
+
ensure
|
33
|
+
PseudoCleaner::MasterCleaner.end_example(scenario)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
Spinach.hooks.after_run do |status|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudo_cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|