From d9e2f30c3ea0cf95ee983b5c85bfd72727f2be97 Mon Sep 17 00:00:00 2001 From: Luca Guidi Date: Mon, 9 Jun 2014 10:59:22 +0200 Subject: [PATCH] Make the tests compatible with the newest Utils::LoatPaths API --- test/test_helper.rb | 14 ++++++++++++++ test/view/configuration_test.rb | 26 +++++++++++++++++--------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 266c2c5e..1dad6f59 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -27,6 +27,20 @@ require 'fixtures' Lotus::View.load! +Lotus::Utils::LoadPaths.class_eval do + def include?(object) + @paths.include?(object) + end + + def ==(other) + other.kind_of?(Lotus::Utils::LoadPaths) && + other.paths == self.paths + end + + protected + attr_reader :paths +end + Lotus::View::Configuration.class_eval do def ==(other) other.kind_of?(Lotus::View::Configuration) && diff --git a/test/view/configuration_test.rb b/test/view/configuration_test.rb index 348ca11c..35a985fe 100644 --- a/test/view/configuration_test.rb +++ b/test/view/configuration_test.rb @@ -63,7 +63,7 @@ def to_pathname describe 'by default' do it "it's equal to root" do - @configuration.load_paths.must_equal [@configuration.root] + @configuration.load_paths.must_include @configuration.root end end @@ -168,14 +168,22 @@ class LazyLayout @config.add_view(RenderView) @config.add_layout(GlobalLayout) - @config.root.must_equal Pathname.new('.').realpath - @config.load_paths.must_equal [@config.root, '..', '../..'] - @config.layout.must_equal GlobalLayout - @config.views.must_include RenderView - @config.layouts.must_include GlobalLayout + @config.root.must_equal Pathname.new('.').realpath + + @config.load_paths.must_include @config.root + @config.load_paths.must_include '..' + @config.load_paths.must_include '../..' + + @config.layout.must_equal GlobalLayout + @config.views.must_include RenderView + @config.layouts.must_include GlobalLayout @configuration.root.must_equal Pathname.new('test').realpath - @configuration.load_paths.must_equal [@config.root, '..'] + + @configuration.load_paths.must_include @config.root + @configuration.load_paths.must_include '..' + @configuration.load_paths.wont_include '../..' + @configuration.layout.must_equal ApplicationLayout @configuration.views.must_include HelloWorldView @@ -243,8 +251,8 @@ class MockView < MockLayout it 'resets root' do root = Pathname.new('.').realpath - @configuration.root.must_equal root - @configuration.load_paths.must_equal [root] + @configuration.root.must_equal root + @configuration.load_paths.must_include root @configuration.layout.must_equal Lotus::View::Rendering::NullLayout @configuration.views.must_be_empty @configuration.layouts.must_be_empty