database_cleaner 0.6.7 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/lib/database_cleaner.rb +1 -3
  3. metadata +48 -154
  4. data/Gemfile.lock +0 -161
  5. data/History.txt +0 -173
  6. data/LICENSE +0 -20
  7. data/README.textile +0 -165
  8. data/Rakefile +0 -65
  9. data/TODO +0 -3
  10. data/VERSION.yml +0 -5
  11. data/cucumber.yml +0 -1
  12. data/examples/Gemfile +0 -48
  13. data/examples/Gemfile.lock +0 -161
  14. data/examples/config/database.yml.example +0 -8
  15. data/examples/db/sqlite_databases_go_here +0 -0
  16. data/examples/features/example.feature +0 -11
  17. data/examples/features/example_multiple_db.feature +0 -23
  18. data/examples/features/example_multiple_orm.feature +0 -22
  19. data/examples/features/step_definitions/activerecord_steps.rb +0 -31
  20. data/examples/features/step_definitions/couchpotato_steps.rb +0 -31
  21. data/examples/features/step_definitions/datamapper_steps.rb +0 -37
  22. data/examples/features/step_definitions/mongoid_steps.rb +0 -23
  23. data/examples/features/step_definitions/mongomapper_steps.rb +0 -31
  24. data/examples/features/step_definitions/translation_steps.rb +0 -55
  25. data/examples/features/support/env.rb +0 -62
  26. data/examples/lib/activerecord_models.rb +0 -41
  27. data/examples/lib/couchpotato_models.rb +0 -61
  28. data/examples/lib/datamapper_models.rb +0 -50
  29. data/examples/lib/mongoid_models.rb +0 -49
  30. data/examples/lib/mongomapper_models.rb +0 -51
  31. data/features/cleaning.feature +0 -22
  32. data/features/cleaning_default_strategy.feature +0 -19
  33. data/features/cleaning_multiple_dbs.feature +0 -21
  34. data/features/cleaning_multiple_orms.feature +0 -29
  35. data/features/step_definitions/database_cleaner_steps.rb +0 -32
  36. data/features/support/env.rb +0 -7
  37. data/features/support/feature_runner.rb +0 -39
  38. data/lib/database_cleaner/active_record/#transaction.rb# +0 -34
  39. data/lib/database_cleaner/active_record/base.rb +0 -53
  40. data/lib/database_cleaner/active_record/deletion.rb +0 -64
  41. data/lib/database_cleaner/active_record/transaction.rb +0 -26
  42. data/lib/database_cleaner/active_record/truncation.rb +0 -134
  43. data/lib/database_cleaner/base.rb +0 -136
  44. data/lib/database_cleaner/configuration.rb +0 -92
  45. data/lib/database_cleaner/couch_potato/base.rb +0 -7
  46. data/lib/database_cleaner/couch_potato/truncation.rb +0 -28
  47. data/lib/database_cleaner/cucumber.rb +0 -11
  48. data/lib/database_cleaner/data_mapper/base.rb +0 -21
  49. data/lib/database_cleaner/data_mapper/transaction.rb +0 -28
  50. data/lib/database_cleaner/data_mapper/truncation.rb +0 -175
  51. data/lib/database_cleaner/generic/base.rb +0 -23
  52. data/lib/database_cleaner/generic/truncation.rb +0 -43
  53. data/lib/database_cleaner/mongo/truncation.rb +0 -22
  54. data/lib/database_cleaner/mongo_mapper/base.rb +0 -20
  55. data/lib/database_cleaner/mongo_mapper/truncation.rb +0 -19
  56. data/lib/database_cleaner/mongoid/base.rb +0 -20
  57. data/lib/database_cleaner/mongoid/truncation.rb +0 -20
  58. data/lib/database_cleaner/null_strategy.rb +0 -15
  59. data/spec/database_cleaner/active_record/base_spec.rb +0 -141
  60. data/spec/database_cleaner/active_record/transaction_spec.rb +0 -65
  61. data/spec/database_cleaner/active_record/truncation_spec.rb +0 -82
  62. data/spec/database_cleaner/base_spec.rb +0 -478
  63. data/spec/database_cleaner/configuration_spec.rb +0 -294
  64. data/spec/database_cleaner/couch_potato/truncation_spec.rb +0 -41
  65. data/spec/database_cleaner/data_mapper/base_spec.rb +0 -30
  66. data/spec/database_cleaner/data_mapper/transaction_spec.rb +0 -23
  67. data/spec/database_cleaner/data_mapper/truncation_spec.rb +0 -11
  68. data/spec/database_cleaner/generic/base_spec.rb +0 -22
  69. data/spec/database_cleaner/generic/truncation_spec.rb +0 -78
  70. data/spec/database_cleaner/mongo_mapper/base_spec.rb +0 -33
  71. data/spec/database_cleaner/mongo_mapper/mongo_examples.rb +0 -8
  72. data/spec/database_cleaner/mongo_mapper/truncation_spec.rb +0 -74
  73. data/spec/database_cleaner/shared_strategy_spec.rb +0 -13
  74. data/spec/rcov.opts +0 -1
  75. data/spec/spec.opts +0 -7
  76. data/spec/spec_helper.rb +0 -19
@@ -1,175 +0,0 @@
1
- require "database_cleaner/generic/truncation"
2
- require 'database_cleaner/data_mapper/base'
3
-
4
- module DataMapper
5
- module Adapters
6
-
7
- class DataObjectsAdapter
8
-
9
- def storage_names(repository = :default)
10
- raise NotImplementedError
11
- end
12
-
13
- end
14
-
15
- class MysqlAdapter < DataObjectsAdapter
16
-
17
- # taken from http://github.com/godfat/dm-mapping/tree/master
18
- def storage_names(repository = :default)
19
- select 'SHOW TABLES'
20
- end
21
-
22
- def truncate_table(table_name)
23
- execute("TRUNCATE TABLE #{quote_name(table_name)};")
24
- end
25
-
26
- # copied from activerecord
27
- def disable_referential_integrity
28
- old = select("SELECT @@FOREIGN_KEY_CHECKS;")
29
- begin
30
- execute("SET FOREIGN_KEY_CHECKS = 0;")
31
- yield
32
- ensure
33
- execute("SET FOREIGN_KEY_CHECKS = ?", *old)
34
- end
35
- end
36
-
37
- end
38
-
39
-
40
- class Sqlite3Adapter < DataObjectsAdapter
41
-
42
- # taken from http://github.com/godfat/dm-mapping/tree/master
43
- def storage_names(repository = :default)
44
- # activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 177
45
- sql = <<-SQL.compress_lines
46
- SELECT name
47
- FROM sqlite_master
48
- WHERE type = 'table' AND NOT name = 'sqlite_sequence'
49
- SQL
50
- # activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 181
51
- select(sql)
52
- end
53
-
54
- def truncate_table(table_name)
55
- execute("DELETE FROM #{quote_name(table_name)};")
56
- end
57
-
58
- # this is a no-op copied from activerecord
59
- # i didn't find out if/how this is possible
60
- # activerecord also doesn't do more here
61
- def disable_referential_integrity
62
- yield
63
- end
64
-
65
- end
66
-
67
- class SqliteAdapter < DataObjectsAdapter
68
- # taken from http://github.com/godfat/dm-mapping/tree/master
69
- def storage_names(repository = :default)
70
- # activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 177
71
- sql = <<-SQL.compress_lines
72
- SELECT name
73
- FROM sqlite_master
74
- WHERE type = 'table' AND NOT name = 'sqlite_sequence'
75
- SQL
76
- # activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 181
77
- select(sql)
78
- end
79
-
80
- def truncate_table(table_name)
81
- execute("DELETE FROM #{quote_name(table_name)};")
82
- end
83
-
84
- # this is a no-op copied from activerecord
85
- # i didn't find out if/how this is possible
86
- # activerecord also doesn't do more here
87
- def disable_referential_integrity
88
- yield
89
- end
90
-
91
- end
92
-
93
- # FIXME
94
- # i don't know if this works
95
- # i basically just copied activerecord code to get a rough idea what they do.
96
- # i don't have postgres available, so i won't be the one to write this.
97
- # maybe codes below gets some postgres/datamapper user going, though.
98
- class PostgresAdapter < DataObjectsAdapter
99
-
100
- # taken from http://github.com/godfat/dm-mapping/tree/master
101
- def storage_names(repository = :default)
102
- sql = <<-SQL.compress_lines
103
- SELECT table_name FROM "information_schema"."tables"
104
- WHERE table_schema = current_schema() and table_type = 'BASE TABLE'
105
- SQL
106
- select(sql)
107
- end
108
-
109
- def truncate_table(table_name)
110
- execute("TRUNCATE TABLE #{quote_name(table_name)} CASCADE;")
111
- end
112
-
113
- # FIXME
114
- # copied from activerecord
115
- def supports_disable_referential_integrity?
116
- version = select("SHOW server_version")[0][0].split('.')
117
- (version[0].to_i >= 8 && version[1].to_i >= 1) ? true : false
118
- rescue
119
- return false
120
- end
121
-
122
- # FIXME
123
- # copied unchanged from activerecord
124
- def disable_referential_integrity(repository = :default)
125
- if supports_disable_referential_integrity? then
126
- execute(storage_names(repository).collect do |name|
127
- "ALTER TABLE #{quote_name(name)} DISABLE TRIGGER ALL"
128
- end.join(";"))
129
- end
130
- yield
131
- ensure
132
- if supports_disable_referential_integrity? then
133
- execute(storage_names(repository).collect do |name|
134
- "ALTER TABLE #{quote_name(name)} ENABLE TRIGGER ALL"
135
- end.join(";"))
136
- end
137
- end
138
-
139
- end
140
-
141
- end
142
- end
143
-
144
-
145
- module DatabaseCleaner
146
- module DataMapper
147
- class Truncation
148
- include ::DatabaseCleaner::DataMapper::Base
149
- include ::DatabaseCleaner::Generic::Truncation
150
-
151
- def clean(repository = nil)
152
- repository = self.db if repository.nil?
153
- adapter = ::DataMapper.repository(repository).adapter
154
- adapter.disable_referential_integrity do
155
- tables_to_truncate(repository).each do |table_name|
156
- adapter.truncate_table table_name
157
- end
158
- end
159
- end
160
-
161
- private
162
-
163
- def tables_to_truncate(repository = nil)
164
- repository = self.db if repository.nil?
165
- (@only || ::DataMapper.repository(repository).adapter.storage_names(repository)) - @tables_to_exclude
166
- end
167
-
168
- # overwritten
169
- def migration_storage_name
170
- 'migration_info'
171
- end
172
-
173
- end
174
- end
175
- end
@@ -1,23 +0,0 @@
1
- module ::DatabaseCleaner
2
- module Generic
3
- module Base
4
-
5
- def self.included(base)
6
- base.extend(ClassMethods)
7
- base.send(:include, InstanceMethods)
8
- end
9
-
10
- module InstanceMethods
11
- def db
12
- :default
13
- end
14
- end
15
-
16
- module ClassMethods
17
- def available_strategies
18
- %W[]
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,43 +0,0 @@
1
- module DatabaseCleaner
2
- module Generic
3
- module Truncation
4
- def self.included(base)
5
- base.send(:include, InstanceMethods)
6
- end
7
-
8
- module InstanceMethods
9
- def initialize(opts={})
10
- if !opts.empty? && !(opts.keys - [:only, :except]).empty?
11
- raise ArgumentError, "The only valid options are :only and :except. You specified #{opts.keys.join(',')}."
12
- end
13
- if opts.has_key?(:only) && opts.has_key?(:except)
14
- raise ArgumentError, "You may only specify either :only or :either. Doing both doesn't really make sense does it?"
15
- end
16
-
17
- @only = opts[:only]
18
- @tables_to_exclude = (opts[:except] || []).dup
19
- @tables_to_exclude << migration_storage_name unless migration_storage_name.nil?
20
- end
21
-
22
- def start
23
- #included for compatability reasons, do nothing if you don't need to
24
- end
25
-
26
- def clean
27
- raise NotImplementedError
28
- end
29
-
30
- private
31
- def tables_to_truncate
32
- raise NotImplementedError
33
- end
34
-
35
- # overwrite in subclasses
36
- # default implementation given because migration storage need not be present
37
- def migration_storage_name
38
- nil
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,22 +0,0 @@
1
- module DatabaseCleaner
2
- module Mongo
3
- module Truncation
4
-
5
- def clean
6
- if @only
7
- collections.each { |c| c.remove if @only.include?(c.name) }
8
- else
9
- collections.each { |c| c.remove unless @tables_to_exclude.include?(c.name) }
10
- end
11
- true
12
- end
13
-
14
- private
15
-
16
- def collections
17
- database.collections.select { |c| c.name !~ /^system\./ }
18
- end
19
-
20
- end
21
- end
22
- end
@@ -1,20 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
- module DatabaseCleaner
3
- module MongoMapper
4
- def self.available_strategies
5
- %w[truncation]
6
- end
7
-
8
- module Base
9
- include ::DatabaseCleaner::Generic::Base
10
-
11
- def db=(desired_db)
12
- @db = desired_db
13
- end
14
-
15
- def db
16
- @db || :default
17
- end
18
- end
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- require 'database_cleaner/mongo_mapper/base'
2
- require 'database_cleaner/generic/truncation'
3
- require 'database_cleaner/mongo/truncation'
4
-
5
- module DatabaseCleaner
6
- module MongoMapper
7
- class Truncation
8
- include ::DatabaseCleaner::MongoMapper::Base
9
- include ::DatabaseCleaner::Generic::Truncation
10
- include ::DatabaseCleaner::Mongo::Truncation
11
-
12
- private
13
-
14
- def database
15
- ::MongoMapper.database
16
- end
17
- end
18
- end
19
- end
@@ -1,20 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
- module DatabaseCleaner
3
- module Mongoid
4
- def self.available_strategies
5
- %w[truncation]
6
- end
7
-
8
- module Base
9
- include ::DatabaseCleaner::Generic::Base
10
-
11
- def db=(desired_db)
12
- @db = desired_db
13
- end
14
-
15
- def db
16
- @db || :default
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require 'database_cleaner/mongoid/base'
2
- require 'database_cleaner/generic/truncation'
3
- require 'database_cleaner/mongo/truncation'
4
-
5
- module DatabaseCleaner
6
- module Mongoid
7
- class Truncation
8
- include ::DatabaseCleaner::Mongoid::Base
9
- include ::DatabaseCleaner::Generic::Truncation
10
- include ::DatabaseCleaner::Mongo::Truncation
11
-
12
- private
13
-
14
- def database
15
- ::Mongoid.database
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,15 +0,0 @@
1
- module DatabaseCleaner
2
- class NullStrategy
3
- def self.start
4
- # no-op
5
- end
6
-
7
- def self.db=(connection)
8
- # no-op
9
- end
10
-
11
- def self.clean
12
- # no-op
13
- end
14
- end
15
- end
@@ -1,141 +0,0 @@
1
- require 'spec_helper'
2
- require 'active_record'
3
- require 'database_cleaner/active_record/base'
4
- require 'database_cleaner/shared_strategy_spec'
5
-
6
- module DatabaseCleaner
7
- describe ActiveRecord do
8
- it { should respond_to(:available_strategies) }
9
-
10
- describe "config_file_location" do
11
- subject { ActiveRecord.config_file_location }
12
-
13
- it "should default to DatabaseCleaner.root / config / database.yml" do
14
- ActiveRecord.config_file_location=nil
15
- DatabaseCleaner.should_receive(:app_root).and_return("/path/to")
16
- subject.should == '/path/to/config/database.yml'
17
- end
18
- end
19
-
20
- end
21
-
22
- module ActiveRecord
23
- class ExampleStrategy
24
- include ::DatabaseCleaner::ActiveRecord::Base
25
- end
26
-
27
- describe ExampleStrategy do
28
- let :config_location do
29
- '/path/to/config/database.yml'
30
- end
31
-
32
- before { ::DatabaseCleaner::ActiveRecord.stub(:config_file_location).and_return(config_location) }
33
-
34
- it_should_behave_like "a generic strategy"
35
-
36
- describe "db" do
37
- it { should respond_to(:db=) }
38
-
39
- it "should store my desired db" do
40
- subject.stub(:load_config)
41
-
42
- subject.db = :my_db
43
- subject.db.should == :my_db
44
- end
45
-
46
- it "should default to :default" do
47
- subject.db.should == :default
48
- end
49
-
50
- it "should load_config when I set db" do
51
- subject.should_receive(:load_config)
52
- subject.db = :my_db
53
- end
54
- end
55
-
56
- describe "load_config" do
57
-
58
- it { should respond_to(:load_config) }
59
-
60
- before do
61
- yaml = <<-Y
62
- my_db:
63
- database: <%= "ONE".downcase %>
64
- Y
65
- File.stub(:file?).with(config_location).and_return(true)
66
- IO.stub(:read).with(config_location).and_return(yaml)
67
- end
68
-
69
- it "should parse the config" do
70
- YAML.should_receive(:load).and_return( {:nil => nil} )
71
- subject.load_config
72
- end
73
-
74
- it "should process erb in the config" do
75
- transformed = <<-Y
76
- my_db:
77
- database: one
78
- Y
79
- YAML.should_receive(:load).with(transformed).and_return({ "my_db" => {"database" => "one"} })
80
- subject.load_config
81
- end
82
-
83
- it "should store the relevant config in connection_hash" do
84
- subject.should_receive(:db).and_return(:my_db)
85
- subject.load_config
86
- subject.connection_hash.should == {"database" => "one"}
87
- end
88
-
89
- it "should skip config if config file is not available" do
90
- File.should_receive(:file?).with(config_location).and_return(false)
91
- subject.load_config
92
- subject.connection_hash.should be_blank
93
- end
94
- end
95
-
96
- describe "connection_hash" do
97
- it { should respond_to(:connection_hash) }
98
- it { should respond_to(:connection_hash=) }
99
- it "should store connection_hash" do
100
- subject.connection_hash = { :key => "value" }
101
- subject.connection_hash.should == { :key => "value" }
102
- end
103
- end
104
-
105
- describe "create_connection_klass" do
106
- it "should return a class" do
107
- subject.create_connection_klass.should be_a(Class)
108
- end
109
-
110
- it "should return a class extending ::ActiveRecord::Base" do
111
- subject.create_connection_klass.ancestors.should include(::ActiveRecord::Base)
112
- end
113
- end
114
-
115
- describe "connection_klass" do
116
- it { expect{ subject.connection_klass }.to_not raise_error }
117
- it "should default to ActiveRecord::Base" do
118
- subject.connection_klass.should == ::ActiveRecord::Base
119
- end
120
-
121
- context "when connection_hash is set" do
122
- let(:hash) { mock("hash") }
123
- before { subject.stub(:connection_hash).and_return(hash) }
124
-
125
- it "should create connection_klass if it doesnt exist if connection_hash is set" do
126
- subject.should_receive(:create_connection_klass).and_return(mock('class').as_null_object)
127
- subject.connection_klass
128
- end
129
-
130
- it "should configure the class from create_connection_klass if connection_hash is set" do
131
- klass = mock('klass')
132
- klass.should_receive(:establish_connection).with(hash)
133
-
134
- subject.should_receive(:create_connection_klass).and_return(klass)
135
- subject.connection_klass
136
- end
137
- end
138
- end
139
- end
140
- end
141
- end
@@ -1,65 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require 'database_cleaner/active_record/transaction'
3
- require 'active_record'
4
-
5
- module DatabaseCleaner
6
- module ActiveRecord
7
-
8
- describe Transaction do
9
- let (:connection) { mock("connection") }
10
- before(:each) do
11
- ::ActiveRecord::Base.stub!(:connection).and_return(connection)
12
- end
13
-
14
- describe "#start" do
15
- it "should increment open transactions if possible" do
16
- connection.stub!(:respond_to?).with(:increment_open_transactions).and_return(true)
17
- connection.stub!(:begin_db_transaction)
18
-
19
- connection.should_receive(:increment_open_transactions)
20
- Transaction.new.start
21
- end
22
-
23
- it "should tell ActiveRecord to increment connection if its not possible to increment current connection" do
24
- connection.stub!(:respond_to?).with(:increment_open_transactions).and_return(false)
25
- connection.stub!(:begin_db_transaction)
26
-
27
- ::ActiveRecord::Base.should_receive(:increment_open_transactions)
28
- Transaction.new.start
29
- end
30
-
31
- it "should start a transaction" do
32
- connection.stub!(:increment_open_transactions)
33
-
34
- connection.should_receive(:begin_db_transaction)
35
- Transaction.new.start
36
- end
37
- end
38
-
39
- describe "#clean" do
40
- it "should start a transaction" do
41
- connection.stub!(:decrement_open_transactions)
42
-
43
- connection.should_receive(:rollback_db_transaction)
44
- Transaction.new.clean
45
- end
46
- it "should decrement open transactions if possible" do
47
- connection.stub!(:respond_to?).with(:decrement_open_transactions).and_return(true)
48
- connection.stub!(:rollback_db_transaction)
49
-
50
- connection.should_receive(:decrement_open_transactions)
51
- Transaction.new.clean
52
- end
53
-
54
- it "should decrement connection via ActiveRecord::Base if connection won't" do
55
- connection.stub!(:respond_to?).with(:decrement_open_transactions).and_return(false)
56
- connection.stub!(:rollback_db_transaction)
57
-
58
- ::ActiveRecord::Base.should_receive(:decrement_open_transactions)
59
- Transaction.new.clean
60
- end
61
- end
62
- end
63
-
64
- end
65
- end
@@ -1,82 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
2
- require 'active_record'
3
- require 'database_cleaner/active_record/truncation'
4
-
5
-
6
- module ActiveRecord
7
- module ConnectionAdapters
8
- [MysqlAdapter, Mysql2Adapter, SQLite3Adapter, JdbcAdapter, PostgreSQLAdapter, IBM_DBAdapter].each do |adapter|
9
- describe adapter, "#truncate_table" do
10
- it "responds" do
11
- adapter.new("foo").should respond_to(:truncate_table)
12
- end
13
- it "should truncate the table"
14
- end
15
- end
16
- end
17
- end
18
-
19
- module DatabaseCleaner
20
- module ActiveRecord
21
-
22
- describe Truncation do
23
- let(:connection) { mock('connection') }
24
-
25
-
26
- before(:each) do
27
- connection.stub!(:disable_referential_integrity).and_yield
28
- connection.stub!(:views).and_return([])
29
- ::ActiveRecord::Base.stub!(:connection).and_return(connection)
30
- end
31
-
32
- it "should truncate all tables except for schema_migrations" do
33
- connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
34
-
35
- connection.should_receive(:truncate_table).with('widgets')
36
- connection.should_receive(:truncate_table).with('dogs')
37
- connection.should_not_receive(:truncate_table).with('schema_migrations')
38
-
39
- Truncation.new.clean
40
- end
41
-
42
- it "should only truncate the tables specified in the :only option when provided" do
43
- connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
44
-
45
- connection.should_receive(:truncate_table).with('widgets')
46
- connection.should_not_receive(:truncate_table).with('dogs')
47
-
48
- Truncation.new(:only => ['widgets']).clean
49
- end
50
-
51
- it "should not truncate the tables specified in the :except option" do
52
- connection.stub!(:tables).and_return(%w[schema_migrations widgets dogs])
53
-
54
- connection.should_receive(:truncate_table).with('dogs')
55
- connection.should_not_receive(:truncate_table).with('widgets')
56
-
57
- Truncation.new(:except => ['widgets']).clean
58
- end
59
-
60
- it "should raise an error when :only and :except options are used" do
61
- running {
62
- Truncation.new(:except => ['widgets'], :only => ['widgets'])
63
- }.should raise_error(ArgumentError)
64
- end
65
-
66
- it "should raise an error when invalid options are provided" do
67
- running { Truncation.new(:foo => 'bar') }.should raise_error(ArgumentError)
68
- end
69
-
70
- it "should not truncate views" do
71
- connection.stub!(:tables).and_return(%w[widgets dogs])
72
- connection.stub!(:views).and_return(["widgets"])
73
-
74
- connection.should_receive(:truncate_table).with('dogs')
75
- connection.should_not_receive(:truncate_table).with('widgets')
76
-
77
- Truncation.new.clean
78
- end
79
-
80
- end
81
- end
82
- end