Skip to content

Commit

Permalink
Make the tests compatible with the newest Utils::LoatPaths API
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Jun 9, 2014
1 parent b2dfcdd commit d9e2f30
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
14 changes: 14 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
26 changes: 17 additions & 9 deletions test/view/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d9e2f30

Please sign in to comment.