geb 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +56 -12
- data/lib/geb/commands/server.rb +3 -2
- data/lib/geb/config.rb +88 -0
- data/lib/geb/defaults.rb +2 -2
- data/lib/geb/page.rb +35 -3
- data/lib/geb/samples/basic/assets/css/site.css +41 -2
- data/lib/geb/samples/basic/geb.config.yml +19 -3
- data/lib/geb/samples/basic/index.html +24 -1
- data/lib/geb/samples/basic/shared/partials/_footer.html +4 -0
- data/lib/geb/samples/basic/shared/partials/_geb.html +26 -0
- data/lib/geb/samples/basic/shared/partials/_header.html +9 -0
- data/lib/geb/samples/bootstrap_jquery/assets/css/site.css +68 -1
- data/lib/geb/samples/bootstrap_jquery/blog/blog_post_1.html +83 -25
- data/lib/geb/samples/bootstrap_jquery/blog/index.html +39 -6
- data/lib/geb/samples/bootstrap_jquery/geb.config.yml +20 -3
- data/lib/geb/samples/bootstrap_jquery/index.html +252 -2
- data/lib/geb/samples/bootstrap_jquery/page.html +24 -2
- data/lib/geb/samples/bootstrap_jquery/shared/partials/_footer.html +2 -0
- data/lib/geb/samples/bootstrap_jquery/shared/partials/_geb.html +26 -0
- data/lib/geb/samples/bootstrap_jquery/shared/partials/_header.html +25 -0
- data/lib/geb/samples/bootstrap_jquery/shared/partials/_meta_tags.html +1 -1
- data/lib/geb/samples/bootstrap_jquery/shared/templates/_blog_post.html +19 -0
- data/lib/geb/samples/bootstrap_jquery/site.webmanifest +1 -1
- data/lib/geb/samples/geb.config.yml +17 -0
- data/lib/geb/server.rb +12 -6
- data/lib/geb/site/build.rb +73 -61
- data/lib/geb/site/release.rb +23 -28
- data/lib/geb/site/remote.rb +1 -1
- data/lib/geb/site/template.rb +6 -0
- data/lib/geb/site.rb +7 -0
- data/lib/geb/template.rb +1 -0
- data/lib/geb/utilities.rb +1 -1
- data/lib/geb.rb +1 -1
- data/test/api tests/test_cli.rb +1 -1
- data/test/api tests/test_config.rb +132 -0
- data/test/api tests/test_page.rb +88 -4
- data/test/api tests/test_server.rb +96 -32
- data/test/api tests/test_site.rb +131 -31
- data/test/command tests/test_geb_build.rb +2 -2
- data/test/command tests/test_geb_release.rb +6 -8
- data/test/command tests/test_geb_server.rb +21 -0
- metadata +4 -4
- data/lib/geb/samples/bootstrap_jquery/blog/blog_post_2.html +0 -35
- data/lib/geb/samples/bootstrap_jquery/blog/blog_post_3.html +0 -35
@@ -17,8 +17,8 @@ class TestServer < Geb::ApiTest
|
|
17
17
|
|
18
18
|
site_mock = mock('site')
|
19
19
|
site_mock.stubs(:site_path).returns('site_path')
|
20
|
-
site_mock.stubs(:
|
21
|
-
site_mock.stubs(:
|
20
|
+
site_mock.stubs(:get_site_local_output_directory).returns('site_path/output')
|
21
|
+
site_mock.stubs(:get_site_release_output_directory).returns('site_path/release')
|
22
22
|
|
23
23
|
http_server_mock = mock('webric_httpserver')
|
24
24
|
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
@@ -29,7 +29,7 @@ class TestServer < Geb::ApiTest
|
|
29
29
|
WEBrick::HTTPServer.expects(:new).returns(http_server_mock)
|
30
30
|
Listen.stubs(:to).returns(file_watcher_mock)
|
31
31
|
|
32
|
-
server = Geb::Server.new(site_mock, 3456, true)
|
32
|
+
server = Geb::Server.new(site_mock, 3456, true, false)
|
33
33
|
|
34
34
|
assert_instance_of Geb::Server, server
|
35
35
|
|
@@ -42,8 +42,8 @@ class TestServer < Geb::ApiTest
|
|
42
42
|
|
43
43
|
site_mock = mock('site')
|
44
44
|
site_mock.stubs(:site_path).returns('site_path')
|
45
|
-
site_mock.stubs(:
|
46
|
-
site_mock.stubs(:
|
45
|
+
site_mock.stubs(:get_site_local_output_directory).returns('site_path/output')
|
46
|
+
site_mock.stubs(:get_site_release_output_directory).returns('site_path/release')
|
47
47
|
|
48
48
|
http_server_mock = mock('webric_httpserver')
|
49
49
|
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
@@ -54,7 +54,7 @@ class TestServer < Geb::ApiTest
|
|
54
54
|
WEBrick::HTTPServer.expects(:new).returns(http_server_mock)
|
55
55
|
Listen.stubs(:to).returns(file_watcher_mock)
|
56
56
|
|
57
|
-
server = Geb::Server.new(site_mock, 3456, false)
|
57
|
+
server = Geb::Server.new(site_mock, 3456, false, false)
|
58
58
|
|
59
59
|
assert_instance_of Geb::Server, server
|
60
60
|
|
@@ -67,8 +67,8 @@ class TestServer < Geb::ApiTest
|
|
67
67
|
|
68
68
|
site_mock = mock('site')
|
69
69
|
site_mock.stubs(:site_path).returns('site_path')
|
70
|
-
site_mock.stubs(:
|
71
|
-
site_mock.stubs(:
|
70
|
+
site_mock.stubs(:get_site_local_output_directory).returns('site_path/output')
|
71
|
+
site_mock.stubs(:get_site_release_output_directory).returns('site_path/release')
|
72
72
|
|
73
73
|
http_server_mock = mock('webric_httpserver')
|
74
74
|
http_server_mock.expects(:start)
|
@@ -81,7 +81,7 @@ class TestServer < Geb::ApiTest
|
|
81
81
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
82
82
|
Listen.stubs(:to).returns(file_watcher_mock)
|
83
83
|
|
84
|
-
server = Geb::Server.new(site_mock, 3456, true)
|
84
|
+
server = Geb::Server.new(site_mock, 3456, true, false)
|
85
85
|
|
86
86
|
server.start
|
87
87
|
|
@@ -104,8 +104,8 @@ class TestServer < Geb::ApiTest
|
|
104
104
|
|
105
105
|
site_mock = mock('site')
|
106
106
|
site_mock.stubs(:site_path).returns('site_path')
|
107
|
-
site_mock.stubs(:
|
108
|
-
site_mock.stubs(:
|
107
|
+
site_mock.stubs(:get_site_local_output_directory).returns('site_path/output')
|
108
|
+
site_mock.stubs(:get_site_release_output_directory).returns('site_path/release')
|
109
109
|
|
110
110
|
http_server_mock = mock('webric_httpserver')
|
111
111
|
http_server_mock.expects(:start)
|
@@ -118,7 +118,7 @@ class TestServer < Geb::ApiTest
|
|
118
118
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
119
119
|
Listen.stubs(:to).returns(file_watcher_mock)
|
120
120
|
|
121
|
-
server = Geb::Server.new(site_mock, 3456, false)
|
121
|
+
server = Geb::Server.new(site_mock, 3456, false, false)
|
122
122
|
|
123
123
|
server.start
|
124
124
|
|
@@ -140,8 +140,8 @@ class TestServer < Geb::ApiTest
|
|
140
140
|
|
141
141
|
site_mock = mock('site')
|
142
142
|
site_mock.stubs(:site_path).returns('site_path')
|
143
|
-
site_mock.stubs(:
|
144
|
-
site_mock.stubs(:
|
143
|
+
site_mock.stubs(:get_site_local_output_directory).returns('site_path/output')
|
144
|
+
site_mock.stubs(:get_site_release_output_directory).returns('site_path/release')
|
145
145
|
|
146
146
|
http_server_mock = mock('webric_httpserver')
|
147
147
|
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
@@ -157,7 +157,7 @@ class TestServer < Geb::ApiTest
|
|
157
157
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
158
158
|
Listen.stubs(:to).returns(file_watcher_mock)
|
159
159
|
|
160
|
-
server = Geb::Server.new(site_mock, 3456, true)
|
160
|
+
server = Geb::Server.new(site_mock, 3456, true, false)
|
161
161
|
|
162
162
|
server.start
|
163
163
|
|
@@ -174,8 +174,8 @@ class TestServer < Geb::ApiTest
|
|
174
174
|
|
175
175
|
site_mock = mock('site')
|
176
176
|
site_mock.stubs(:site_path).returns('site_path')
|
177
|
-
site_mock.stubs(:
|
178
|
-
site_mock.stubs(:
|
177
|
+
site_mock.stubs(:get_site_local_output_directory).returns('site_path/output')
|
178
|
+
site_mock.stubs(:get_site_release_output_directory).returns('site_path/release')
|
179
179
|
|
180
180
|
http_server_mock = mock('webric_httpserver')
|
181
181
|
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
@@ -189,7 +189,7 @@ class TestServer < Geb::ApiTest
|
|
189
189
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
190
190
|
Listen.stubs(:to).returns(file_watcher_mock)
|
191
191
|
|
192
|
-
server = Geb::Server.new(site_mock, 3456, false)
|
192
|
+
server = Geb::Server.new(site_mock, 3456, false, false)
|
193
193
|
|
194
194
|
server.start
|
195
195
|
|
@@ -212,8 +212,8 @@ class TestServer < Geb::ApiTest
|
|
212
212
|
|
213
213
|
site_mock = mock('site')
|
214
214
|
site_mock.stubs(:site_path).returns(dir)
|
215
|
-
site_mock.stubs(:
|
216
|
-
site_mock.stubs(:
|
215
|
+
site_mock.stubs(:get_site_local_output_directory).returns(dir)
|
216
|
+
site_mock.stubs(:get_site_release_output_directory).returns(dir)
|
217
217
|
http_server_mock = mock('webric_httpserver')
|
218
218
|
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
219
219
|
file_watcher_mock = mock('file_watcher')
|
@@ -222,7 +222,7 @@ class TestServer < Geb::ApiTest
|
|
222
222
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
223
223
|
Listen.stubs(:to).returns(file_watcher_mock)
|
224
224
|
|
225
|
-
geb_server = Geb::Server.new(site_mock, port, true)
|
225
|
+
geb_server = Geb::Server.new(site_mock, port, true, false)
|
226
226
|
|
227
227
|
WEBrick::HTTPServer.unstub(:new)
|
228
228
|
|
@@ -253,8 +253,8 @@ class TestServer < Geb::ApiTest
|
|
253
253
|
|
254
254
|
site_mock = mock('site')
|
255
255
|
site_mock.stubs(:site_path).returns(dir)
|
256
|
-
site_mock.stubs(:
|
257
|
-
site_mock.stubs(:
|
256
|
+
site_mock.stubs(:get_site_local_output_directory).returns(dir)
|
257
|
+
site_mock.stubs(:get_site_release_output_directory).returns(dir)
|
258
258
|
http_server_mock = mock('webric_httpserver')
|
259
259
|
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
260
260
|
file_watcher_mock = mock('file_watcher')
|
@@ -263,7 +263,7 @@ class TestServer < Geb::ApiTest
|
|
263
263
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
264
264
|
Listen.stubs(:to).returns(file_watcher_mock)
|
265
265
|
|
266
|
-
geb_server = Geb::Server.new(site_mock, 8888, true)
|
266
|
+
geb_server = Geb::Server.new(site_mock, 8888, true, false)
|
267
267
|
|
268
268
|
Listen.unstub(:to)
|
269
269
|
file_watcher = geb_server.send(:get_file_watcher)
|
@@ -302,8 +302,8 @@ class TestServer < Geb::ApiTest
|
|
302
302
|
|
303
303
|
site_mock = mock('site')
|
304
304
|
site_mock.stubs(:site_path).returns(site_dir)
|
305
|
-
site_mock.stubs(:
|
306
|
-
site_mock.stubs(:
|
305
|
+
site_mock.stubs(:get_site_local_output_directory).returns(site_output_directory)
|
306
|
+
site_mock.stubs(:get_site_release_output_directory).returns(site_release_directory)
|
307
307
|
site_mock.expects(:build).times(1)
|
308
308
|
|
309
309
|
http_server_mock = mock('webric_httpserver')
|
@@ -314,15 +314,13 @@ class TestServer < Geb::ApiTest
|
|
314
314
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
315
315
|
Listen.stubs(:to).returns(file_watcher_mock)
|
316
316
|
|
317
|
-
geb_server = Geb::Server.new(site_mock, 8888, true)
|
317
|
+
geb_server = Geb::Server.new(site_mock, 8888, true, false)
|
318
318
|
|
319
319
|
Listen.unstub(:to)
|
320
320
|
|
321
321
|
log_output = ""
|
322
322
|
Geb.stubs(:log_start) { |*args| log_output << args.first }
|
323
323
|
Geb.stubs(:log) { |*args| log_output << args.first }
|
324
|
-
|
325
|
-
# initialize a sequence
|
326
324
|
Geb.expects(:log_start).times(1).with("Found changes, rebuilding site ... ")
|
327
325
|
Geb.expects(:log).times(4)
|
328
326
|
|
@@ -346,6 +344,72 @@ class TestServer < Geb::ApiTest
|
|
346
344
|
end # test "that the server detects file changes and rebuilds the site"
|
347
345
|
|
348
346
|
|
347
|
+
test "that the server detects file changes and rebuilds the site with debug set" do
|
348
|
+
|
349
|
+
# create a temporary directory
|
350
|
+
Dir.mktmpdir do |dir|
|
351
|
+
|
352
|
+
site_dir = File.join(dir, 'newsite')
|
353
|
+
site_output_directory = File.join(site_dir, 'output/local')
|
354
|
+
site_release_directory = File.join(site_dir, 'output/release')
|
355
|
+
|
356
|
+
file_path_add = File.join(site_dir, 'add.html')
|
357
|
+
file_path_modify = File.join(site_dir, 'modify.html')
|
358
|
+
file_path_delete = File.join(site_dir, 'delete.html')
|
359
|
+
|
360
|
+
FileUtils.mkdir_p(site_dir)
|
361
|
+
FileUtils.mkdir_p(site_output_directory)
|
362
|
+
FileUtils.mkdir_p(site_release_directory)
|
363
|
+
|
364
|
+
FileUtils.touch(file_path_modify)
|
365
|
+
File.write(file_path_modify, 'modify file original content')
|
366
|
+
FileUtils.touch(file_path_delete)
|
367
|
+
File.write(file_path_delete, 'delete file content')
|
368
|
+
|
369
|
+
site_mock = mock('site')
|
370
|
+
site_mock.stubs(:site_path).returns(site_dir)
|
371
|
+
site_mock.stubs(:get_site_local_output_directory).returns(site_output_directory)
|
372
|
+
site_mock.stubs(:get_site_release_output_directory).returns(site_release_directory)
|
373
|
+
site_mock.expects(:build).times(1)
|
374
|
+
|
375
|
+
http_server_mock = mock('webric_httpserver')
|
376
|
+
http_server_mock.stubs(:config).returns({:Port => 3456, :DocumentRoot => 'site_path/output'})
|
377
|
+
file_watcher_mock = mock('file_watcher')
|
378
|
+
file_watcher_mock.stubs(:ignore)
|
379
|
+
|
380
|
+
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
381
|
+
Listen.stubs(:to).returns(file_watcher_mock)
|
382
|
+
|
383
|
+
geb_server = Geb::Server.new(site_mock, 8888, true, true)
|
384
|
+
|
385
|
+
Listen.unstub(:to)
|
386
|
+
|
387
|
+
log_output = ""
|
388
|
+
Geb.stubs(:log_start) { |*args| log_output << args.first }
|
389
|
+
Geb.stubs(:log) { |*args| log_output << args.first }
|
390
|
+
Geb.expects(:log_start).times(1).with("Found changes, rebuilding site ... ")
|
391
|
+
Geb.expects(:log).times(4)
|
392
|
+
|
393
|
+
file_watcher = geb_server.send(:get_file_watcher)
|
394
|
+
|
395
|
+
file_watcher.start
|
396
|
+
|
397
|
+
sleep 0.5
|
398
|
+
|
399
|
+
FileUtils.touch(file_path_add)
|
400
|
+
File.write(file_path_add, 'add file content')
|
401
|
+
File.write(file_path_modify, 'modify file modified content')
|
402
|
+
FileUtils.rm(file_path_delete)
|
403
|
+
|
404
|
+
sleep 0.5
|
405
|
+
|
406
|
+
file_watcher.stop
|
407
|
+
|
408
|
+
end # Dir.mktmpdir
|
409
|
+
|
410
|
+
end # test "that the server detects file changes and rebuilds the site with debug set"
|
411
|
+
|
412
|
+
|
349
413
|
test "that the server detects file changes handles exception is build fails" do
|
350
414
|
|
351
415
|
# create a temporary directory
|
@@ -370,8 +434,8 @@ class TestServer < Geb::ApiTest
|
|
370
434
|
|
371
435
|
site_mock = mock('site')
|
372
436
|
site_mock.stubs(:site_path).returns(site_dir)
|
373
|
-
site_mock.stubs(:
|
374
|
-
site_mock.stubs(:
|
437
|
+
site_mock.stubs(:get_site_local_output_directory).returns(site_output_directory)
|
438
|
+
site_mock.stubs(:get_site_release_output_directory).returns(site_release_directory)
|
375
439
|
site_mock.expects(:build).raises(Geb::Error, "Build failed")
|
376
440
|
|
377
441
|
http_server_mock = mock('webric_httpserver')
|
@@ -382,7 +446,7 @@ class TestServer < Geb::ApiTest
|
|
382
446
|
WEBrick::HTTPServer.stubs(:new).returns(http_server_mock)
|
383
447
|
Listen.stubs(:to).returns(file_watcher_mock)
|
384
448
|
|
385
|
-
geb_server = Geb::Server.new(site_mock, 8888, true)
|
449
|
+
geb_server = Geb::Server.new(site_mock, 8888, true, false)
|
386
450
|
|
387
451
|
Listen.unstub(:to)
|
388
452
|
|
data/test/api tests/test_site.rb
CHANGED
@@ -629,6 +629,55 @@ class SiteTest < Geb::ApiTest
|
|
629
629
|
|
630
630
|
end # test "that the build pages method throws an exception if the page output throws an exception"
|
631
631
|
|
632
|
+
test "that the build pages methods builds pages with custom page extensions" do
|
633
|
+
|
634
|
+
site = Geb::Site.new
|
635
|
+
test_site_path = "test/site"
|
636
|
+
|
637
|
+
Dir.mktmpdir do |temp_dir|
|
638
|
+
|
639
|
+
site_path = File.join(temp_dir, test_site_path)
|
640
|
+
|
641
|
+
site_pages = []
|
642
|
+
site_pages << File.join(site_path, "index.html")
|
643
|
+
site_pages << File.join(site_path, "about.htm")
|
644
|
+
site_pages << File.join(site_path, "contact.html")
|
645
|
+
site_pages << File.join(site_path, "sub/page.html")
|
646
|
+
site_pages << File.join(site_path, "sub/sub/page.htm")
|
647
|
+
site_pages << File.join(site_path, "assets/styles/foo.css")
|
648
|
+
site_pages.sort!
|
649
|
+
|
650
|
+
FileUtils.mkdir_p(site_path)
|
651
|
+
|
652
|
+
site_pages.each do |page|
|
653
|
+
FileUtils.mkdir_p(File.dirname(page))
|
654
|
+
FileUtils.touch(page)
|
655
|
+
end
|
656
|
+
|
657
|
+
config = mock('config')
|
658
|
+
config.stubs(:site_name).returns("site")
|
659
|
+
config.stubs(:output_dir).returns("output")
|
660
|
+
config.stubs(:page_extensions).returns([".htm", ".css"])
|
661
|
+
config.stubs(:template_and_partial_identifier).returns(Geb::Defaults::TEMPLATE_AND_PARTIAL_IDENTIFIER)
|
662
|
+
|
663
|
+
page_mock = mock('page')
|
664
|
+
page_mock.expects(:build).times(3)
|
665
|
+
Geb::Page.expects(:new).returns(page_mock).with(site, File.join(site_path, "about.htm")).once
|
666
|
+
Geb::Page.expects(:new).returns(page_mock).with(site, File.join(site_path, "sub/sub/page.htm")).once
|
667
|
+
Geb::Page.expects(:new).returns(page_mock).with(site, File.join(site_path, "assets/styles/foo.css")).once
|
668
|
+
|
669
|
+
site.instance_variable_set(:@loaded, true)
|
670
|
+
site.instance_variable_set(:@site_path, site_path)
|
671
|
+
site.instance_variable_set(:@site_config, config)
|
672
|
+
site.expects(:clear_site_output_directory).once
|
673
|
+
site.expects(:output_site).once
|
674
|
+
|
675
|
+
site.build_pages
|
676
|
+
|
677
|
+
end # Dir.mktmpdir
|
678
|
+
|
679
|
+
end # test "that the build pages methods builds pages with custom page extensions"
|
680
|
+
|
632
681
|
test "that get page files method returns a list of page files using defaults" do
|
633
682
|
|
634
683
|
site = Geb::Site.new
|
@@ -661,11 +710,10 @@ class SiteTest < Geb::ApiTest
|
|
661
710
|
|
662
711
|
end # test "that get page files method returns a list of page files using defaults"
|
663
712
|
|
664
|
-
test "that get page files method returns a list of page files using custom page
|
713
|
+
test "that get page files method returns a list of page files using custom page extensions" do
|
665
714
|
|
666
715
|
site = Geb::Site.new
|
667
716
|
test_site_path = "test/site"
|
668
|
-
test_page_extension = [".htm"]
|
669
717
|
|
670
718
|
Dir.mktmpdir do |temp_dir|
|
671
719
|
|
@@ -675,6 +723,7 @@ class SiteTest < Geb::ApiTest
|
|
675
723
|
site_pages << File.join(site_path, "index.htm")
|
676
724
|
site_pages << File.join(site_path, "about.html")
|
677
725
|
site_pages << File.join(site_path, "contact.htm")
|
726
|
+
site_pages << File.join(site_path, "styles/test.css")
|
678
727
|
site_pages << File.join(site_path, "sub/page.htm")
|
679
728
|
site_pages << File.join(site_path, "sub/sub/page.html")
|
680
729
|
site_pages.sort!
|
@@ -686,13 +735,39 @@ class SiteTest < Geb::ApiTest
|
|
686
735
|
FileUtils.touch(page)
|
687
736
|
end
|
688
737
|
|
689
|
-
pages = site.
|
738
|
+
pages = site.get_page_files(site_path, [".htm"])
|
739
|
+
|
740
|
+
assert_equal 3, pages.length
|
741
|
+
assert_includes pages, File.join(site_path, "index.htm")
|
742
|
+
refute_includes pages, File.join(site_path, "about.html")
|
743
|
+
assert_includes pages, File.join(site_path, "contact.htm")
|
744
|
+
refute_includes pages, File.join(site_path, "styles/test.css")
|
745
|
+
assert_includes pages, File.join(site_path, "sub/page.htm")
|
746
|
+
refute_includes pages, File.join(site_path, "sub/sub/page.html")
|
747
|
+
|
748
|
+
pages = site.get_page_files(site_path, [".htm", ".css"])
|
749
|
+
|
750
|
+
assert_equal 4, pages.length
|
751
|
+
assert_includes pages, File.join(site_path, "index.htm")
|
752
|
+
refute_includes pages, File.join(site_path, "about.html")
|
753
|
+
assert_includes pages, File.join(site_path, "contact.htm")
|
754
|
+
assert_includes pages, File.join(site_path, "styles/test.css")
|
755
|
+
assert_includes pages, File.join(site_path, "sub/page.htm")
|
756
|
+
refute_includes pages, File.join(site_path, "sub/sub/page.html")
|
757
|
+
|
758
|
+
pages = site.get_page_files(site_path, [".htm", "css"])
|
690
759
|
|
691
|
-
assert_equal
|
760
|
+
assert_equal 4, pages.length
|
761
|
+
assert_includes pages, File.join(site_path, "index.htm")
|
762
|
+
refute_includes pages, File.join(site_path, "about.html")
|
763
|
+
assert_includes pages, File.join(site_path, "contact.htm")
|
764
|
+
assert_includes pages, File.join(site_path, "styles/test.css")
|
765
|
+
assert_includes pages, File.join(site_path, "sub/page.htm")
|
766
|
+
refute_includes pages, File.join(site_path, "sub/sub/page.html")
|
692
767
|
|
693
768
|
end # Dir.mktmpdir
|
694
769
|
|
695
|
-
end # test "that get page files method returns a list of page files using custom page
|
770
|
+
end # test "that get page files method returns a list of page files using custom page extensions"
|
696
771
|
|
697
772
|
test "that the get page files method returns a list of page files while ignoring files with ignore pattern" do
|
698
773
|
|
@@ -788,7 +863,7 @@ class SiteTest < Geb::ApiTest
|
|
788
863
|
site.instance_variable_set(:@site_path, site_path)
|
789
864
|
site.instance_variable_set(:@site_config, config)
|
790
865
|
|
791
|
-
site.
|
866
|
+
site.clear_site_output_directory(site.get_site_local_output_directory())
|
792
867
|
|
793
868
|
# check to make sure all the files and directories are gone
|
794
869
|
refute Dir.exist?(File.join(site_path, Geb::Defaults::OUTPUT_DIR, Geb::Defaults::LOCAL_OUTPUT_DIR, "sub"))
|
@@ -798,7 +873,7 @@ class SiteTest < Geb::ApiTest
|
|
798
873
|
|
799
874
|
end # test "that the clear site output directory method clears the output directory"
|
800
875
|
|
801
|
-
test "that the output site method
|
876
|
+
test "that the output site method files from one directory to another" do
|
802
877
|
|
803
878
|
site = Geb::Site.new
|
804
879
|
test_site_path = "test/site"
|
@@ -822,7 +897,7 @@ class SiteTest < Geb::ApiTest
|
|
822
897
|
site.instance_variable_set(:@site_path, site_path)
|
823
898
|
site.instance_variable_set(:@site_config, config)
|
824
899
|
|
825
|
-
site.
|
900
|
+
site.output_site(very_temp_dir, site.get_site_local_output_directory())
|
826
901
|
|
827
902
|
# check to make sure all the files and directories are gone
|
828
903
|
assert Dir.exist?(File.join(site_path, Geb::Defaults::OUTPUT_DIR, Geb::Defaults::LOCAL_OUTPUT_DIR, "sub"))
|
@@ -830,24 +905,22 @@ class SiteTest < Geb::ApiTest
|
|
830
905
|
|
831
906
|
end # Dir.mktmpdir
|
832
907
|
|
833
|
-
end # test "that the output site method
|
908
|
+
end # test "that the output site method files from one directory to another"
|
834
909
|
|
835
910
|
test "that the release method executes the site build first" do
|
836
911
|
|
837
912
|
site = Geb::Site.new
|
838
913
|
test_site_path = "test/site"
|
839
|
-
test_site_release_dir = File.join(test_site_path, Geb::Defaults::OUTPUT_DIR, Geb::Defaults::RELEASE_OUTPUT_DIR)
|
840
914
|
|
841
|
-
|
842
|
-
site.expects(:build).once.in_sequence(execution_sequence)
|
843
|
-
site.expects(:get_site_release_directory).returns(test_site_release_dir).once.in_sequence(execution_sequence)
|
844
|
-
site.expects(:clear_site_release_directory).once.in_sequence(execution_sequence)
|
845
|
-
site.expects(:copy_site_to_release_directory).once.in_sequence(execution_sequence)
|
915
|
+
site.expects(:build).once
|
846
916
|
|
847
917
|
site.instance_variable_set(:@site_path, test_site_path)
|
918
|
+
site.instance_variable_set(:@loaded, true)
|
848
919
|
|
849
920
|
site.release
|
850
921
|
|
922
|
+
# TODO: More...
|
923
|
+
|
851
924
|
end # test "that the release method executes the site build first"
|
852
925
|
|
853
926
|
test "that the site release directory is correctly generated" do
|
@@ -860,33 +933,59 @@ class SiteTest < Geb::ApiTest
|
|
860
933
|
site.instance_variable_set(:@site_path, test_site_path)
|
861
934
|
site.instance_variable_set(:@site_config, config)
|
862
935
|
|
863
|
-
site_release_directory = site.
|
936
|
+
site_release_directory = site.get_site_release_output_directory()
|
864
937
|
|
865
938
|
assert_equal File.join(test_site_path, Geb::Defaults::OUTPUT_DIR, Geb::Defaults::RELEASE_OUTPUT_DIR), site_release_directory
|
866
939
|
|
867
940
|
end # test "that the site release directory is correctly generated"
|
868
941
|
|
869
|
-
test "that the site release
|
942
|
+
test "that the site release sets and resets the releasing flag correctly" do
|
870
943
|
|
871
944
|
site = Geb::Site.new
|
872
945
|
test_site_path = "test/site"
|
873
|
-
test_site_output_dir = File.join(test_site_path, Geb::Defaults::OUTPUT_DIR, Geb::Defaults::LOCAL_OUTPUT_DIR)
|
874
|
-
test_site_release_dir = File.join(test_site_path, Geb::Defaults::OUTPUT_DIR, Geb::Defaults::RELEASE_OUTPUT_DIR)
|
875
946
|
|
876
|
-
execution_sequence = sequence('execution_sequence')
|
877
947
|
site.expects(:build).once
|
878
|
-
site.stubs(:get_site_release_directory).returns(test_site_release_dir)
|
879
|
-
FileUtils.expects(:rm_rf).with(Dir.glob("#{test_site_release_dir}/*")).once.in_sequence(execution_sequence)
|
880
|
-
FileUtils.expects(:cp_r).with("#{test_site_output_dir}/.", test_site_release_dir).once.in_sequence(execution_sequence)
|
881
|
-
|
882
|
-
config = mock('config')
|
883
|
-
config.stubs(:output_dir).returns("output")
|
884
948
|
site.instance_variable_set(:@site_path, test_site_path)
|
885
|
-
site.instance_variable_set(:@
|
949
|
+
site.instance_variable_set(:@loaded, true)
|
950
|
+
site.instance_variable_set(:@releasing, false)
|
886
951
|
|
887
952
|
site.release
|
888
953
|
|
889
|
-
|
954
|
+
refute site.releasing
|
955
|
+
|
956
|
+
end # test "that the site release sets and resets the releasing flag correctly"
|
957
|
+
|
958
|
+
test "that the site release handles site not being loaded" do
|
959
|
+
|
960
|
+
site = Geb::Site.new
|
961
|
+
test_site_path = "test/site"
|
962
|
+
|
963
|
+
site.instance_variable_set(:@site_path, test_site_path)
|
964
|
+
site.instance_variable_set(:@loaded, false)
|
965
|
+
site.instance_variable_set(:@releasing, false)
|
966
|
+
|
967
|
+
error = assert_raises Geb::Site::SiteNotLoadedError do
|
968
|
+
site.release
|
969
|
+
end
|
970
|
+
|
971
|
+
assert_includes error.message, "Could not release the site"
|
972
|
+
|
973
|
+
end # test "that the site release handles site not being loaded"
|
974
|
+
|
975
|
+
test "that the site release handles release flag already set" do
|
976
|
+
|
977
|
+
site = Geb::Site.new
|
978
|
+
test_site_path = "test/site"
|
979
|
+
|
980
|
+
site.instance_variable_set(:@site_path, test_site_path)
|
981
|
+
site.instance_variable_set(:@loaded, true)
|
982
|
+
site.instance_variable_set(:@releasing, true)
|
983
|
+
|
984
|
+
assert_raises Geb::Site::SiteReleasingError do
|
985
|
+
site.release
|
986
|
+
end
|
987
|
+
|
988
|
+
end # test "that the site release handles release flag already set"
|
890
989
|
|
891
990
|
test "that site bundle template method executes as expected" do
|
892
991
|
|
@@ -899,6 +998,7 @@ class SiteTest < Geb::ApiTest
|
|
899
998
|
config = mock('config')
|
900
999
|
config.stubs(:template_paths).returns(template_paths_config)
|
901
1000
|
config.stubs(:output_dir).returns(Geb::Defaults::OUTPUT_DIR)
|
1001
|
+
config.stubs(:generate_config_file)
|
902
1002
|
site.instance_variable_set(:@site_path, test_site_path)
|
903
1003
|
site.instance_variable_set(:@loaded, true)
|
904
1004
|
site.instance_variable_set(:@site_config, config)
|
@@ -1253,7 +1353,7 @@ class SiteTest < Geb::ApiTest
|
|
1253
1353
|
|
1254
1354
|
FileUtils.touch(File.join(site_release_path, "dummy_file.html"))
|
1255
1355
|
|
1256
|
-
assert_equal site_release_path, site.
|
1356
|
+
assert_equal site_release_path, site.get_site_release_output_directory()
|
1257
1357
|
|
1258
1358
|
assert site.released?
|
1259
1359
|
|
@@ -1278,7 +1378,7 @@ class SiteTest < Geb::ApiTest
|
|
1278
1378
|
|
1279
1379
|
FileUtils.mkdir_p(site_path)
|
1280
1380
|
|
1281
|
-
assert_equal site_release_path, site.
|
1381
|
+
assert_equal site_release_path, site.get_site_release_output_directory()
|
1282
1382
|
|
1283
1383
|
refute site.released?
|
1284
1384
|
|
@@ -1304,7 +1404,7 @@ class SiteTest < Geb::ApiTest
|
|
1304
1404
|
FileUtils.mkdir_p(site_path)
|
1305
1405
|
FileUtils.mkdir_p(site_release_path)
|
1306
1406
|
|
1307
|
-
assert_equal site_release_path, site.
|
1407
|
+
assert_equal site_release_path, site.get_site_release_output_directory()
|
1308
1408
|
|
1309
1409
|
refute site.released?
|
1310
1410
|
|
@@ -183,7 +183,7 @@ class TestGebCommandBuild < Geb::CliTest
|
|
183
183
|
|
184
184
|
assert_includes stdout, "Loading site from path #{Dir.pwd} ... done."
|
185
185
|
assert_includes stdout, "Found geb site at path #{Dir.pwd}"
|
186
|
-
assert_match(/Building \d
|
186
|
+
assert_match(/Building \d*.* pages locally/, stdout)
|
187
187
|
assert_includes stdout, "loading page"
|
188
188
|
assert_includes stdout, "loading template"
|
189
189
|
assert_includes stdout, "loading partial"
|
@@ -191,7 +191,7 @@ class TestGebCommandBuild < Geb::CliTest
|
|
191
191
|
assert_match(/Done building \d* pages for/, stdout)
|
192
192
|
assert_includes stdout, "Clearing site output folder"
|
193
193
|
assert_includes stdout, "Outputting site to"
|
194
|
-
|
194
|
+
assert_match(/Building .* assets locally/, stdout)
|
195
195
|
assert_includes stdout, "Done building assets for"
|
196
196
|
|
197
197
|
end # test "that the command actually builds the site"
|
@@ -111,7 +111,7 @@ class TestGebCommandRelease < Geb::CliTest
|
|
111
111
|
|
112
112
|
assert_includes stdout, "Loading site from path #{Dir.pwd} ... done."
|
113
113
|
assert_includes stdout, "Found geb site at path #{Dir.pwd}"
|
114
|
-
assert_match(/Building \d
|
114
|
+
assert_match(/Building \d*.* pages for release/, stdout)
|
115
115
|
assert_includes stdout, "loading page"
|
116
116
|
assert_includes stdout, "loading template"
|
117
117
|
assert_includes stdout, "loading partial"
|
@@ -119,10 +119,8 @@ class TestGebCommandRelease < Geb::CliTest
|
|
119
119
|
assert_match(/Done building \d* pages for/, stdout)
|
120
120
|
assert_includes stdout, "Clearing site output folder"
|
121
121
|
assert_match(/Outputting site to.*done/, stdout)
|
122
|
-
|
122
|
+
assert_match(/Building .* assets for release/, stdout)
|
123
123
|
assert_includes stdout, "Done building assets for"
|
124
|
-
assert_match(/Clearing site release folder.*done/, stdout)
|
125
|
-
assert_match(/Releasing site to.*done/, stdout)
|
126
124
|
refute_match(/Resolving directories and files to include in the template archive.*done/, stdout)
|
127
125
|
refute_match(/Creating template archive in.*done/, stdout)
|
128
126
|
|
@@ -141,7 +139,7 @@ class TestGebCommandRelease < Geb::CliTest
|
|
141
139
|
|
142
140
|
assert_includes stdout, "Loading site from path #{Dir.pwd} ... done."
|
143
141
|
assert_includes stdout, "Found geb site at path #{Dir.pwd}"
|
144
|
-
assert_match(/Building \d
|
142
|
+
assert_match(/Building \d*.* pages for release/, stdout)
|
145
143
|
assert_includes stdout, "loading page"
|
146
144
|
assert_includes stdout, "loading template"
|
147
145
|
assert_includes stdout, "loading partial"
|
@@ -149,13 +147,13 @@ class TestGebCommandRelease < Geb::CliTest
|
|
149
147
|
assert_match(/Done building \d* pages for/, stdout)
|
150
148
|
assert_includes stdout, "Clearing site output folder"
|
151
149
|
assert_match(/Outputting site to.*done/, stdout)
|
152
|
-
|
150
|
+
assert_match(/Building .* assets for release/, stdout)
|
153
151
|
assert_includes stdout, "Done building assets for"
|
154
|
-
assert_match(/Clearing site
|
155
|
-
assert_match(/Releasing site to.*done/, stdout)
|
152
|
+
assert_match(/Clearing site output folder.*done/, stdout)
|
156
153
|
assert_match(/Resolving directories and files to include in the template archive.*done/, stdout)
|
157
154
|
assert_match(/copying directory and all sub-directories from.*to.*done/, stdout)
|
158
155
|
assert_match(/copying file from.*to.*done/, stdout)
|
156
|
+
assert_match(/Generating geb\.config\.yml in the template archive directory.*done/, stdout)
|
159
157
|
assert_includes stdout, "Done copying directories and files to the template archive directory."
|
160
158
|
assert_match(/Creating template archive in.*done/, stdout)
|
161
159
|
|
@@ -100,6 +100,27 @@ class TestGebCommandServer < Geb::CliTest
|
|
100
100
|
|
101
101
|
end # test "that command default executes"
|
102
102
|
|
103
|
+
test "that command default executes with debug option set to true" do
|
104
|
+
|
105
|
+
copy_test_site()
|
106
|
+
server_port = Geb::Test::WebServerProxy.find_available_port()
|
107
|
+
geb_command = "geb server --port #{server_port} --debug"
|
108
|
+
|
109
|
+
server_up = lambda do |output, error_output|
|
110
|
+
output.include?("Server running on http://localhost:#{server_port}")
|
111
|
+
end
|
112
|
+
|
113
|
+
run_command_with_timeout(geb_command, break_condition: server_up) do |output, error_output|
|
114
|
+
|
115
|
+
assert_includes output, "Loading site from path #{Dir.pwd}"
|
116
|
+
assert_includes output, "Server running on http://localhost:#{server_port}"
|
117
|
+
assert_includes output, "Watching for changes in [#{Dir.pwd}]"
|
118
|
+
assert_match(/Building .* pages locally/, output)
|
119
|
+
|
120
|
+
end # run_command_with_timeout
|
121
|
+
|
122
|
+
end # test "that command default executes"
|
123
|
+
|
103
124
|
test "that command handles being executed in a non-site directory" do
|
104
125
|
|
105
126
|
# create a temporary directory
|