test/extra/test_auto_compiler.rb in nanoc-3.7.4 vs test/extra/test_auto_compiler.rb in nanoc-3.7.5
- old
+ new
@@ -1,9 +1,8 @@
# encoding: utf-8
class Nanoc::Extra::AutoCompilerTest < Nanoc::TestCase
-
def test_handle_request_with_item_rep_with_index_filename
if_have 'mime/types', 'rack' do
# Create site
Nanoc::CLI.run %w( create_site bar)
@@ -75,17 +74,21 @@
file_server = mock
def file_server.call(env)
@expected_path_info = 'somefile.txt'
@actual_path_info = env['PATH_INFO']
end
- def file_server.expected_path_info; @expected_path_info; end
- def file_server.actual_path_info; @actual_path_info; end
+ def file_server.expected_path_info
+ @expected_path_info
+ end
+ def file_server.actual_path_info
+ @actual_path_info
+ end
# Create site
site = mock
site.expects(:items).returns([])
- site.expects(:config).returns({ :output_dir => 'out', :index_filenames => ['index.html'] })
+ site.expects(:config).returns({ output_dir: 'out', index_filenames: ['index.html'] })
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
@@ -109,17 +112,21 @@
file_server = mock
def file_server.call(env)
@expected_path_info = '/foo/bar/index.html'
@actual_path_info = env['PATH_INFO']
end
- def file_server.expected_path_info; @expected_path_info; end
- def file_server.actual_path_info; @actual_path_info; end
+ def file_server.expected_path_info
+ @expected_path_info
+ end
+ def file_server.actual_path_info
+ @actual_path_info
+ end
# Create site
site = mock
site.expects(:items).returns([])
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => ['index.html'] })
+ site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
@@ -143,17 +150,21 @@
file_server = mock
def file_server.call(env)
@expected_path_info = 'foo/bar/'
@actual_path_info = env['PATH_INFO']
end
- def file_server.expected_path_info; @expected_path_info; end
- def file_server.actual_path_info; @actual_path_info; end
+ def file_server.expected_path_info
+ @expected_path_info
+ end
+ def file_server.actual_path_info
+ @actual_path_info
+ end
# Create site
site = mock
site.expects(:items).returns([])
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => ['index.html'] })
+ site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
@@ -177,17 +188,21 @@
file_server = mock
def file_server.call(env)
@expected_path_info = 'foo/bar'
@actual_path_info = env['PATH_INFO']
end
- def file_server.expected_path_info; @expected_path_info; end
- def file_server.actual_path_info; @actual_path_info; end
+ def file_server.expected_path_info
+ @expected_path_info
+ end
+ def file_server.actual_path_info
+ @actual_path_info
+ end
# Create site
site = mock
site.expects(:items).returns([])
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => ['index.html'] })
+ site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
@@ -211,17 +226,21 @@
file_server = mock
def file_server.call(env)
@expected_path_info = 'foo/bar'
@actual_path_info = env['PATH_INFO']
end
- def file_server.expected_path_info; @expected_path_info; end
- def file_server.actual_path_info; @actual_path_info; end
+ def file_server.expected_path_info
+ @expected_path_info
+ end
+ def file_server.actual_path_info
+ @actual_path_info
+ end
# Create site
site = mock
site.expects(:items).returns([])
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => ['index.html'] })
+ site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
@@ -241,17 +260,21 @@
file_server = mock
def file_server.call(env)
@expected_path_info = 'four-oh-four.txt'
@actual_path_info = env['PATH_INFO']
end
- def file_server.expected_path_info; @expected_path_info; end
- def file_server.actual_path_info; @actual_path_info; end
+ def file_server.expected_path_info
+ @expected_path_info
+ end
+ def file_server.actual_path_info
+ @actual_path_info
+ end
# Create site
site = mock
site.expects(:items).returns([])
- site.expects(:config).at_least_once.returns({ :output_dir => 'out', :index_filenames => ['index.html'] })
+ site.expects(:config).at_least_once.returns({ output_dir: 'out', index_filenames: ['index.html'] })
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
@@ -368,26 +391,26 @@
# Set config to 1st value
File.open('nanoc.yaml', 'w') do |io|
io.write 'value: Foo'
end
- File.utime(Time.now+5, Time.now+5, 'nanoc.yaml')
+ File.utime(Time.now + 5, Time.now + 5, 'nanoc.yaml')
# Check
- status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
+ _status, _headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
body.each do |b|
assert_match(/The Grand Value of Configuration is Foo!/, b)
end
# Set config to 2nd value
File.open('nanoc.yaml', 'w') do |io|
io.write 'value: Bar'
end
- File.utime(Time.now+5, Time.now+5, 'nanoc.yaml')
+ File.utime(Time.now + 5, Time.now + 5, 'nanoc.yaml')
# Check
- status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
+ _status, _headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
body.each do |b|
assert_match(/The Grand Value of Configuration is Bar!/, b)
end
end
end
@@ -398,18 +421,17 @@
# Create autocompiler
autocompiler = Nanoc::Extra::AutoCompiler.new('.')
# Mock dependencies
site = mock
- site.stubs(:config).returns({ :output_dir => 'output/' })
+ site.stubs(:config).returns({ output_dir: 'output/' })
site.stubs(:items).returns([])
autocompiler.stubs(:build_site)
autocompiler.stubs(:site).returns(site)
# Test
result = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/%73oftware')
assert_equal 404, result[0]
assert_match("File not found: /software\n", result[2][0])
end
end
-
end