railsthemes 1.1.pre → 1.1.pre.2
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.
- data/Gemfile +2 -2
- data/bin/railsthemes +27 -12
- data/cacert.pem +3331 -0
- data/lib/railsthemes/email_installer.rb +73 -0
- data/lib/railsthemes/ensurer.rb +152 -0
- data/lib/railsthemes/installer.rb +116 -345
- data/lib/railsthemes/logging.rb +35 -0
- data/lib/railsthemes/theme_installer.rb +126 -0
- data/lib/railsthemes/utils.rb +116 -24
- data/lib/railsthemes/version.rb +1 -1
- data/lib/railsthemes.rb +22 -1
- data/railsthemes.gemspec +2 -0
- data/spec/fixtures/blank-assets/{base/app/assets/images/bg/sprite.png → email/app/assets/stylesheets/email.css} +0 -0
- data/spec/fixtures/blank-assets/{base/app/assets/images/image1.png → erb-css/base/app/assets/images/bg/sprite.png} +0 -0
- data/spec/fixtures/blank-assets/{base/app/assets/javascripts/jquery.dataTables.js → erb-css/base/app/assets/images/image1.png} +0 -0
- data/spec/fixtures/blank-assets/{base/app/assets/javascripts/scripts.js.erb → erb-css/base/app/assets/javascripts/jquery.dataTables.js} +0 -0
- data/spec/fixtures/blank-assets/{base/app/views/layouts/_interior_sidebar.html.erb → erb-css/base/app/assets/javascripts/scripts.js.erb} +0 -0
- data/spec/fixtures/blank-assets/{base → erb-css/base}/app/assets/stylesheets/style.css.erb +0 -0
- data/spec/fixtures/blank-assets/{base/app/views/layouts/application.html.erb → erb-css/base/app/views/layouts/_interior_sidebar.html.erb} +0 -0
- data/spec/fixtures/blank-assets/{base/app/views/layouts/homepage.html.erb → erb-css/base/app/views/layouts/application.html.erb} +0 -0
- data/spec/fixtures/blank-assets/{gems/formtastic/app/assets/stylesheets/formtastic.css.scss → erb-css/base/app/views/layouts/homepage.html.erb} +0 -0
- data/spec/fixtures/blank-assets/{gems/simple_form/app/assets/stylesheets/simple_form.css.scss → erb-css/gems/formtastic/app/assets/stylesheets/formtastic.css.scss} +0 -0
- data/spec/fixtures/blank-assets/erb-css/gems/simple_form/app/assets/stylesheets/simple_form.css.scss +0 -0
- data/spec/fixtures/{blank-assets.tar.gz → blank-assets-archived/email.tar.gz} +0 -0
- data/spec/fixtures/blank-assets-archived/erb-css.tar.gz +0 -0
- data/spec/lib/railsthemes/email_installer_spec.rb +8 -0
- data/spec/lib/railsthemes/ensurer_spec.rb +215 -0
- data/spec/lib/railsthemes/installer_spec.rb +100 -456
- data/spec/lib/railsthemes/theme_installer_spec.rb +206 -0
- data/spec/lib/railsthemes/utils_spec.rb +62 -0
- data/spec/spec_helper.rb +49 -0
- metadata +71 -26
- data/lib/railsthemes/win_cacerts.rb +0 -26
@@ -1,532 +1,176 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'railsthemes'
|
3
|
-
require '
|
3
|
+
require 'json'
|
4
4
|
|
5
5
|
describe Railsthemes::Installer do
|
6
|
-
def using_gems *gems
|
7
|
-
"GEM\nremote: https://rubygems.org/\nspecs:\n" +
|
8
|
-
gems.map{|gem| " #{gem}"}.join("\n") +
|
9
|
-
"\nGEM\n remote: https://rubygems.org/"
|
10
|
-
end
|
11
|
-
|
12
|
-
def using_gem_specs specs = {}
|
13
|
-
lines = []
|
14
|
-
specs.each { |name, version| lines << " #{name} (#{version})"}
|
15
|
-
"GEM\nremote: https://rubygems.org/\nspecs:\n" +
|
16
|
-
lines.join("\n") +
|
17
|
-
"\nGEM\n remote: https://rubygems.org/"
|
18
|
-
end
|
19
|
-
|
20
|
-
LOGFILE_NAME = 'railsthemes.log'
|
21
|
-
|
22
|
-
before :all do
|
23
|
-
File.delete(LOGFILE_NAME) if File.exists?(LOGFILE_NAME)
|
24
|
-
end
|
25
|
-
|
26
6
|
before do
|
27
|
-
|
28
|
-
@
|
29
|
-
@
|
30
|
-
|
31
|
-
|
32
|
-
@tempdir = ''
|
33
|
-
if OS.windows?
|
34
|
-
@tempdir = File.join('C:', 'Users', 'Admin', 'AppData', 'Local', 'Temp')
|
35
|
-
else
|
36
|
-
@tempdir = 'tmp'
|
37
|
-
end
|
38
|
-
stub(@installer).generate_tempdir_name { @tempdir }
|
39
|
-
FileUtils.touch('Gemfile.lock')
|
7
|
+
setup_logger
|
8
|
+
@installer = Railsthemes::Installer.new
|
9
|
+
@tempdir = stub_tempdir
|
10
|
+
|
11
|
+
stub(Railsthemes::Ensurer).ensure_clean_install_possible
|
40
12
|
end
|
41
13
|
|
42
14
|
describe :install_from_file_system do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
FileUtils.touch('filepath/base/a')
|
47
|
-
FileUtils.touch('filepath/base/b')
|
48
|
-
mock(@installer).post_copying_changes
|
49
|
-
|
50
|
-
@installer.install_from_file_system('filepath')
|
51
|
-
File.should exist('a')
|
52
|
-
File.should exist('b')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should handle directories that have spaces' do
|
56
|
-
FileUtils.mkdir_p('file path/base')
|
57
|
-
FileUtils.touch('file path/base/a')
|
58
|
-
FileUtils.touch('file path/base/b')
|
59
|
-
mock(@installer).post_copying_changes
|
60
|
-
|
61
|
-
@installer.install_from_file_system('file path')
|
62
|
-
File.should exist('a')
|
63
|
-
File.should exist('b')
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should handle windows style paths' do
|
67
|
-
FileUtils.mkdir_p('fp1/fp2/base')
|
68
|
-
FileUtils.touch('fp1/fp2/base/a')
|
69
|
-
FileUtils.touch('fp1/fp2/base/b')
|
70
|
-
FileUtils.mkdir_p('fp1/fp2/gems')
|
71
|
-
mock(@installer).post_copying_changes
|
72
|
-
|
73
|
-
@installer.install_from_file_system('fp1\fp2')
|
74
|
-
File.should exist('a')
|
75
|
-
File.should exist('b')
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should not copy system files' do
|
79
|
-
FileUtils.mkdir_p('filepath/base')
|
80
|
-
FileUtils.touch('filepath/base/.DS_Store')
|
81
|
-
mock(@installer).post_copying_changes
|
82
|
-
|
83
|
-
@installer.install_from_file_system('filepath')
|
84
|
-
File.should_not exist('.DS_Store')
|
85
|
-
end
|
15
|
+
before do
|
16
|
+
FakeFS::FileSystem.clone('spec/fixtures')
|
17
|
+
stub(Railsthemes::Utils).get_primary_configuration { ['erb', 'css'] }
|
86
18
|
end
|
87
19
|
|
88
|
-
describe '
|
20
|
+
describe 'installing theme' do
|
89
21
|
before do
|
90
|
-
|
91
|
-
FileUtils.mkdir_p('filepath/base/app/assets/stylesheets')
|
92
|
-
FileUtils.mkdir_p("app/assets/stylesheets")
|
93
|
-
@filename = 'app/assets/stylesheets/railsthemes_THEME_overrides.anything'
|
94
|
-
FileUtils.touch("filepath/base/#{@filename}")
|
95
|
-
mock(@installer).post_copying_changes
|
96
|
-
stub(@installer).popup_documentation
|
22
|
+
stub(@installer.email_installer).install_from_file_system(anything)
|
97
23
|
end
|
98
24
|
|
99
|
-
it 'should
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
@installer.install_from_file_system('filepath')
|
105
|
-
File.should exist(@filename)
|
106
|
-
File.read(@filename).should =~ /existing override/
|
25
|
+
it 'should install the right theme version' do
|
26
|
+
mock(@installer.theme_installer).install_from_file_system('spec/fixtures/blank-assets/erb-css')
|
27
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets'
|
107
28
|
end
|
108
29
|
|
109
|
-
it 'should
|
110
|
-
@installer.install_from_file_system('
|
111
|
-
|
112
|
-
|
30
|
+
it 'should install the right theme version if it is an archive in that directory' do
|
31
|
+
mock(@installer.theme_installer).install_from_file_system('spec/fixtures/blank-assets-archived/erb-css')
|
32
|
+
stub(@installer.email_installer).install_from_file_system(anything)
|
33
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets-archived'
|
113
34
|
end
|
114
35
|
end
|
115
36
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
archive = 'tarfile.tar.gz'
|
120
|
-
FileUtils.touch archive
|
121
|
-
mock(@installer).install_from_archive archive
|
122
|
-
@installer.install_from_file_system archive
|
37
|
+
describe 'installing email theme' do
|
38
|
+
before do
|
39
|
+
stub(@installer.theme_installer).install_from_file_system(anything)
|
123
40
|
end
|
124
41
|
|
125
|
-
it 'should
|
126
|
-
mock(
|
127
|
-
@installer.install_from_file_system '
|
42
|
+
it 'should install the email theme if present' do
|
43
|
+
mock(@installer.email_installer).install_from_file_system('spec/fixtures/blank-assets/email')
|
44
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets'
|
128
45
|
end
|
129
|
-
end
|
130
46
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@installer.install_from_file_system("does not exist")
|
47
|
+
it 'should install the archived email theme if present' do
|
48
|
+
mock(@installer.email_installer).install_from_file_system('spec/fixtures/blank-assets-archived/email')
|
49
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets-archived'
|
135
50
|
end
|
136
51
|
end
|
52
|
+
end
|
137
53
|
|
138
|
-
|
54
|
+
# should probably move documentation stuff to another class
|
55
|
+
describe 'popping up the documentation' do
|
56
|
+
context 'when installing from the file system' do
|
139
57
|
before do
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
FileUtils.touch('filepath/base/b')
|
144
|
-
FileUtils.mkdir_p('filepath/gems')
|
145
|
-
mock(@installer).post_copying_changes
|
58
|
+
FakeFS::FileSystem.clone('spec/fixtures')
|
59
|
+
stub(@installer.theme_installer).install_from_file_system(anything)
|
60
|
+
stub(@installer.email_installer).install_from_file_system(anything)
|
146
61
|
end
|
147
62
|
|
148
63
|
it 'should not pop it up when the user specified not to pop it up' do
|
149
64
|
@installer.doc_popup = false
|
150
65
|
dont_allow(@installer).popup_documentation
|
151
|
-
@installer.install_from_file_system '
|
66
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets'
|
152
67
|
end
|
153
68
|
|
154
69
|
it 'should pop it up when the user did not specify to not pop it up' do
|
155
70
|
mock(@installer).popup_documentation
|
156
|
-
@installer.install_from_file_system '
|
71
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets'
|
157
72
|
end
|
158
73
|
end
|
159
74
|
end
|
160
75
|
|
161
|
-
describe
|
162
|
-
it 'should
|
163
|
-
|
164
|
-
|
165
|
-
@installer.install_gems_from("spec/fixtures/blank-assets", ['formtastic', 'kaminari'])
|
166
|
-
File.should exist('app/assets/stylesheets/formtastic.css.scss')
|
167
|
-
File.should_not exist('app/assets/stylesheets/kaminari.css.scss')
|
168
|
-
File.should_not exist('app/assets/stylesheets/simple_form.css.scss')
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe :install_from_archive do
|
173
|
-
# does not work on Windows, NotImplementedError in tar module
|
174
|
-
it 'should extract and then install from that extracted directory' do
|
175
|
-
filename = 'spec/fixtures/blank-assets.tar.gz'
|
176
|
-
FakeFS::FileSystem.clone(filename)
|
177
|
-
mock(@installer).install_from_file_system @tempdir
|
178
|
-
@installer.install_from_archive filename
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe :archive? do
|
183
|
-
it 'should be true for tar.gz file' do
|
184
|
-
@installer.archive?('test/a/b/c/d.tar.gz').should be_true
|
76
|
+
describe 'popup_documentation' do
|
77
|
+
it 'should not open if the style guide does not exist' do
|
78
|
+
dont_allow(Launchy).open(anything)
|
79
|
+
@installer.popup_documentation
|
185
80
|
end
|
186
81
|
|
187
|
-
it 'should
|
188
|
-
|
82
|
+
it 'should open the style guide correctly if it exists' do
|
83
|
+
FileUtils.mkdir_p('doc')
|
84
|
+
filename = 'doc/Theme_Envy_Usage_And_Style_Guide.html'
|
85
|
+
FileUtils.touch(filename)
|
86
|
+
mock(Launchy).open(filename)
|
87
|
+
@installer.popup_documentation
|
189
88
|
end
|
190
89
|
end
|
191
90
|
|
192
|
-
describe '
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
'app/assets/javascripts/jquery.dataTables.js',
|
197
|
-
'app/assets/javascripts/scripts.js.erb',
|
198
|
-
'app/assets/stylesheets/style.css.erb',
|
199
|
-
'app/views/layouts/_interior_sidebar.html.erb',
|
200
|
-
'app/views/layouts/application.html.erb',
|
201
|
-
'app/views/layouts/homepage.html.erb'].each do |filename|
|
202
|
-
File.should exist(filename), "#{filename} was not present"
|
203
|
-
end
|
204
|
-
File.open('app/assets/stylesheets/style.css.erb').each do |line|
|
205
|
-
line.should match /style.css.erb/
|
206
|
-
end
|
91
|
+
describe '#download_from_hash' do
|
92
|
+
it 'should download and install main theme when theme specified' do
|
93
|
+
mock(Railsthemes::Utils).download(:url => 'theme_url', :save_to => "dir/erb-css.tar.gz")
|
94
|
+
@installer.download_from_hash({'theme' => 'theme_url'}, 'dir')
|
207
95
|
end
|
208
96
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
# should add some gems to the gemfile here and test gem installation
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'should extract correctly from directory' do
|
216
|
-
filename = 'spec/fixtures/blank-assets'
|
217
|
-
@installer.install_from_file_system filename
|
218
|
-
verify_end_to_end_operation
|
219
|
-
end
|
220
|
-
|
221
|
-
# does not work on Windows, NotImplementedError in tar module
|
222
|
-
it 'should extract correctly from archive' do
|
223
|
-
filename = 'spec/fixtures/blank-assets.tar.gz'
|
224
|
-
@installer.install_from_file_system filename
|
225
|
-
verify_end_to_end_operation
|
97
|
+
it 'should download and install email theme when email specified' do
|
98
|
+
mock(Railsthemes::Utils).download(:url => 'email_url', :save_to => "dir/email.tar.gz")
|
99
|
+
@installer.download_from_hash({'email' => 'email_url'}, 'dir')
|
226
100
|
end
|
227
101
|
end
|
228
102
|
|
229
|
-
describe
|
103
|
+
describe '#install_from_code' do
|
230
104
|
before do
|
231
|
-
|
232
|
-
file.puts "GEM\n remote: https://rubygems.org/"
|
233
|
-
end
|
105
|
+
mock(@installer).send_gemfile('code')
|
234
106
|
end
|
235
107
|
|
236
|
-
it 'should
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
@installer.send_gemfile('panozzaj@gmail.com:code')
|
108
|
+
it 'should download and install when the code is recognized' do
|
109
|
+
mock(@installer).get_download_hash('code') { :hash }
|
110
|
+
mock(@installer).download_from_hash(:hash, @tempdir)
|
111
|
+
mock(@installer).install_from_file_system(@tempdir)
|
112
|
+
@installer.install_from_code 'code'
|
242
113
|
end
|
243
114
|
|
244
|
-
it 'should
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
115
|
+
it 'should print an error message when the code is not recognized' do
|
116
|
+
mock(@installer).get_download_hash('code') { nil }
|
117
|
+
dont_allow(@installer).download_from_hash(:hash, @tempdir)
|
118
|
+
dont_allow(@installer).install_from_file_system(@tempdir)
|
119
|
+
mock(Railsthemes::Safe).log_and_abort(/didn't recognize/)
|
120
|
+
@installer.install_from_code 'code'
|
249
121
|
end
|
250
122
|
end
|
251
123
|
|
252
|
-
describe
|
253
|
-
it 'should
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
mock(Railsthemes::Safe).yes?(/wish to install/) { true }
|
261
|
-
mock(@installer).install_from_server('code')
|
262
|
-
@installer.ask_to_install_unsupported 'code'
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
describe :download_from_code do
|
267
|
-
it 'should abort if the VCS is not clean' do
|
268
|
-
mock(@installer).check_vcs_status { 'msg' }
|
269
|
-
mock(Railsthemes::Safe).log_and_abort('msg')
|
270
|
-
@installer.download_from_code 'thecode'
|
271
|
-
end
|
272
|
-
|
273
|
-
it 'should abort if the installer version is not up-to-date' do
|
274
|
-
mock(@installer).check_vcs_status
|
275
|
-
mock(@installer).check_installer_version { 'msg' }
|
276
|
-
mock(Railsthemes::Safe).log_and_abort('msg')
|
277
|
-
@installer.download_from_code 'thecode'
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'should ask the user if they still want to install when a Gemfile.lock is not present' do
|
281
|
-
File.unlink('Gemfile.lock')
|
282
|
-
mock(@installer).check_vcs_status
|
283
|
-
mock(@installer).check_installer_version
|
284
|
-
mock(@installer).ask_to_install_unsupported 'thecode'
|
285
|
-
@installer.download_from_code 'thecode'
|
286
|
-
end
|
287
|
-
|
288
|
-
it 'should ask the user if they still want to install when the rails version is < 3.1' do
|
289
|
-
mock(@installer).check_vcs_status
|
290
|
-
mock(@installer).check_installer_version
|
291
|
-
mock(@installer).rails_version { Gem::Version.new('3.0.9') }
|
292
|
-
mock(@installer).ask_to_install_unsupported 'thecode'
|
293
|
-
@installer.download_from_code 'thecode'
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'should install from the server otherwise' do
|
297
|
-
mock(@installer).check_vcs_status
|
298
|
-
mock(@installer).check_installer_version
|
299
|
-
mock(@installer).rails_version { Gem::Version.new('3.1.0') }
|
300
|
-
mock(@installer).install_from_server 'thecode'
|
301
|
-
@installer.download_from_code 'thecode'
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
def with_installer_version version, &block
|
306
|
-
old_version = Railsthemes::VERSION
|
307
|
-
Railsthemes.send(:remove_const, 'VERSION')
|
308
|
-
Railsthemes.const_set('VERSION', version)
|
309
|
-
|
310
|
-
block.call
|
311
|
-
|
312
|
-
Railsthemes.send(:remove_const, 'VERSION')
|
313
|
-
Railsthemes.const_set('VERSION', old_version)
|
314
|
-
end
|
315
|
-
|
316
|
-
describe '#check_installer_version' do
|
317
|
-
it 'should return message if the current installer version is < server recommendation' do
|
318
|
-
FakeWeb.register_uri :get, /\/installer\/version$/, :body => '1.0.4'
|
319
|
-
with_installer_version '1.0.3' do
|
320
|
-
result = @installer.check_installer_version
|
321
|
-
result.should_not be_nil
|
322
|
-
result.should match(/Your version is older than the recommended version/)
|
323
|
-
result.should match(/Your version: 1\.0\.3/)
|
324
|
-
result.should match(/Recommended version: 1\.0\.4/)
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
it 'should return nothing if the current installer version is = server recommendation' do
|
329
|
-
FakeWeb.register_uri :get, /\/installer\/version$/, :body => '1.0.4'
|
330
|
-
with_installer_version '1.0.4' do
|
331
|
-
result = @installer.check_installer_version
|
332
|
-
result.should be_nil
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'should return nothing if the current installer version is > server recommendation' do
|
337
|
-
FakeWeb.register_uri :get, /\/installer\/version$/, :body => '1.0.4'
|
338
|
-
with_installer_version '1.0.5' do
|
339
|
-
result = @installer.check_installer_version
|
340
|
-
result.should be_nil
|
341
|
-
end
|
124
|
+
describe '#get_download_hash' do
|
125
|
+
it 'should download the file correctly when valid configuration' do
|
126
|
+
FakeWeb.register_uri :get,
|
127
|
+
/download\?code=panozzaj@gmail.com:code&config=haml,scss&v=2/,
|
128
|
+
:body => { 'theme' => 'auth_url' }.to_json
|
129
|
+
mock(Railsthemes::Utils).get_primary_configuration { ['haml', 'scss'] }
|
130
|
+
result = @installer.get_download_hash 'panozzaj@gmail.com:code'
|
131
|
+
result.should == { 'theme' => 'auth_url' }
|
342
132
|
end
|
343
133
|
|
344
|
-
it 'should
|
345
|
-
FakeWeb.register_uri :get,
|
134
|
+
it 'should fail with an error message on any error message' do
|
135
|
+
FakeWeb.register_uri :get,
|
136
|
+
'https://railsthemes.com/download?code=panozzaj@gmail.com:code&config=',
|
346
137
|
:body => '', :status => ['401', 'Unauthorized']
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
describe '#install_from_server' do
|
352
|
-
context 'when a gemfile.lock is present' do
|
353
|
-
before do
|
354
|
-
mock(@installer).send_gemfile('panozzaj@gmail.com:code')
|
355
|
-
end
|
356
|
-
|
357
|
-
it 'should download the file correctly when valid configuration' do
|
358
|
-
FakeWeb.register_uri :get,
|
359
|
-
/download\?code=panozzaj@gmail.com:code&config=haml,scss/,
|
360
|
-
:body => 'auth_url'
|
361
|
-
mock(@installer).get_primary_configuration('') { 'haml,scss' }
|
362
|
-
mock(Railsthemes::Utils).download_file_to('auth_url', "#{@tempdir}/archive.tar.gz")
|
363
|
-
mock(@installer).install_from_archive "#{@tempdir}/archive.tar.gz"
|
364
|
-
@installer.install_from_server 'panozzaj@gmail.com:code'
|
365
|
-
end
|
366
|
-
|
367
|
-
it 'should fail with an error message on any error message' do
|
368
|
-
FakeWeb.register_uri :get,
|
369
|
-
'https://railsthemes.com/download?code=panozzaj@gmail.com:code&config=',
|
370
|
-
:body => '', :status => ['401', 'Unauthorized']
|
371
|
-
mock(@installer).get_primary_configuration('') { '' }
|
372
|
-
mock(Railsthemes::Safe).log_and_abort(/didn't recognize/)
|
373
|
-
@installer.install_from_server 'panozzaj@gmail.com:code'
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
describe '#get_primary_configuration' do
|
379
|
-
it 'should give erb,css when there is no Gemfile' do
|
380
|
-
@installer.get_primary_configuration('').should == 'erb,css'
|
381
|
-
end
|
382
|
-
|
383
|
-
it 'should give haml,scss when haml and sass are in the Gemfile' do
|
384
|
-
gemfile = using_gems 'haml', 'sass'
|
385
|
-
@installer.get_primary_configuration(gemfile).should == 'haml,scss'
|
386
|
-
end
|
387
|
-
|
388
|
-
it 'should give haml,css when sass is not in the Gemfile but haml is' do
|
389
|
-
gemfile = using_gems 'haml'
|
390
|
-
@installer.get_primary_configuration(gemfile).should == 'haml,css'
|
391
|
-
end
|
392
|
-
|
393
|
-
it 'should give erb,scss when haml is not in the gemfile but sass is' do
|
394
|
-
gemfile = using_gems 'sass'
|
395
|
-
@installer.get_primary_configuration(gemfile).should == 'erb,scss'
|
396
|
-
end
|
397
|
-
|
398
|
-
it 'should give erb,css when haml and sass are not in the gemfile' do
|
399
|
-
gemfile = using_gems
|
400
|
-
@installer.get_primary_configuration(gemfile).should == 'erb,css'
|
138
|
+
mock(Railsthemes::Utils).get_primary_configuration { [] }
|
139
|
+
mock(Railsthemes::Safe).log_and_abort(/didn't recognize/)
|
140
|
+
@installer.install_from_code 'panozzaj@gmail.com:code'
|
401
141
|
end
|
402
142
|
end
|
403
143
|
|
404
|
-
describe :
|
405
|
-
context '
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
it 'should return false, issues when the vcs is unclean' do
|
411
|
-
mock(Railsthemes::Safe).system_call('git status -s') { '# modified: installer_spec.rb' }
|
412
|
-
result = @installer.check_vcs_status
|
413
|
-
result.should match /Git reports/
|
414
|
-
result.should match /# modified: installer_spec\.rb/
|
415
|
-
result.should match /roll back or commit/
|
416
|
-
end
|
417
|
-
|
418
|
-
it 'should do nothing significant when the vcs is clean' do
|
419
|
-
mock(Railsthemes::Safe).system_call('git status -s') { '' }
|
420
|
-
@installer.check_vcs_status.should be_nil
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
context 'when Mercurial used' do
|
425
|
-
before do
|
426
|
-
Dir.mkdir('.hg')
|
427
|
-
end
|
428
|
-
|
429
|
-
it 'should exit when the vcs is unclean' do
|
430
|
-
mock(Railsthemes::Safe).system_call('hg status') { '? test.txt' }
|
431
|
-
result = @installer.check_vcs_status
|
432
|
-
result.should_not be_nil
|
433
|
-
result.should match /Mercurial reports/
|
434
|
-
result.should match /\? test\.txt/
|
435
|
-
result.should match /roll back or commit/
|
436
|
-
end
|
437
|
-
|
438
|
-
it 'should do nothing significant when the vcs is clean' do
|
439
|
-
mock(Railsthemes::Safe).system_call('hg status') { '' }
|
440
|
-
@installer.check_vcs_status.should be_nil
|
144
|
+
describe :send_gemfile do
|
145
|
+
context 'without Gemfile.lock present' do
|
146
|
+
it 'should not hit the server and should return nil' do
|
147
|
+
result = @installer.send_gemfile('panozzaj@gmail.com:code')
|
148
|
+
result.should be_nil
|
441
149
|
end
|
442
150
|
end
|
443
151
|
|
444
|
-
context '
|
152
|
+
context 'with Gemfile.lock present' do
|
445
153
|
before do
|
446
|
-
|
154
|
+
File.open('Gemfile.lock', 'w') do |file|
|
155
|
+
file.puts "GEM\n remote: https://rubygems.org/"
|
156
|
+
end
|
447
157
|
end
|
448
158
|
|
449
|
-
it 'should
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
159
|
+
it 'should hit the server with the Gemfile and return the results, arrayified' do
|
160
|
+
FakeFS.deactivate! # has an issue with generating tmpfiles otherwise
|
161
|
+
params = { :code => 'panozzaj@gmail.com:code', :gemfile_lock => File.new('Gemfile.lock', 'rb') }
|
162
|
+
FakeWeb.register_uri :post, 'https://railsthemes.com/gemfiles/parse',
|
163
|
+
:body => 'haml,scss', :parameters => params
|
164
|
+
@installer.send_gemfile('panozzaj@gmail.com:code')
|
455
165
|
end
|
456
166
|
|
457
|
-
it 'should
|
458
|
-
|
459
|
-
|
167
|
+
it 'should return a blank array when there are issues' do
|
168
|
+
FakeFS.deactivate! # has an issue with generating tmpfiles otherwise
|
169
|
+
FakeWeb.register_uri :post, 'https://railsthemes.com/gemfiles/parse',
|
170
|
+
:body => '', :parameters => :any, :status => ['401', 'Unauthorized']
|
171
|
+
@installer.send_gemfile('panozzaj@gmail.com:code')
|
460
172
|
end
|
461
173
|
end
|
462
174
|
end
|
463
175
|
|
464
|
-
describe '#create_railsthemes_demo_pages' do
|
465
|
-
before do
|
466
|
-
FileUtils.mkdir('config')
|
467
|
-
File.open(File.join('config', 'routes.rb'), 'w') do |f|
|
468
|
-
f.write <<-EOS
|
469
|
-
RailsApp::Application.routes.draw do
|
470
|
-
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
471
|
-
# Note: This route will make all actions in every controller accessible via GET requests.
|
472
|
-
# match ':controller(/:action(/:id(.:format)))'
|
473
|
-
end
|
474
|
-
EOS
|
475
|
-
end
|
476
|
-
end
|
477
|
-
|
478
|
-
it 'should create a RailsThemes controller' do
|
479
|
-
@installer.create_railsthemes_demo_pages
|
480
|
-
controller = File.join('app', 'controllers', 'railsthemes_controller.rb')
|
481
|
-
lines = File.read(controller).split("\n")
|
482
|
-
lines.count.should == 11
|
483
|
-
lines.first.should match /class RailsthemesController < ApplicationController/
|
484
|
-
end
|
485
|
-
|
486
|
-
it 'should insert lines into the routes file' do
|
487
|
-
@installer.create_railsthemes_demo_pages
|
488
|
-
routes_file = File.join('config', 'routes.rb')
|
489
|
-
lines = File.read(routes_file).split("\n")
|
490
|
-
lines.grep(/match 'railsthemes\/landing' => 'railsthemes#landing'/).count.should == 1
|
491
|
-
lines.grep(/match 'railsthemes\/inner' => 'railsthemes#inner'/).count.should == 1
|
492
|
-
lines.grep(/match 'railsthemes\/jquery_ui' => 'railsthemes#jquery_ui'/).count.should == 1
|
493
|
-
end
|
494
|
-
|
495
|
-
it 'should not insert lines into the routes file when run more than once' do
|
496
|
-
@installer.create_railsthemes_demo_pages
|
497
|
-
@installer.create_railsthemes_demo_pages
|
498
|
-
routes_file = File.join('config', 'routes.rb')
|
499
|
-
lines = File.read(routes_file).split("\n")
|
500
|
-
lines.grep(/match 'railsthemes\/landing' => 'railsthemes#landing'/).count.should == 1
|
501
|
-
lines.grep(/match 'railsthemes\/inner' => 'railsthemes#inner'/).count.should == 1
|
502
|
-
lines.grep(/match 'railsthemes\/jquery_ui' => 'railsthemes#jquery_ui'/).count.should == 1
|
503
|
-
end
|
504
|
-
end
|
505
|
-
|
506
|
-
describe '#rails_version' do
|
507
|
-
it 'should return the right version' do
|
508
|
-
gemfile = using_gem_specs :rails => '3.0.1'
|
509
|
-
@installer.rails_version(gemfile).version.should == '3.0.1'
|
510
|
-
end
|
511
|
-
|
512
|
-
it 'should return nil if there is no rails present' do
|
513
|
-
gemfile = using_gem_specs
|
514
|
-
@installer.rails_version(gemfile).should be_nil
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
describe 'popup_documentation' do
|
519
|
-
it 'should not open if the style guide does not exist' do
|
520
|
-
dont_allow(Launchy).open(anything)
|
521
|
-
@installer.popup_documentation
|
522
|
-
end
|
523
|
-
|
524
|
-
it 'should open the style guide correctly if it exists' do
|
525
|
-
FileUtils.mkdir_p('doc')
|
526
|
-
filename = 'doc/Theme_Envy_Usage_And_Style_Guide.html'
|
527
|
-
FileUtils.touch(filename)
|
528
|
-
mock(Launchy).open(filename)
|
529
|
-
@installer.popup_documentation
|
530
|
-
end
|
531
|
-
end
|
532
176
|
end
|