Sha256: 72ccebda5a153d35811b680da06c95f6cf241dcf7d1f335cd7ec77df7d4f10e6

Contents?: true

Size: 1.56 KB

Versions: 14

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8

class Nanoc::RuleContextTest < Nanoc::TestCase

  def test_objects
    # Mock everything
    config = mock
    items = mock
    layouts = mock
    site = mock
    site.stubs(:config).returns(config)
    site.stubs(:items).returns(items)
    site.stubs(:layouts).returns(layouts)
    item = mock
    item.stubs(:site).returns(site)
    rep = mock
    rep.stubs(:item).returns(item)
    compiler = Nanoc::Compiler.new(site)

    # Create context
    @rule_context = Nanoc::RuleContext.new(:rep => rep, :compiler => compiler)

    # Check
    assert_equal rep,     @rule_context.rep
    assert_equal item,    @rule_context.item
    assert_equal site,    @rule_context.site
    assert_equal config,  @rule_context.config
    assert_equal layouts, @rule_context.layouts
    assert_equal items,   @rule_context.items
  end

  def test_actions
    # Mock everything
    config = mock
    items = mock
    layouts = mock
    site = mock
    site.stubs(:config).returns(config)
    site.stubs(:items).returns(items)
    site.stubs(:layouts).returns(layouts)
    item = mock
    item.stubs(:site).returns(site)

    # Mock rep
    rep = mock
    rep.stubs(:item).returns(item)
    rep.expects(:filter).with(:foo, { :bar => 'baz' })
    rep.expects(:layout).with('foo')
    rep.expects(:snapshot).with('awesome')

    # Mock compiler
    compiler = Nanoc::Compiler.new(site)

    # Create context
    @rule_context = Nanoc::RuleContext.new(:rep => rep, :compiler => compiler)

    # Check
    rep.filter   :foo, :bar => 'baz'
    rep.layout   'foo'
    rep.snapshot 'awesome'
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
nanoc-3.7.3 test/base/test_rule_context.rb
nanoc-3.7.2 test/base/test_rule_context.rb
nanoc-3.7.1 test/base/test_rule_context.rb
nanoc-3.7.0 test/base/test_rule_context.rb
nanoc-3.6.11 test/base/test_rule_context.rb
nanoc-3.6.10 test/base/test_rule_context.rb
nanoc-3.6.9 test/base/test_rule_context.rb
nanoc-3.6.8 test/base/test_rule_context.rb
nanoc-3.6.7 test/base/test_rule_context.rb
nanoc-3.6.6 test/base/test_rule_context.rb
nanoc-3.6.5 test/base/test_rule_context.rb
nanoc-3.6.4 test/base/test_rule_context.rb
nanoc-3.6.3 test/base/test_rule_context.rb
nanoc-3.6.2 test/base/test_rule_context.rb