database_flusher 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5757e018763a6a24a1ab1d4458342652e37c6dd
4
- data.tar.gz: eef0f72db7a2688c90cb43829dce03f5cbc04484
3
+ metadata.gz: f228160138e843a8bed353ad7cc4582b1390846d
4
+ data.tar.gz: fea5700dd7a8e3d27d36bf32205472982de6de21
5
5
  SHA512:
6
- metadata.gz: 8202dd0665c71467cd1d9ad20740453e94e7b674f432c6dd4c6238a2ae02cb1f061a017ea84faea86e0c73d57268ddd179edfd1f9aef1adeaf63a76a6729dc51
7
- data.tar.gz: 19f3166b15a7d8933d478a00b01fe875acf0d15fd00fd4fccf06317ec956c518e88416936b5a88a75b822e3ac8e3e713aaa0d5b57fc753b135a36e6b630a609c
6
+ metadata.gz: '0846ed665fa63a8c664352f89c7160351c344578bc6efb800f13b2314f9c92fb2e24507c5fb797354f3dd875cde218836f110306272ffc61b659bb2bd5e84188'
7
+ data.tar.gz: 98e3cb45b170ad48bec6b220de6007b276b58500a17c07d147e7d3345561e356f0d41928767b2e7079341a936748ff1feef62485864aad0b52d6c5a31fbf1022
data/README.md CHANGED
@@ -44,17 +44,29 @@ $ bundle
44
44
 
45
45
  ## Usage
46
46
 
47
- RSpec:
47
+ ### RSpec
48
48
 
49
49
  ```ruby
50
50
  RSpec.configure do |config|
51
51
  config.use_transactional_fixtures = false
52
52
 
53
53
  config.before :suite do
54
+ if File.exists?('.~lock')
55
+ puts "Unclean shutdown, cleaning the whole database..."
56
+ DatabaseFlusher[:active_record].clean_with(:deletion)
57
+ DatabaseFlusher[:mongoid].clean_with(:deletion)
58
+ else
59
+ File.open('.~lock', 'a') {}
60
+ end
61
+
54
62
  DatabaseFlusher[:active_record].strategy = :transaction
55
63
  DatabaseFlusher[:mongoid].strategy = :deletion
56
64
  end
57
65
 
66
+ config.after :suite do
67
+ File.unlink('.~lock')
68
+ end
69
+
58
70
  config.before :each do
59
71
  DatabaseFlusher[:active_record].strategy = :transaction
60
72
  end
@@ -75,19 +87,30 @@ RSpec.configure do |config|
75
87
  end
76
88
  ```
77
89
 
78
- Cucumber:
90
+ ### Cucumber
79
91
 
80
92
  ```ruby
81
- DatabaseFlusher[:active_record].strategy = :transaction
82
- DatabaseFlusher[:mongoid].strategy = :deletion
93
+ if File.exists?('.~lock')
94
+ puts "Unclean shutdown, cleaning the whole database..."
95
+ DatabaseFlusher[:active_record].clean_with(:deletion)
96
+ DatabaseFlusher[:mongoid].clean_with(:deletion)
97
+ else
98
+ File.open('.~lock', 'a') {}
99
+ end
83
100
 
84
- Before('~@javascript') do
85
- DatabaseFlusher[:active_record].strategy = :transaction
86
- DatabaseFlusher.start
101
+ at_exit do
102
+ File.unlink('.~lock')
87
103
  end
88
104
 
89
- Before('@javascript') do
90
- DatabaseFlusher[:active_record].strategy = :deletion
105
+ DatabaseFlusher[:active_record].strategy = :transaction
106
+ DatabaseFlusher[:mongoid].strategy = :deletion
107
+
108
+ Before do
109
+ if Capybara.current_driver == :rack_test
110
+ DatabaseFlusher[:active_record].strategy = :transaction
111
+ else
112
+ DatabaseFlusher[:active_record].strategy = :deletion
113
+ end
91
114
  DatabaseFlusher.start
92
115
  end
93
116
 
@@ -96,26 +119,6 @@ After do
96
119
  end
97
120
  ```
98
121
 
99
- In case of unclean test shutdown, you can clean the whole database, using:
100
-
101
- ```ruby
102
- RSpec.configure do |config|
103
- config.before :suite do
104
- if File.exists?('.~lock')
105
- puts "Unclean shutdown, cleaning the whole database..."
106
- DatabaseFlusher[:active_record].clean_with(:deletion)
107
- DatabaseFlusher[:mongoid].clean_with(:deletion)
108
- else
109
- File.open('.~lock', 'a') {}
110
- end
111
- end
112
-
113
- config.after :suite do
114
- File.unlink('.~lock')
115
- end
116
- end
117
- ```
118
-
119
122
  ## Contributing
120
123
 
121
124
  Bug reports and pull requests are welcome on GitHub at https://github.com/ebeigarts/database_flusher. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -69,7 +69,8 @@ module DatabaseFlusher
69
69
  end
70
70
 
71
71
  def all_tables
72
- tables = connection.tables
72
+ # NOTE connection.tables warns on AR 5 with some adapters
73
+ tables = ActiveSupport::Deprecation.silence { connection.tables }
73
74
  tables.reject do |t|
74
75
  (t == ::ActiveRecord::Migrator.schema_migrations_table_name) ||
75
76
  (::ActiveRecord::Base.respond_to?(:internal_metadata_table_name) &&
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module DatabaseFlusher
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_flusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts