test/base/test_compiler.rb in nanoc-3.7.3 vs test/base/test_compiler.rb in nanoc-3.7.4

- old
+ new

@@ -2,11 +2,11 @@ class Nanoc::CompilerTest < Nanoc::TestCase def test_compilation_rule_for # Mock rules - rules = [ mock, mock, mock ] + rules = [mock, mock, mock] rules[0].expects(:applicable_to?).returns(false) rules[1].expects(:applicable_to?).returns(true) rules[1].expects(:rep_name).returns('wrong') rules[2].expects(:applicable_to?).returns(true) rules[2].expects(:rep_name).returns('right') @@ -25,11 +25,11 @@ assert_equal rules[2], compiler.rules_collection.compilation_rule_for(rep) end def test_routing_rule_for # Mock rules - rules = [ mock, mock, mock ] + rules = [mock, mock, mock] rules[0].expects(:applicable_to?).returns(false) rules[1].expects(:applicable_to?).returns(true) rules[1].expects(:rep_name).returns('wrong') rules[2].expects(:applicable_to?).returns(true) rules[2].expects(:rep_name).returns('right') @@ -52,43 +52,43 @@ # Mock site site = mock # Create compiler compiler = Nanoc::Compiler.new(site) - compiler.rules_collection.layout_filter_mapping[/.*/] = [ :erb, { :foo => 'bar' } ] + compiler.rules_collection.layout_filter_mapping[/.*/] = [:erb, { :foo => 'bar' }] # Mock layout layout = MiniTest::Mock.new layout.expect(:identifier, '/some_layout/') # Check - assert_equal([ :erb, { :foo => 'bar' } ], compiler.rules_collection.filter_for_layout(layout)) + assert_equal([:erb, { :foo => 'bar' }], compiler.rules_collection.filter_for_layout(layout)) end def test_filter_for_layout_with_existant_layout_and_unknown_filter # Mock site site = mock # Create compiler compiler = Nanoc::Compiler.new(site) - compiler.rules_collection.layout_filter_mapping[/.*/] = [ :some_unknown_filter, { :foo => 'bar' } ] + compiler.rules_collection.layout_filter_mapping[/.*/] = [:some_unknown_filter, { :foo => 'bar' }] # Mock layout layout = MiniTest::Mock.new layout.expect(:identifier, '/some_layout/') # Check - assert_equal([ :some_unknown_filter, { :foo => 'bar' } ], compiler.rules_collection.filter_for_layout(layout)) + assert_equal([:some_unknown_filter, { :foo => 'bar' }], compiler.rules_collection.filter_for_layout(layout)) end def test_filter_for_layout_with_nonexistant_layout # Mock site site = mock # Create compiler compiler = Nanoc::Compiler.new(site) - compiler.rules_collection.layout_filter_mapping[%r{^/foo/$}] = [ :erb, { :foo => 'bar' } ] + compiler.rules_collection.layout_filter_mapping[%r{^/foo/$}] = [:erb, { :foo => 'bar' }] # Mock layout layout = MiniTest::Mock.new layout.expect(:identifier, '/bar/') @@ -100,17 +100,17 @@ # Mock site site = mock # Create compiler compiler = Nanoc::Compiler.new(site) - compiler.rules_collection.layout_filter_mapping[%r{^/a/b/c/.*/$}] = [ :erb, { :char => 'd' } ] - compiler.rules_collection.layout_filter_mapping[%r{^/a/.*/$}] = [ :erb, { :char => 'b' } ] - compiler.rules_collection.layout_filter_mapping[%r{^/a/b/.*/$}] = [ :erb, { :char => 'c' } ] # never used! - compiler.rules_collection.layout_filter_mapping[%r{^/.*/$}] = [ :erb, { :char => 'a' } ] + compiler.rules_collection.layout_filter_mapping[%r{^/a/b/c/.*/$}] = [:erb, { :char => 'd' }] + compiler.rules_collection.layout_filter_mapping[%r{^/a/.*/$}] = [:erb, { :char => 'b' }] + compiler.rules_collection.layout_filter_mapping[%r{^/a/b/.*/$}] = [:erb, { :char => 'c' }] # never used! + compiler.rules_collection.layout_filter_mapping[%r{^/.*/$}] = [:erb, { :char => 'a' }] # Mock layout - layouts = [ mock, mock, mock, mock ] + layouts = [mock, mock, mock, mock] layouts[0].stubs(:identifier).returns('/a/b/c/d/') layouts[1].stubs(:identifier).returns('/a/b/c/') layouts[2].stubs(:identifier).returns('/a/b/') layouts[3].stubs(:identifier).returns('/a/') @@ -157,15 +157,15 @@ # Create site site = mock site.stubs(:config).returns({}) site.stubs(:items).returns([]) - site.stubs(:layouts).returns([ layout ]) + site.stubs(:layouts).returns([layout]) # Create compiler compiler = Nanoc::Compiler.new(site) compiler.rules_collection.expects(:compilation_rule_for).times(2).with(rep).returns(rule) - compiler.rules_collection.layout_filter_mapping[%r{^/blah/$}] = [ :erb, {} ] + compiler.rules_collection.layout_filter_mapping[%r{^/blah/$}] = [:erb, {}] site.stubs(:compiler).returns(compiler) # Compile compiler.send(:compile_rep, rep)