dump 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -11,7 +11,7 @@ describe DumpRake::Dump do
11
11
 
12
12
  describe "lock" do
13
13
  before do
14
- @yield_receiver = mock('yield_receiver')
14
+ @yield_receiver = double('yield_receiver')
15
15
  end
16
16
 
17
17
  it "should not yield if file does not exist" do
@@ -27,7 +27,7 @@ describe DumpRake::Dump do
27
27
  it "should not yield if file can not be locked" do
28
28
  @yield_receiver.should_not_receive(:fire)
29
29
 
30
- @file = mock('file')
30
+ @file = double('file')
31
31
  @file.should_receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(nil)
32
32
  @file.should_receive(:flock).with(File::LOCK_UN)
33
33
  @file.should_receive(:close)
@@ -41,7 +41,7 @@ describe DumpRake::Dump do
41
41
  it "should yield if file can not be locked" do
42
42
  @yield_receiver.should_receive(:fire)
43
43
 
44
- @file = mock('file')
44
+ @file = double('file')
45
45
  @file.should_receive(:flock).with(File::LOCK_EX | File::LOCK_NB).and_return(true)
46
46
  @file.should_receive(:flock).with(File::LOCK_UN)
47
47
  @file.should_receive(:close)
@@ -64,10 +64,10 @@ describe DumpRake::Dump do
64
64
 
65
65
  describe "with options" do
66
66
  before do
67
- @time = mock('time')
68
- @time.stub!(:utc).and_return(@time)
69
- @time.stub!(:strftime).and_return('19650414065945')
70
- Time.stub!(:now).and_return(@time)
67
+ @time = double('time')
68
+ @time.stub(:utc).and_return(@time)
69
+ @time.stub(:strftime).and_return('19650414065945')
70
+ Time.stub(:now).and_return(@time)
71
71
  end
72
72
 
73
73
  it "should generate path with no options" do
@@ -100,7 +100,7 @@ describe DumpRake::Dump do
100
100
  File.should_receive(:file?).with(path).at_least(1).and_return(true)
101
101
  path
102
102
  end
103
- Dir.stub!(:[]).and_return(paths)
103
+ Dir.stub(:[]).and_return(paths)
104
104
  end
105
105
 
106
106
  it "should search for files in dump dir when asked for list" do
@@ -128,7 +128,7 @@ describe DumpRake::Dump do
128
128
  File.should_receive(:file?).with(path).at_least(1).and_return(true)
129
129
  path
130
130
  end
131
- Dir.stub!(:[]).and_return(paths)
131
+ Dir.stub(:[]).and_return(paths)
132
132
  end
133
133
 
134
134
  it "should return all dumps if no tags send" do
@@ -6,16 +6,17 @@ DumpWriter = DumpRake::DumpWriter
6
6
  describe DumpWriter do
7
7
  describe "create" do
8
8
  it "should create selves instance and open" do
9
- @dump = mock('dump')
9
+ @dump = double('dump')
10
10
  @dump.should_receive(:open)
11
11
  DumpWriter.should_receive(:new).with('/abc/123.tmp').and_return(@dump)
12
12
  DumpWriter.create('/abc/123.tmp')
13
13
  end
14
14
 
15
15
  it "should call dump subroutines" do
16
- @dump = mock('dump')
17
- @dump.stub!(:open).and_yield(@dump)
18
- DumpWriter.stub!(:new).and_return(@dump)
16
+ @dump = double('dump')
17
+ @dump.stub(:open).and_yield(@dump)
18
+ @dump.stub(:silence).and_yield
19
+ DumpWriter.stub(:new).and_return(@dump)
19
20
 
20
21
  @dump.should_receive(:write_schema).ordered
21
22
  @dump.should_receive(:write_tables).ordered
@@ -28,15 +29,15 @@ describe DumpWriter do
28
29
 
29
30
  describe "open" do
30
31
  it "should create dir for dump" do
31
- Zlib::GzipWriter.stub!(:open)
32
+ Zlib::GzipWriter.stub(:open)
32
33
  FileUtils.should_receive(:mkpath).with('/abc/def/ghi')
33
34
  DumpWriter.new('/abc/def/ghi/123.tgz').open
34
35
  end
35
36
 
36
37
  it "should set stream to gzipped tar writer" do
37
- FileUtils.stub!(:mkpath)
38
- @gzip = mock('gzip')
39
- @stream = mock('stream')
38
+ FileUtils.stub(:mkpath)
39
+ @gzip = double('gzip')
40
+ @stream = double('stream')
40
41
  Zlib::GzipWriter.should_receive(:open).with(Pathname("123.tgz")).and_yield(@gzip)
41
42
  Archive::Tar::Minitar::Output.should_receive(:open).with(@gzip).and_yield(@stream)
42
43
  @gzip.should_receive(:mtime=).with(Time.utc(2000))
@@ -52,23 +53,23 @@ describe DumpWriter do
52
53
 
53
54
  describe "subroutines" do
54
55
  before do
55
- @tar = mock('tar')
56
- @stream = mock('stream', :tar => @tar)
56
+ @tar = double('tar')
57
+ @stream = double('stream', :tar => @tar)
57
58
  @config = {:tables => {}}
58
59
  @dump = DumpWriter.new('123.tgz')
59
- @dump.stub!(:stream).and_return(@stream)
60
- @dump.stub!(:config).and_return(@config)
61
- Progress.stub!(:io).and_return(StringIO.new)
60
+ @dump.stub(:stream).and_return(@stream)
61
+ @dump.stub(:config).and_return(@config)
62
+ Progress.stub(:io).and_return(StringIO.new)
62
63
  end
63
64
 
64
65
  describe "create_file" do
65
66
  it "should create temp file, yield it for writing, create file in tar and write it there" do
66
- @temp = mock('temp', :open => true, :length => 6, :read => 'qwfpgj')
67
+ @temp = double('temp', :open => true, :length => 6, :read => 'qwfpgj')
67
68
  @temp.should_receive(:write).with('qwfpgj')
68
- @temp.stub!(:eof?).and_return(false, true)
69
+ @temp.stub(:eof?).and_return(false, true)
69
70
  Tempfile.should_receive(:open).and_yield(@temp)
70
71
 
71
- @file = mock('file')
72
+ @file = double('file')
72
73
  @file.should_receive(:write).with('qwfpgj')
73
74
 
74
75
  @stream.tar.should_receive(:add_file_simple).with('abc/def.txt', :mode => 0100444, :size => 6).and_yield(@file)
@@ -87,16 +88,16 @@ describe DumpWriter do
87
88
  end
88
89
 
89
90
  it "should set ENV[SCHEMA] to path of returned file" do
90
- @file = mock('file', :path => 'db/schema.rb')
91
- @dump.stub!(:create_file).and_yield(@file)
91
+ @file = double('file', :path => 'db/schema.rb')
92
+ @dump.stub(:create_file).and_yield(@file)
92
93
  DumpRake::Env.should_receive(:with_env).with('SCHEMA' => 'db/schema.rb')
93
94
  @dump.write_schema
94
95
  end
95
96
 
96
97
  it "should call rake task db:schema:dump" do
97
- @file = mock('file', :path => 'db/schema.rb')
98
- @dump.stub!(:create_file).and_yield(@file)
99
- @task = mock('task')
98
+ @file = double('file', :path => 'db/schema.rb')
99
+ @dump.stub(:create_file).and_yield(@file)
100
+ @task = double('task')
100
101
  Rake::Task.should_receive(:[]).with('db:schema:dump').and_return(@task)
101
102
  @task.should_receive(:invoke)
102
103
  @dump.write_schema
@@ -105,14 +106,14 @@ describe DumpWriter do
105
106
 
106
107
  describe "write_tables" do
107
108
  it "should verify connection" do
108
- @dump.stub!(:tables_to_dump).and_return([])
109
+ @dump.stub(:tables_to_dump).and_return([])
109
110
  @dump.should_receive(:verify_connection)
110
111
  @dump.write_tables
111
112
  end
112
113
 
113
114
  it "should call write_table for each table returned by tables_to_dump" do
114
- @dump.stub!(:verify_connection)
115
- @dump.stub!(:tables_to_dump).and_return(%w[first second])
115
+ @dump.stub(:verify_connection)
116
+ @dump.stub(:tables_to_dump).and_return(%w[first second])
116
117
 
117
118
  @dump.should_receive(:write_table).with('first')
118
119
  @dump.should_receive(:write_table).with('second')
@@ -124,32 +125,32 @@ describe DumpWriter do
124
125
  describe "write_table" do
125
126
  it "should get row count and store it to config" do
126
127
  @dump.should_receive(:table_row_count).with('first').and_return(666)
127
- @dump.stub!(:create_file)
128
+ @dump.stub(:create_file)
128
129
  @dump.write_table('first')
129
130
  @config[:tables]['first'].should == 666
130
131
  end
131
132
 
132
133
  it "should create_file" do
133
- @dump.stub!(:table_row_count).and_return(666)
134
+ @dump.stub(:table_row_count).and_return(666)
134
135
  @dump.should_receive(:create_file)
135
136
  @dump.write_table('first')
136
137
  end
137
138
 
138
139
  it "should dump column names and values of each row" do
139
140
  @column_definitions = [
140
- mock('column', :name => 'id'),
141
- mock('column', :name => 'name'),
142
- mock('column', :name => 'associated_id')
141
+ double('column', :name => 'id'),
142
+ double('column', :name => 'name'),
143
+ double('column', :name => 'associated_id')
143
144
  ]
144
- ActiveRecord::Base.connection.stub!(:columns).and_return(@column_definitions)
145
+ ActiveRecord::Base.connection.stub(:columns).and_return(@column_definitions)
145
146
  @rows = [
146
147
  {'id' => 1, 'name' => 'a', 'associated_id' => 100},
147
148
  {'id' => 2, 'name' => 'b', 'associated_id' => 666},
148
149
  ]
149
150
 
150
- @file = mock('file')
151
- @dump.stub!(:table_row_count).and_return(666)
152
- @dump.stub!(:create_file).and_yield(@file)
151
+ @file = double('file')
152
+ @dump.stub(:table_row_count).and_return(666)
153
+ @dump.stub(:create_file).and_yield(@file)
153
154
 
154
155
  column_names = @column_definitions.map(&:name).sort
155
156
  @file.should_receive(:write).with(Marshal.dump(column_names)).ordered
@@ -168,7 +169,7 @@ describe DumpWriter do
168
169
 
169
170
  describe "write_assets" do
170
171
  before do
171
- @dump.stub!(:assets_root_link).and_yield('/tmp', 'assets')
172
+ @dump.stub(:assets_root_link).and_yield('/tmp', 'assets')
172
173
  end
173
174
 
174
175
  it "should call assets_to_dump" do
@@ -177,22 +178,22 @@ describe DumpWriter do
177
178
  end
178
179
 
179
180
  it "should change root to rails app root" do
180
- @file = mock('file')
181
- @dump.stub!(:assets_to_dump).and_return(%w[images videos])
182
- @dump.stub!(:create_file).and_yield(@file)
181
+ @file = double('file')
182
+ @dump.stub(:assets_to_dump).and_return(%w[images videos])
183
+ @dump.stub(:create_file).and_yield(@file)
183
184
 
184
185
  Dir.should_receive(:chdir).with(DumpRake::RailsRoot)
185
186
  @dump.write_assets
186
187
  end
187
188
 
188
189
  it "should put assets to config" do
189
- @file = mock('file')
190
- @dump.stub!(:assets_to_dump).and_return(%w[images/* videos])
191
- @dump.stub!(:create_file).and_yield(@file)
192
- Dir.stub!(:chdir).and_yield
193
- @tar = mock('tar_writer')
194
- Archive::Tar::Minitar::Output.stub!(:open).and_yield(@tar)
195
- Dir.stub!(:[]).and_return([])
190
+ @file = double('file')
191
+ @dump.stub(:assets_to_dump).and_return(%w[images/* videos])
192
+ @dump.stub(:create_file).and_yield(@file)
193
+ Dir.stub(:chdir).and_yield
194
+ @tar = double('tar_writer')
195
+ Archive::Tar::Minitar::Output.stub(:open).and_yield(@tar)
196
+ Dir.stub(:[]).and_return([])
196
197
  Dir.should_receive(:[]).with(*%w[images/* videos]).and_return(%w[images/a images/b videos])
197
198
 
198
199
  @dump.write_assets
@@ -201,12 +202,12 @@ describe DumpWriter do
201
202
  end
202
203
 
203
204
  it "should use glob to find files" do
204
- @file = mock('file')
205
- @dump.stub!(:assets_to_dump).and_return(%w[images/* videos])
206
- @dump.stub!(:create_file).and_yield(@file)
207
- Dir.stub!(:chdir).and_yield
208
- @tar = mock('tar_writer')
209
- Archive::Tar::Minitar::Output.stub!(:open).and_yield(@tar)
205
+ @file = double('file')
206
+ @dump.stub(:assets_to_dump).and_return(%w[images/* videos])
207
+ @dump.stub(:create_file).and_yield(@file)
208
+ Dir.stub(:chdir).and_yield
209
+ @tar = double('tar_writer')
210
+ Archive::Tar::Minitar::Output.stub(:open).and_yield(@tar)
210
211
 
211
212
  Dir.should_receive(:[]).with(*%w[images/* videos]).and_return(%w[images/a images/b videos])
212
213
  Dir.should_receive(:[]).with('images/a/**/*').and_return([])
@@ -217,12 +218,12 @@ describe DumpWriter do
217
218
  end
218
219
 
219
220
  it "should pack each file from assets_root_link" do
220
- @file = mock('file')
221
- @dump.stub!(:assets_to_dump).and_return(%w[images/* videos])
222
- @dump.stub!(:create_file).and_yield(@file)
223
- Dir.stub!(:chdir).and_yield
224
- @tar = mock('tar_writer')
225
- Archive::Tar::Minitar::Output.stub!(:open).and_yield(@tar)
221
+ @file = double('file')
222
+ @dump.stub(:assets_to_dump).and_return(%w[images/* videos])
223
+ @dump.stub(:create_file).and_yield(@file)
224
+ Dir.stub(:chdir).and_yield
225
+ @tar = double('tar_writer')
226
+ Archive::Tar::Minitar::Output.stub(:open).and_yield(@tar)
226
227
 
227
228
  Dir.should_receive(:[]).with(*%w[images/* videos]).and_return(%w[images/a images/b videos])
228
229
  Dir.should_receive(:[]).with('images/a/**/*').and_return([])
@@ -235,12 +236,12 @@ describe DumpWriter do
235
236
  end
236
237
 
237
238
  it "should pack each file" do
238
- @file = mock('file')
239
- @dump.stub!(:assets_to_dump).and_return(%w[images/* videos])
240
- @dump.stub!(:create_file).and_yield(@file)
241
- Dir.stub!(:chdir).and_yield
242
- @tar = mock('tar_writer')
243
- Archive::Tar::Minitar::Output.stub!(:open).and_yield(@tar)
239
+ @file = double('file')
240
+ @dump.stub(:assets_to_dump).and_return(%w[images/* videos])
241
+ @dump.stub(:create_file).and_yield(@file)
242
+ Dir.stub(:chdir).and_yield
243
+ @tar = double('tar_writer')
244
+ Archive::Tar::Minitar::Output.stub(:open).and_yield(@tar)
244
245
 
245
246
  Dir.should_receive(:[]).with(*%w[images/* videos]).and_return(%w[images/a images/b videos])
246
247
  Dir.should_receive(:[]).with('images/a/**/*').and_return(%w[a.jpg b.jpg])
@@ -255,12 +256,12 @@ describe DumpWriter do
255
256
  end
256
257
 
257
258
  it "should not raise if something fails when packing" do
258
- @file = mock('file')
259
- @dump.stub!(:assets_to_dump).and_return(%w[videos])
260
- @dump.stub!(:create_file).and_yield(@file)
261
- Dir.stub!(:chdir).and_yield
262
- @tar = mock('tar_writer')
263
- Archive::Tar::Minitar::Output.stub!(:open).and_yield(@tar)
259
+ @file = double('file')
260
+ @dump.stub(:assets_to_dump).and_return(%w[videos])
261
+ @dump.stub(:create_file).and_yield(@file)
262
+ Dir.stub(:chdir).and_yield
263
+ @tar = double('tar_writer')
264
+ Archive::Tar::Minitar::Output.stub(:open).and_yield(@tar)
264
265
 
265
266
  Dir.should_receive(:[]).with(*%w[videos]).and_return(%w[videos])
266
267
  Dir.should_receive(:[]).with('videos/**/*').and_return(%w[a.mov b.mov])
@@ -282,8 +283,8 @@ describe DumpWriter do
282
283
  end
283
284
 
284
285
  it "should dump column names and values of each row" do
285
- @file = mock('file')
286
- @dump.stub!(:create_file).and_yield(@file)
286
+ @file = double('file')
287
+ @dump.stub(:create_file).and_yield(@file)
287
288
  @config.replace({:tables => {'first' => 1, 'second' => 2}, :assets => %w[images videos]})
288
289
 
289
290
  @file.should_receive(:write).with(Marshal.dump(@config))
@@ -293,32 +294,32 @@ describe DumpWriter do
293
294
 
294
295
  describe "assets_to_dump" do
295
296
  it "should call rake task assets" do
296
- @task = mock('task')
297
+ @task = double('task')
297
298
  Rake::Task.should_receive(:[]).with('assets').and_return(@task)
298
299
  @task.should_receive(:invoke)
299
300
  @dump.assets_to_dump
300
301
  end
301
302
 
302
303
  it "should return array of assets if separator is colon" do
303
- @task = mock('task')
304
- Rake::Task.stub!(:[]).and_return(@task)
305
- @task.stub!(:invoke)
304
+ @task = double('task')
305
+ Rake::Task.stub(:[]).and_return(@task)
306
+ @task.stub(:invoke)
306
307
  DumpRake::Env.with_env(:assets => 'images:videos') do
307
308
  @dump.assets_to_dump.should == %w[images videos]
308
309
  end
309
310
  end
310
311
 
311
312
  it "should return array of assets if separator is comma" do
312
- @task = mock('task')
313
- Rake::Task.stub!(:[]).and_return(@task)
314
- @task.stub!(:invoke)
313
+ @task = double('task')
314
+ Rake::Task.stub(:[]).and_return(@task)
315
+ @task.stub(:invoke)
315
316
  DumpRake::Env.with_env(:assets => 'images,videos') do
316
317
  @dump.assets_to_dump.should == %w[images videos]
317
318
  end
318
319
  end
319
320
 
320
321
  it "should return empty array if calling rake task assets raises an exception" do
321
- Rake::Task.stub!(:[]).and_raise('task assets not found')
322
+ Rake::Task.stub(:[]).and_raise('task assets not found')
322
323
  DumpRake::Env.with_env(:assets => 'images:videos') do
323
324
  @dump.assets_to_dump.should == []
324
325
  end
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  describe 'RailsRoot' do
18
18
  before do
19
- @root = mock('root')
19
+ @root = double('root')
20
20
  @root.should_receive(:to_s).and_return(@root)
21
21
  end
22
22
 
@@ -25,7 +25,7 @@ describe 'RailsRoot' do
25
25
  temp_remove_const DumpRake, :RailsRoot
26
26
 
27
27
  it "should use Rails if it is present" do
28
- Object.const_set('Rails', mock('rails'))
28
+ Object.const_set('Rails', double('rails'))
29
29
  Rails.should_receive(:root).and_return(@root)
30
30
  load 'dump_rake/rails_root.rb'
31
31
  DumpRake::RailsRoot.should === @root
@@ -143,9 +143,9 @@ describe TableManipulation do
143
143
  describe "table_chunk_size" do
144
144
  it "should return chunk_size based on estimated average for row size" do
145
145
  should_receive(:table_columns).with('first').and_return(
146
- [mock(:column, :type => :integer, :limit => nil)] * 3 +
147
- [mock(:column, :type => :string, :limit => nil)] * 3 +
148
- [mock(:column, :type => :text, :limit => nil)]
146
+ [double(:column, :type => :integer, :limit => nil)] * 3 +
147
+ [double(:column, :type => :string, :limit => nil)] * 3 +
148
+ [double(:column, :type => :text, :limit => nil)]
149
149
  )
150
150
  table_chunk_size('first').should satisfy { |n|
151
151
  (TableManipulation::CHUNK_SIZE_MIN..TableManipulation::CHUNK_SIZE_MAX).include?(n)
@@ -154,14 +154,14 @@ describe TableManipulation do
154
154
 
155
155
  it "should not return value less than CHUNK_SIZE_MIN" do
156
156
  should_receive(:table_columns).with('first').and_return(
157
- [mock(:column, :type => :text, :limit => nil)] * 100
157
+ [double(:column, :type => :text, :limit => nil)] * 100
158
158
  )
159
159
  table_chunk_size('first').should == TableManipulation::CHUNK_SIZE_MIN
160
160
  end
161
161
 
162
162
  it "should not return value more than CHUNK_SIZE_MAX" do
163
163
  should_receive(:table_columns).with('first').and_return(
164
- [mock(:column, :type => :boolean, :limit => 1)] * 10
164
+ [double(:column, :type => :boolean, :limit => 1)] * 10
165
165
  )
166
166
  table_chunk_size('first').should == TableManipulation::CHUNK_SIZE_MAX
167
167
  end
@@ -169,7 +169,7 @@ describe TableManipulation do
169
169
 
170
170
  describe "table_columns" do
171
171
  it "should return table column definitions" do
172
- columns = [mock(:column), mock(:column), mock(:column)]
172
+ columns = [double(:column), double(:column), double(:column)]
173
173
  ActiveRecord::Base.connection.should_receive(:columns).with('first').and_return(columns)
174
174
  table_columns('first').should == columns
175
175
  end
@@ -179,13 +179,13 @@ describe TableManipulation do
179
179
  it "should return true only if table has column with name id and type :integer" do
180
180
  should_receive(:table_primary_key).at_least(3).times.and_return('id')
181
181
 
182
- should_receive(:table_columns).with('first').and_return([mock(:column, :name => 'id', :type => :integer), mock(:column, :name => 'title', :type => :integer)])
182
+ should_receive(:table_columns).with('first').and_return([double(:column, :name => 'id', :type => :integer), double(:column, :name => 'title', :type => :integer)])
183
183
  table_has_primary_column?('first').should be_true
184
184
 
185
- should_receive(:table_columns).with('second').and_return([mock(:column, :name => 'id', :type => :string), mock(:column, :name => 'title', :type => :integer)])
185
+ should_receive(:table_columns).with('second').and_return([double(:column, :name => 'id', :type => :string), double(:column, :name => 'title', :type => :integer)])
186
186
  table_has_primary_column?('second').should be_false
187
187
 
188
- should_receive(:table_columns).with('third').and_return([mock(:column, :name => 'name', :type => :integer), mock(:column, :name => 'title', :type => :integer)])
188
+ should_receive(:table_columns).with('third').and_return([double(:column, :name => 'name', :type => :integer), double(:column, :name => 'title', :type => :integer)])
189
189
  table_has_primary_column?('third').should be_false
190
190
  end
191
191
  end
@@ -248,7 +248,7 @@ describe TableManipulation do
248
248
 
249
249
  describe "select_all_by_sql" do
250
250
  it "should return all rows returned by database" do
251
- rows = [mock(:row), mock(:row), mock(:row)]
251
+ rows = [double(:row), double(:row), double(:row)]
252
252
  ActiveRecord::Base.connection.should_receive(:select_all).with("SELECT * FROM abc WHERE x = y").and_return(rows)
253
253
  select_all_by_sql("SELECT * FROM abc WHERE x = y").should == rows
254
254
  end