database_rewinder 0.4.1 → 0.4.2

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: b376682c2f67881f7a3f6d94cdee69ca9c2d91d4
4
- data.tar.gz: bbe492eaf822b8964c6921591fdc348d87afcd91
3
+ metadata.gz: fdff13637a829acd582b4c01d312b2a13feb61d4
4
+ data.tar.gz: e984897076c597c332af05d88f70123f299fd35f
5
5
  SHA512:
6
- metadata.gz: 58460132f5cbfaa52a83c962511a2092e079cc66c6295ea3a702ca105c136f2bfbdbff66b933b83b1ce5c0268d92b0ba024d514fa814358677c38eb13e109b36
7
- data.tar.gz: 80ec799e958f0e5eb29edad2e9aaf975120eda596cb27093c8832792ca8e5cafa88b7e478f05129cb43efaf11d22e4a786ec3d3d61593462fe47f844b60c7010
6
+ metadata.gz: 36f33700c2dee70e5e05a4af6447651b34ce13cae4b4e45ab4c4c73439ea69d49965d86c052133a0f75e681f104d3b9881efbbaf22d34e47c375b5c3b7213708
7
+ data.tar.gz: e78829201e040887e19d73affb3780bcb563758ed4956ed659958fcabea4fcc11680ce6aa742afd6631c5491c60b49782fa6d54e26fc7d5650bf0de761d9f3e4
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
4
  - 2.1
5
+ - 2.2
data/README.md CHANGED
@@ -22,9 +22,9 @@ This strategy was originally devised and implemented by Shingo Morita (@eudoxa)
22
22
 
23
23
  ## Supported versions
24
24
 
25
- * ActiveRecord 3.2, 4.0, 4.1
25
+ * ActiveRecord 3.2, 4.0, 4.1, 4.2
26
26
 
27
- * Ruby 2.0, 2.1
27
+ * Ruby 2.0, 2.1, 2.2
28
28
 
29
29
  ## Installation
30
30
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "database_rewinder"
7
- spec.version = '0.4.1'
7
+ spec.version = '0.4.2'
8
8
  spec.authors = ["Akira Matsuda"]
9
9
  spec.email = ["ronnie@dio.jp"]
10
10
  spec.description = "A minimalist's tiny and ultra-fast database cleaner"
@@ -47,8 +47,10 @@ module DatabaseRewinder
47
47
  end
48
48
  end or return
49
49
 
50
- match = sql.match(/\AINSERT INTO [`"]?([^\s`"]+)[`"]?/i)
51
- table = match[1] if match
50
+ match = sql.match(/\AINSERT INTO (?:\.*[`"]?([^.\s`"]+)[`"]?)*/i)
51
+ return unless match
52
+
53
+ table = match[1]
52
54
  if table
53
55
  cleaner.inserted_tables << table unless cleaner.inserted_tables.include? table
54
56
  cleaner.pool ||= connection.pool
@@ -12,6 +12,18 @@ module DatabaseRewinder
12
12
  end
13
13
  end
14
14
 
15
- ::ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :prepend, DatabaseRewinder::InsertRecorder if defined? ::ActiveRecord::ConnectionAdapters::SQLite3Adapter
16
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :prepend, DatabaseRewinder::InsertRecorder if defined? ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
17
- ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send :prepend, DatabaseRewinder::InsertRecorder if defined? ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
15
+ begin
16
+ require 'active_record/connection_adapters/sqlite3_adapter'
17
+ ::ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :prepend, DatabaseRewinder::InsertRecorder
18
+ rescue LoadError
19
+ end
20
+ begin
21
+ require 'active_record/connection_adapters/postgresql_adapter'
22
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :prepend, DatabaseRewinder::InsertRecorder
23
+ rescue LoadError
24
+ end
25
+ begin
26
+ require 'active_record/connection_adapters/abstract_mysql_adapter'
27
+ ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send :prepend, DatabaseRewinder::InsertRecorder
28
+ rescue LoadError
29
+ end
@@ -23,14 +23,39 @@ describe DatabaseRewinder do
23
23
  @cleaner = DatabaseRewinder.create_cleaner 'foo'
24
24
  connection = double('connection').as_null_object
25
25
  connection.instance_variable_set :'@config', {adapter: 'sqlite3', database: File.expand_path('db/test.sqlite3', Rails.root) }
26
- DatabaseRewinder.record_inserted_table(connection, 'INSERT INTO "foos" ("name") VALUES (?)')
26
+ DatabaseRewinder.record_inserted_table(connection, sql)
27
27
  end
28
28
  after do
29
29
  DatabaseRewinder.database_configuration = nil
30
30
  end
31
31
  subject { @cleaner }
32
32
 
33
- its(:inserted_tables) { should == ['foos'] }
33
+ context 'common database' do
34
+ context 'include database name' do
35
+ let(:sql) { 'INSERT INTO "database"."foos" ("name") VALUES (?)' }
36
+ its(:inserted_tables) { should == ['foos'] }
37
+ end
38
+ context 'only table name' do
39
+ let(:sql) { 'INSERT INTO "foos" ("name") VALUES (?)' }
40
+ its(:inserted_tables) { should == ['foos'] }
41
+ end
42
+ end
43
+
44
+ context 'DataBase accepts more than one dots in an object notation(exp: SQLServer)' do
45
+ context 'full joined' do
46
+ let(:sql) { 'INSERT INTO server.database.schema.foos ("name") VALUES (?)' }
47
+ its(:inserted_tables) { should == ['foos'] }
48
+ end
49
+ context 'missing one' do
50
+ let(:sql) { 'INSERT INTO database..foos ("name") VALUES (?)' }
51
+ its(:inserted_tables) { should == ['foos'] }
52
+ end
53
+
54
+ context 'missing two' do
55
+ let(:sql) { 'INSERT INTO server...foos ("name") VALUES (?)' }
56
+ its(:inserted_tables) { should == ['foos'] }
57
+ end
58
+ end
34
59
  end
35
60
 
36
61
  describe '.clean' do
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_rewinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-22 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - <
45
+ - - "<"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.99'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - <
52
+ - - "<"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.99'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: A minimalist's tiny and ultra-fast database cleaner
@@ -87,8 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
92
  - Gemfile
93
93
  - MIT_LICENSE
94
94
  - README.md
@@ -116,17 +116,17 @@ require_paths:
116
116
  - lib
117
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - '>='
119
+ - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.4.1
129
+ rubygems_version: 2.4.5
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: A minimalist's tiny and ultra-fast database cleaner