dump 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -0
  3. data/.travis.database.yml +14 -0
  4. data/.travis.yml +30 -0
  5. data/Gemfile +20 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.markdown +5 -3
  8. data/dump.gemspec +1 -2
  9. data/lib/dump_rake/dump.rb +4 -0
  10. data/lib/dump_rake/dump_reader.rb +1 -1
  11. data/lib/dump_rake/dump_writer.rb +1 -1
  12. data/lib/dump_rake/table_manipulation.rb +1 -1
  13. data/spec/.gitignore +18 -0
  14. data/spec/cycle_spec.rb +22 -14
  15. data/spec/dummy-2.3/config/boot.rb +114 -0
  16. data/spec/dummy-2.3/config/database.yml +22 -0
  17. data/spec/dummy-2.3/config/environment.rb +41 -0
  18. data/spec/dummy-2.3/config/environments/development.rb +17 -0
  19. data/spec/dummy-2.3/config/environments/production.rb +28 -0
  20. data/spec/dummy-2.3/config/environments/test.rb +28 -0
  21. data/spec/dummy-2.3/config/initializers/backtrace_silencers.rb +7 -0
  22. data/spec/dummy-2.3/config/initializers/cookie_verification_secret.rb +7 -0
  23. data/spec/dummy-2.3/config/initializers/inflections.rb +10 -0
  24. data/spec/{dummy-3.1.3 → dummy-2.3}/config/initializers/mime_types.rb +0 -0
  25. data/spec/dummy-2.3/config/initializers/new_rails_defaults.rb +21 -0
  26. data/spec/dummy-2.3/config/initializers/session_store.rb +15 -0
  27. data/spec/dummy-2.3/config/locales/en.yml +5 -0
  28. data/spec/dummy-2.3/config/routes.rb +43 -0
  29. data/spec/dummy-2.3/db/seeds.rb +7 -0
  30. data/spec/dummy-3.0/.gitignore +4 -0
  31. data/spec/{dummy-3.1.3 → dummy-3.0}/config.ru +1 -1
  32. data/spec/dummy-3.0/config/application.rb +42 -0
  33. data/spec/{dummy-3.1.3 → dummy-3.0}/config/boot.rb +0 -0
  34. data/spec/dummy-3.0/config/database.yml +22 -0
  35. data/spec/{dummy-3.1.3 → dummy-3.0}/config/environment.rb +1 -1
  36. data/spec/dummy-3.0/config/environments/development.rb +26 -0
  37. data/spec/dummy-3.0/config/environments/production.rb +49 -0
  38. data/spec/dummy-3.0/config/environments/test.rb +35 -0
  39. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/backtrace_silencers.rb +0 -0
  40. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/inflections.rb +0 -0
  41. data/spec/dummy-3.0/config/initializers/mime_types.rb +5 -0
  42. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/secret_token.rb +1 -1
  43. data/spec/{dummy-3.1.3 → dummy-3.0}/config/initializers/session_store.rb +2 -2
  44. data/spec/dummy-3.0/config/locales/en.yml +5 -0
  45. data/spec/dummy-3.0/config/routes.rb +58 -0
  46. data/spec/dummy-3.0/db/seeds.rb +7 -0
  47. data/spec/{dummy-3.1.3 → dummy-3.1}/.gitignore +0 -0
  48. data/spec/dummy-3.1/config.ru +4 -0
  49. data/spec/{dummy-3.1.3 → dummy-3.1}/config/application.rb +2 -7
  50. data/spec/dummy-3.1/config/boot.rb +6 -0
  51. data/spec/{dummy-3.1.3 → dummy-3.1}/config/database.yml +0 -0
  52. data/spec/dummy-3.1/config/environment.rb +5 -0
  53. data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/development.rb +1 -6
  54. data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/production.rb +1 -14
  55. data/spec/{dummy-3.1.3 → dummy-3.1}/config/environments/test.rb +1 -1
  56. data/spec/dummy-3.1/config/initializers/backtrace_silencers.rb +7 -0
  57. data/spec/dummy-3.1/config/initializers/inflections.rb +10 -0
  58. data/spec/dummy-3.1/config/initializers/mime_types.rb +5 -0
  59. data/spec/dummy-3.1/config/initializers/secret_token.rb +7 -0
  60. data/spec/dummy-3.1/config/initializers/session_store.rb +8 -0
  61. data/spec/{dummy-3.1.3 → dummy-3.1}/config/initializers/wrap_parameters.rb +0 -0
  62. data/spec/{dummy-3.1.3 → dummy-3.1}/config/locales/en.yml +0 -0
  63. data/spec/{dummy-3.1.3 → dummy-3.1}/config/routes.rb +1 -1
  64. data/spec/{dummy-3.1.3 → dummy-3.1}/db/seeds.rb +0 -0
  65. data/spec/{dummy-3.1.3/app/mailers → dummy-3.1/log}/.gitkeep +0 -0
  66. data/spec/dummy-3.2/.gitignore +15 -0
  67. data/spec/dummy-3.2/config.ru +4 -0
  68. data/spec/dummy-3.2/config/application.rb +63 -0
  69. data/spec/dummy-3.2/config/boot.rb +6 -0
  70. data/spec/dummy-3.2/config/database.yml +25 -0
  71. data/spec/dummy-3.2/config/environment.rb +5 -0
  72. data/spec/dummy-3.2/config/environments/development.rb +32 -0
  73. data/spec/dummy-3.2/config/environments/production.rb +54 -0
  74. data/spec/dummy-3.2/config/environments/test.rb +37 -0
  75. data/spec/dummy-3.2/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/dummy-3.2/config/initializers/inflections.rb +15 -0
  77. data/spec/dummy-3.2/config/initializers/mime_types.rb +5 -0
  78. data/spec/dummy-3.2/config/initializers/secret_token.rb +7 -0
  79. data/spec/dummy-3.2/config/initializers/session_store.rb +8 -0
  80. data/spec/dummy-3.2/config/initializers/wrap_parameters.rb +14 -0
  81. data/spec/dummy-3.2/config/locales/en.yml +5 -0
  82. data/spec/dummy-3.2/config/routes.rb +58 -0
  83. data/spec/dummy-3.2/db/seeds.rb +7 -0
  84. data/spec/{dummy-3.1.3/app/models → dummy-3.2/log}/.gitkeep +0 -0
  85. data/spec/dummy-4.0/.gitignore +16 -0
  86. data/spec/dummy-4.0/config.ru +4 -0
  87. data/spec/dummy-4.0/config/application.rb +31 -0
  88. data/spec/dummy-4.0/config/boot.rb +4 -0
  89. data/spec/dummy-4.0/config/database.yml +25 -0
  90. data/spec/dummy-4.0/config/environment.rb +5 -0
  91. data/spec/dummy-4.0/config/environments/development.rb +25 -0
  92. data/spec/dummy-4.0/config/environments/production.rb +65 -0
  93. data/spec/dummy-4.0/config/environments/test.rb +36 -0
  94. data/spec/dummy-4.0/config/initializers/backtrace_silencers.rb +7 -0
  95. data/spec/dummy-4.0/config/initializers/filter_parameter_logging.rb +4 -0
  96. data/spec/dummy-4.0/config/initializers/inflections.rb +16 -0
  97. data/spec/dummy-4.0/config/initializers/mime_types.rb +5 -0
  98. data/spec/dummy-4.0/config/initializers/secret_token.rb +12 -0
  99. data/spec/dummy-4.0/config/initializers/session_store.rb +3 -0
  100. data/spec/dummy-4.0/config/initializers/wrap_parameters.rb +14 -0
  101. data/spec/dummy-4.0/config/locales/en.yml +23 -0
  102. data/spec/dummy-4.0/config/routes.rb +56 -0
  103. data/spec/dummy-4.0/db/seeds.rb +7 -0
  104. data/spec/{dummy-3.1.3/lib/assets/.gitkeep → dummy-4.0/log/.keep} +0 -0
  105. data/spec/lib/dump_rake/dump_reader_spec.rb +90 -89
  106. data/spec/lib/dump_rake/dump_spec.rb +9 -9
  107. data/spec/lib/dump_rake/dump_writer_spec.rb +79 -78
  108. data/spec/lib/dump_rake/rails_root_spec.rb +2 -2
  109. data/spec/lib/dump_rake/table_manipulation_spec.rb +10 -10
  110. data/spec/lib/dump_rake_spec.rb +34 -34
  111. data/spec/recipes/dump_spec.rb +34 -34
  112. data/spec/spec_helper.rb +35 -10
  113. data/spec/tasks/assets_spec.rb +6 -6
  114. metadata +240 -183
  115. data/spec/dummy-3.1.3/.rspec +0 -1
  116. data/spec/dummy-3.1.3/Gemfile +0 -14
  117. data/spec/dummy-3.1.3/Gemfile.lock +0 -133
  118. data/spec/dummy-3.1.3/README +0 -261
  119. data/spec/dummy-3.1.3/Rakefile +0 -7
  120. data/spec/dummy-3.1.3/app/assets/images/rails.png +0 -0
  121. data/spec/dummy-3.1.3/app/assets/javascripts/application.js +0 -9
  122. data/spec/dummy-3.1.3/app/assets/stylesheets/application.css +0 -7
  123. data/spec/dummy-3.1.3/app/controllers/application_controller.rb +0 -3
  124. data/spec/dummy-3.1.3/app/helpers/application_helper.rb +0 -2
  125. data/spec/dummy-3.1.3/app/views/layouts/application.html.erb +0 -14
  126. data/spec/dummy-3.1.3/doc/README_FOR_APP +0 -2
  127. data/spec/dummy-3.1.3/lib/tasks/.gitkeep +0 -0
  128. data/spec/dummy-3.1.3/log/.gitkeep +0 -0
  129. data/spec/dummy-3.1.3/public/404.html +0 -26
  130. data/spec/dummy-3.1.3/public/422.html +0 -26
  131. data/spec/dummy-3.1.3/public/500.html +0 -26
  132. data/spec/dummy-3.1.3/public/favicon.ico +0 -0
  133. data/spec/dummy-3.1.3/public/index.html +0 -241
  134. data/spec/dummy-3.1.3/public/robots.txt +0 -5
  135. data/spec/dummy-3.1.3/script/rails +0 -6
  136. data/spec/dummy-3.1.3/spec/spec_helper.rb +0 -32
  137. data/spec/dummy-3.1.3/vendor/assets/stylesheets/.gitkeep +0 -0
  138. data/spec/dummy-3.1.3/vendor/plugins/.gitkeep +0 -0
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy40::Application.config.secret_key_base = '3586b42c7cccac1ba714e7321305ef092a00b11a01c36b1801fd3f5cb959396078f013a32d15a35b2a55a5c208a23daf4e9b3d91f0e8d0bd3ae4df2eea1a7ac7'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy40::Application.config.session_store :cookie_store, key: '_dummy-4_0_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,56 @@
1
+ Dummy40::Application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -22,16 +22,17 @@ DumpReader = DumpRake::DumpReader
22
22
  describe DumpReader do
23
23
  describe "restore" do
24
24
  it "should create selves instance and open" do
25
- @dump = mock('dump')
25
+ @dump = double('dump')
26
26
  @dump.should_receive(:open)
27
27
  DumpReader.should_receive(:new).with('/abc/123.tmp').and_return(@dump)
28
28
  DumpReader.restore('/abc/123.tmp')
29
29
  end
30
30
 
31
31
  it "should call dump subroutines" do
32
- @dump = mock('dump')
33
- @dump.stub!(:open).and_yield(@dump)
34
- DumpReader.stub!(:new).and_return(@dump)
32
+ @dump = double('dump')
33
+ @dump.stub(:open).and_yield(@dump)
34
+ @dump.stub(:silence).and_yield
35
+ DumpReader.stub(:new).and_return(@dump)
35
36
 
36
37
  @dump.should_receive(:read_config).ordered
37
38
  @dump.should_receive(:migrate_down).ordered
@@ -80,7 +81,7 @@ describe DumpReader do
80
81
  end
81
82
 
82
83
  it "should create selves instance and open" do
83
- @dump = mock('dump')
84
+ @dump = double('dump')
84
85
  @dump.should_receive(:open)
85
86
  DumpReader.should_receive(:new).with('/abc/123.tmp').and_return(@dump)
86
87
  DumpReader.summary('/abc/123.tmp')
@@ -95,18 +96,18 @@ describe DumpReader do
95
96
  tables = {'a' => 10, 'b' => 20, 'c' => 666}
96
97
  formatted_tables = ['a: 10 rows', 'b: 20 rows', 'c: 666 rows']
97
98
 
98
- @dump = mock('dump')
99
- @dump.stub!(:config).and_return(:tables => tables, :assets => assets)
100
- @dump.stub!(:open).and_yield(@dump)
101
- DumpReader.stub!(:new).and_return(@dump)
99
+ @dump = double('dump')
100
+ @dump.stub(:config).and_return(:tables => tables, :assets => assets)
101
+ @dump.stub(:open).and_yield(@dump)
102
+ DumpReader.stub(:new).and_return(@dump)
102
103
  @dump.should_receive(:read_config)
103
104
 
104
- @summary = mock('summary')
105
+ @summary = double('summary')
105
106
  @summary.should_receive(:header).with('Tables')
106
107
  @summary.should_receive(:data).with(formatted_tables)
107
108
  @summary.should_receive(:header).with('Assets')
108
109
  @summary.should_receive(:data).with(formatted_assets)
109
- Summary.stub!(:new).and_return(@summary)
110
+ Summary.stub(:new).and_return(@summary)
110
111
 
111
112
  DumpReader.summary('/abc/123.tmp').should == @summary
112
113
  end
@@ -117,25 +118,25 @@ describe DumpReader do
117
118
  formatted_tables = ['a: 10 rows', 'b: 20 rows', 'c: 666 rows']
118
119
  assets = formatted_assets = %w[path/a path/b]
119
120
 
120
- schema = mock('schema')
121
- schema_lines = mock('schema_lines')
121
+ schema = double('schema')
122
+ schema_lines = double('schema_lines')
122
123
  schema.should_receive(:split).with("\n").and_return(schema_lines)
123
124
 
124
- @dump = mock('dump')
125
- @dump.stub!(:config).and_return(:tables => tables, :assets => assets)
126
- @dump.stub!(:open).and_yield(@dump)
127
- @dump.stub!(:schema).and_return(schema)
128
- DumpReader.stub!(:new).and_return(@dump)
125
+ @dump = double('dump')
126
+ @dump.stub(:config).and_return(:tables => tables, :assets => assets)
127
+ @dump.stub(:open).and_yield(@dump)
128
+ @dump.stub(:schema).and_return(schema)
129
+ DumpReader.stub(:new).and_return(@dump)
129
130
  @dump.should_receive(:read_config)
130
131
 
131
- @summary = mock('summary')
132
+ @summary = double('summary')
132
133
  @summary.should_receive(:header).with('Tables')
133
134
  @summary.should_receive(:data).with(formatted_tables)
134
135
  @summary.should_receive(:header).with('Assets')
135
136
  @summary.should_receive(:data).with(formatted_assets)
136
137
  @summary.should_receive(:header).with('Schema')
137
138
  @summary.should_receive(:data).with(schema_lines)
138
- Summary.stub!(:new).and_return(@summary)
139
+ Summary.stub(:new).and_return(@summary)
139
140
 
140
141
  DumpReader.summary('/abc/123.tmp', :schema => true).should == @summary
141
142
  end
@@ -143,8 +144,8 @@ describe DumpReader do
143
144
 
144
145
  describe "open" do
145
146
  it "should set stream to gzipped tar reader" do
146
- @gzip = mock('gzip')
147
- @stream = mock('stream')
147
+ @gzip = double('gzip')
148
+ @stream = double('stream')
148
149
  Zlib::GzipReader.should_receive(:open).with(Pathname("123.tgz")).and_yield(@gzip)
149
150
  Archive::Tar::Minitar::Input.should_receive(:open).with(@gzip).and_yield(@stream)
150
151
 
@@ -158,12 +159,12 @@ describe DumpReader do
158
159
 
159
160
  describe "low level" do
160
161
  before do
161
- @e1 = mock('e1', :full_name => 'config', :read => 'config_data')
162
- @e2 = mock('e2', :full_name => 'first.dump', :read => 'first.dump_data')
163
- @e3 = mock('e3', :full_name => 'second.dump', :read => 'second.dump_data')
162
+ @e1 = double('e1', :full_name => 'config', :read => 'config_data')
163
+ @e2 = double('e2', :full_name => 'first.dump', :read => 'first.dump_data')
164
+ @e3 = double('e3', :full_name => 'second.dump', :read => 'second.dump_data')
164
165
  @stream = [@e1, @e2, @e3]
165
166
  @dump = DumpReader.new('123.tgz')
166
- @dump.stub!(:stream).and_return(@stream)
167
+ @dump.stub(:stream).and_return(@stream)
167
168
  end
168
169
 
169
170
  describe "find_entry" do
@@ -204,9 +205,9 @@ describe DumpReader do
204
205
  end
205
206
 
206
207
  it "should open temp file, write data there, rewind and yield that file" do
207
- @entry = mock('entry')
208
- @dump.stub!(:find_entry).and_yield(@entry)
209
- @temp = mock('temp')
208
+ @entry = double('entry')
209
+ @dump.stub(:find_entry).and_yield(@entry)
210
+ @temp = double('temp')
210
211
  Tempfile.should_receive(:open).and_yield(@temp)
211
212
 
212
213
  @entry.should_receive(:eof?).and_return(false, false, true)
@@ -224,10 +225,10 @@ describe DumpReader do
224
225
 
225
226
  describe "subroutines" do
226
227
  before do
227
- @stream = mock('stream')
228
+ @stream = double('stream')
228
229
  @dump = DumpReader.new('123.tgz')
229
- @dump.stub!(:stream).and_return(@stream)
230
- Progress.stub!(:io).and_return(StringIO.new)
230
+ @dump.stub(:stream).and_return(@stream)
231
+ Progress.stub(:io).and_return(StringIO.new)
231
232
  end
232
233
 
233
234
  describe "read_config" do
@@ -257,8 +258,8 @@ describe DumpReader do
257
258
  end
258
259
 
259
260
  it "should invoke db:drop and db:create if migrate_down is reset" do
260
- @load_task = mock('drop_task')
261
- @dump_task = mock('create_task')
261
+ @load_task = double('drop_task')
262
+ @dump_task = double('create_task')
262
263
  Rake::Task.should_receive(:[]).with('db:drop').and_return(@load_task)
263
264
  Rake::Task.should_receive(:[]).with('db:create').and_return(@dump_task)
264
265
  @load_task.should_receive(:invoke)
@@ -272,7 +273,7 @@ describe DumpReader do
272
273
  [nil, '1'].each do |migrate_down_value|
273
274
  describe "when migrate_down is #{migrate_down_value.inspect}" do
274
275
  it "should not find_entry if table schema_migrations is not present" do
275
- @dump.stub!(:avaliable_tables).and_return(%w[first])
276
+ @dump.stub(:avaliable_tables).and_return(%w[first])
276
277
  @dump.should_not_receive(:find_entry)
277
278
 
278
279
  DumpRake::Env.with_env(:migrate_down => migrate_down_value) do
@@ -281,7 +282,7 @@ describe DumpReader do
281
282
  end
282
283
 
283
284
  it "should find schema_migrations.dump if table schema_migrations is present" do
284
- @dump.stub!(:avaliable_tables).and_return(%w[schema_migrations first])
285
+ @dump.stub(:avaliable_tables).and_return(%w[schema_migrations first])
285
286
  @dump.should_receive(:find_entry).with('schema_migrations.dump')
286
287
 
287
288
  DumpRake::Env.with_env(:migrate_down => migrate_down_value) do
@@ -297,12 +298,12 @@ describe DumpReader do
297
298
  end
298
299
  @entry.rewind
299
300
 
300
- @dump.stub!(:avaliable_tables).and_return(%w[schema_migrations first])
301
+ @dump.stub(:avaliable_tables).and_return(%w[schema_migrations first])
301
302
  @dump.should_receive(:find_entry).with('schema_migrations.dump').and_yield(@entry)
302
303
  @dump.should_receive('table_rows').with('schema_migrations').and_return(%w[1 2 4 5 6 7].map{ |version| {'version' => version} })
303
304
 
304
305
  @versions = []
305
- @migrate_down_task = mock('migrate_down_task')
306
+ @migrate_down_task = double('migrate_down_task')
306
307
  @migrate_down_task.should_receive('invoke').exactly(2).times.with do
307
308
  version = DumpRake::Env['VERSION']
308
309
  @versions << version
@@ -327,9 +328,9 @@ describe DumpReader do
327
328
 
328
329
  describe "read_schema" do
329
330
  before do
330
- @task = mock('task')
331
- Rake::Task.stub!(:[]).and_return(@task)
332
- @task.stub!(:invoke)
331
+ @task = double('task')
332
+ Rake::Task.stub(:[]).and_return(@task)
333
+ @task.stub(:invoke)
333
334
  end
334
335
 
335
336
  it "should read schema.rb to temp file" do
@@ -338,19 +339,19 @@ describe DumpReader do
338
339
  end
339
340
 
340
341
  it "should set ENV SCHEMA to temp files path" do
341
- @file = mock('tempfile', :path => '/temp/123-arst')
342
- @dump.stub!(:read_entry_to_file).and_yield(@file)
342
+ @file = double('tempfile', :path => '/temp/123-arst')
343
+ @dump.stub(:read_entry_to_file).and_yield(@file)
343
344
 
344
345
  DumpRake::Env.should_receive(:with_env).with('SCHEMA' => '/temp/123-arst')
345
346
  @dump.read_schema
346
347
  end
347
348
 
348
349
  it "should call task db:schema:load and db:schema:dump" do
349
- @file = mock('tempfile', :path => '/temp/123-arst')
350
- @dump.stub!(:read_entry_to_file).and_yield(@file)
350
+ @file = double('tempfile', :path => '/temp/123-arst')
351
+ @dump.stub(:read_entry_to_file).and_yield(@file)
351
352
 
352
- @load_task = mock('load_task')
353
- @dump_task = mock('dump_task')
353
+ @load_task = double('load_task')
354
+ @dump_task = double('dump_task')
354
355
  Rake::Task.should_receive(:[]).with('db:schema:load').and_return(@load_task)
355
356
  Rake::Task.should_receive(:[]).with('db:schema:dump').and_return(@dump_task)
356
357
  @load_task.should_receive(:invoke)
@@ -370,14 +371,14 @@ describe DumpReader do
370
371
 
371
372
  describe "read_tables" do
372
373
  it "should verify connection" do
373
- @dump.stub!(:config).and_return({:tables => []})
374
+ @dump.stub(:config).and_return({:tables => []})
374
375
  @dump.should_receive(:verify_connection)
375
376
  @dump.read_tables
376
377
  end
377
378
 
378
379
  it "should call read_table for each table in config" do
379
- @dump.stub!(:verify_connection)
380
- @dump.stub!(:config).and_return({:tables => {'first' => 1, 'second' => 3}})
380
+ @dump.stub(:verify_connection)
381
+ @dump.stub(:config).and_return({:tables => {'first' => 1, 'second' => 3}})
381
382
 
382
383
  @dump.should_receive(:read_table).with('first', 1)
383
384
  @dump.should_receive(:read_table).with('second', 3)
@@ -394,7 +395,7 @@ describe DumpReader do
394
395
  end
395
396
 
396
397
  it "should clear table and read table if entry found for table" do
397
- @entry = mock('entry', :to_str => Marshal.dump('data'), :eof? => true)
398
+ @entry = double('entry', :to_str => Marshal.dump('data'), :eof? => true)
398
399
  @dump.should_receive(:columns_insert_sql).with('data')
399
400
  @dump.should_receive(:find_entry).with('first.dump').and_yield(@entry)
400
401
  @dump.should_receive(:quote_table_name).with('first').and_return('`first`')
@@ -403,7 +404,7 @@ describe DumpReader do
403
404
  end
404
405
 
405
406
  it "should clear schema table before writing" do
406
- @entry = mock('entry', :to_str => Marshal.dump('data'), :eof? => true)
407
+ @entry = double('entry', :to_str => Marshal.dump('data'), :eof? => true)
407
408
  @dump.should_receive(:columns_insert_sql).with('data')
408
409
  @dump.should_receive(:find_entry).with('schema_migrations.dump').and_yield(@entry)
409
410
  @dump.should_receive(:quote_table_name).with('schema_migrations').and_return('`schema_migrations`')
@@ -425,19 +426,19 @@ describe DumpReader do
425
426
  end
426
427
  @entry.rewind
427
428
 
428
- @dump.stub!(:find_entry).and_yield(@entry)
429
+ @dump.stub(:find_entry).and_yield(@entry)
429
430
  end
430
431
  it "should read to eof" do
431
432
  create_entry(2500)
432
- @dump.stub!(:clear_table)
433
- @dump.stub!(:insert_into_table)
433
+ @dump.stub(:clear_table)
434
+ @dump.stub(:insert_into_table)
434
435
  @dump.read_table('first', 2500)
435
436
  @entry.eof?.should be_true
436
437
  end
437
438
 
438
439
  it "should try to insert rows in slices of 1000 rows" do
439
440
  create_entry(2500)
440
- @dump.stub!(:clear_table)
441
+ @dump.stub(:clear_table)
441
442
  @dump.should_receive(:insert_into_table).with(anything, anything, object_of_length(1000)).twice
442
443
  @dump.should_receive(:insert_into_table).with(anything, anything, object_of_length(500)).once
443
444
 
@@ -446,7 +447,7 @@ describe DumpReader do
446
447
 
447
448
  it "should try to insert row by row if slice method fails" do
448
449
  create_entry(2500)
449
- @dump.stub!(:clear_table)
450
+ @dump.stub(:clear_table)
450
451
  @dump.should_receive(:insert_into_table).with(anything, anything, kind_of(Array)).exactly(3).times.and_raise('sql error')
451
452
  @dump.should_receive(:insert_into_table).with(anything, anything, kind_of(String)).exactly(2500).times
452
453
  @dump.read_table('first', 2500)
@@ -454,7 +455,7 @@ describe DumpReader do
454
455
 
455
456
  it "should quote table, columns and values and send them to insert_into_table" do
456
457
  create_entry(100)
457
- @dump.stub!(:clear_table)
458
+ @dump.stub(:clear_table)
458
459
  @dump.should_receive(:quote_table_name).with('first').and_return('`first`')
459
460
  @dump.should_receive(:columns_insert_sql).with(@columns).and_return('(`id`, `name`)')
460
461
  @rows.each do |row|
@@ -469,33 +470,33 @@ describe DumpReader do
469
470
 
470
471
  describe "read_assets" do
471
472
  before do
472
- @task = mock('task')
473
- Rake::Task.stub!(:[]).with('assets:delete').and_return(@task)
474
- @task.stub!(:invoke)
475
- @dump.stub!(:assets_root_link).and_yield('/tmp', 'assets')
473
+ @task = double('task')
474
+ Rake::Task.stub(:[]).with('assets:delete').and_return(@task)
475
+ @task.stub(:invoke)
476
+ @dump.stub(:assets_root_link).and_yield('/tmp', 'assets')
476
477
  end
477
478
 
478
479
  it "should not read assets if config[:assets] is nil" do
479
- @dump.stub!(:config).and_return({})
480
+ @dump.stub(:config).and_return({})
480
481
  @dump.should_not_receive(:find_entry)
481
482
  @dump.read_assets
482
483
  end
483
484
 
484
485
  it "should not read assets if config[:assets] is blank" do
485
- @dump.stub!(:config).and_return({:assets => []})
486
+ @dump.stub(:config).and_return({:assets => []})
486
487
  @dump.should_not_receive(:find_entry)
487
488
  @dump.read_assets
488
489
  end
489
490
 
490
491
  describe "deleting existing assets" do
491
492
  before do
492
- @stream.stub!(:each)
493
+ @stream.stub(:each)
493
494
  end
494
495
 
495
496
  it "should call assets:delete" do
496
497
  @assets = %w[images videos]
497
- @dump.stub!(:config).and_return({:assets => @assets})
498
- @dump.stub!(:find_entry)
498
+ @dump.stub(:config).and_return({:assets => @assets})
499
+ @dump.stub(:find_entry)
499
500
 
500
501
  @task.should_receive(:invoke)
501
502
 
@@ -504,8 +505,8 @@ describe DumpReader do
504
505
 
505
506
  it "should call assets:delete with ASSETS set to config[:assets] joined with :" do
506
507
  @assets = %w[images videos]
507
- @dump.stub!(:config).and_return({:assets => @assets})
508
- @dump.stub!(:find_entry)
508
+ @dump.stub(:config).and_return({:assets => @assets})
509
+ @dump.stub(:find_entry)
509
510
 
510
511
  def @task.invoke
511
512
  DumpRake::Env[:assets].should == 'images:videos'
@@ -517,7 +518,7 @@ describe DumpReader do
517
518
  describe "when called with restore_assets" do
518
519
  it "should delete files and dirs only in requested paths" do
519
520
  @assets = %w[images videos]
520
- @dump.stub!(:config).and_return({:assets => @assets})
521
+ @dump.stub(:config).and_return({:assets => @assets})
521
522
 
522
523
  DumpRake::Assets.should_receive('glob_asset_children').with('images', '**/*').and_return(%w[images images/a.jpg images/b.jpg])
523
524
  DumpRake::Assets.should_receive('glob_asset_children').with('videos', '**/*').and_return(%w[videos videos/a.mov])
@@ -545,10 +546,10 @@ describe DumpReader do
545
546
  describe "old style" do
546
547
  it "should find assets.tar" do
547
548
  @assets = %w[images videos]
548
- @dump.stub!(:config).and_return({:assets => @assets})
549
- Dir.stub!(:glob).and_return([])
550
- FileUtils.stub!(:remove_entry)
551
- @stream.stub!(:each)
549
+ @dump.stub(:config).and_return({:assets => @assets})
550
+ Dir.stub(:glob).and_return([])
551
+ FileUtils.stub(:remove_entry)
552
+ @stream.stub(:each)
552
553
 
553
554
  @dump.should_receive(:find_entry).with('assets.tar')
554
555
  @dump.read_assets
@@ -560,18 +561,18 @@ describe DumpReader do
560
561
  {'images' => {:files => 0, :total => 0}, 'videos' => {:files => 0, :total => 0}},
561
562
  ].each do |assets|
562
563
  it "should rewrite rewind method to empty method - to not raise exception, open tar and extract each entry" do
563
- @dump.stub!(:config).and_return({:assets => assets})
564
- Dir.stub!(:glob).and_return([])
565
- FileUtils.stub!(:remove_entry)
564
+ @dump.stub(:config).and_return({:assets => assets})
565
+ Dir.stub(:glob).and_return([])
566
+ FileUtils.stub(:remove_entry)
566
567
 
567
- @assets_tar = mock('assets_tar')
568
- @assets_tar.stub!(:rewind).and_raise('hehe - we want to rewind to center of gzip')
569
- @dump.stub!(:find_entry).and_yield(@assets_tar)
568
+ @assets_tar = double('assets_tar')
569
+ @assets_tar.stub(:rewind).and_raise('hehe - we want to rewind to center of gzip')
570
+ @dump.stub(:find_entry).and_yield(@assets_tar)
570
571
 
571
- @inp = mock('inp')
572
+ @inp = double('inp')
572
573
  each_excpectation = @inp.should_receive(:each)
573
574
  @entries = %w[a b c d].map do |s|
574
- file = mock("file_#{s}")
575
+ file = double("file_#{s}")
575
576
  each_excpectation.and_yield(file)
576
577
  @inp.should_receive(:extract_entry).with(DumpRake::RailsRoot, file)
577
578
  file
@@ -594,19 +595,19 @@ describe DumpReader do
594
595
  {'images' => {:files => 0, :total => 0}, 'videos' => {:files => 0, :total => 0}},
595
596
  ].each do |assets|
596
597
  it "should extract each entry" do
597
- @dump.stub!(:config).and_return({:assets => assets})
598
- Dir.stub!(:glob).and_return([])
599
- FileUtils.stub!(:remove_entry)
598
+ @dump.stub(:config).and_return({:assets => assets})
599
+ Dir.stub(:glob).and_return([])
600
+ FileUtils.stub(:remove_entry)
600
601
 
601
602
  @dump.should_receive(:assets_root_link).and_yield('/tmp/abc', 'assets')
602
603
  each_excpectation = @stream.should_receive(:each)
603
604
  @entries = %w[a b c d].map do |s|
604
- file = mock("file_#{s}", :full_name => "assets/#{s}")
605
+ file = double("file_#{s}", :full_name => "assets/#{s}")
605
606
  each_excpectation.and_yield(file)
606
607
  @stream.should_receive(:extract_entry).with('/tmp/abc', file)
607
608
  file
608
609
  end
609
- other_file = mock('other_file', :full_name => 'other_file')
610
+ other_file = double('other_file', :full_name => 'other_file')
610
611
  each_excpectation.and_yield(other_file)
611
612
  @stream.should_not_receive(:extract_entry).with('/tmp/abc', other_file)
612
613
 
@@ -618,8 +619,8 @@ describe DumpReader do
618
619
 
619
620
  describe "read_asset?" do
620
621
  it "should create filter and call custom_pass? on it" do
621
- @filter = mock('filter')
622
- @filter.stub!('custom_pass?')
622
+ @filter = double('filter')
623
+ @filter.stub('custom_pass?')
623
624
 
624
625
  DumpRake::Env.should_receive('filter').with(:restore_assets, DumpRake::Assets::SPLITTER).and_return(@filter)
625
626