Sha256: a22f65cc688d4e94aa92b799310ec885c6296c19f4a880c6f7161bd163bb9fda

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

class Nanoc::Int::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::Int::Compiler.new(site)

    # Create context
    @rule_context = Nanoc::Int::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::Int::Compiler.new(site)

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-4.0.0b3 test/base/test_rule_context.rb