Sha256: 199c83d8fa3a4d9931cd27b60244e9d1e5526cd51f1154eb7cdb3ba5f799c65f

Contents?: true

Size: 1.73 KB

Versions: 15

Compression:

Stored size: 1.73 KB

Contents

# encoding: utf-8

class Nanoc::FilterTest < Nanoc::TestCase

  def test_initialize
    # Create filter
    filter = Nanoc::Filter.new

    # Test assigns
    assert_equal({}, filter.instance_eval { @assigns })
  end

  def test_assigns
    # Create filter
    filter = Nanoc::Filter.new({ :foo => 'bar' })

    # Check assigns
    assert_equal('bar', filter.assigns[:foo])
  end

  def test_assigns_with_instance_variables
    # Create filter
    filter = Nanoc::Filter.new({ :foo => 'bar' })

    # Check assigns
    assert_equal('bar', filter.instance_eval { @foo })
  end

  def test_assigns_with_instance_methods
    # Create filter
    filter = Nanoc::Filter.new({ :foo => 'bar' })

    # Check assigns
    assert_equal('bar', filter.instance_eval { foo })
  end

  def test_run
    # Create filter
    filter = Nanoc::Filter.new

    # Make sure an error is raised
    assert_raises(NotImplementedError) do
      filter.run(nil)
    end
  end

  def test_filename_item
    # Mock items
    item = mock
    item.expects(:identifier).returns('/foo/bar/baz/')
    item_rep = mock
    item_rep.expects(:name).returns(:quux)

    # Create filter
    filter = Nanoc::Filter.new({ :item => item, :item_rep => item_rep })

    # Check filename
    assert_equal('item /foo/bar/baz/ (rep quux)', filter.filename)
  end

  def test_filename_layout
    # Mock items
    layout = mock
    layout.expects(:identifier).returns('/wohba/')

    # Create filter
    filter = Nanoc::Filter.new({ :item => mock, :item_rep => mock, :layout => layout })

    # Check filename
    assert_equal('layout /wohba/', filter.filename)
  end

  def test_filename_unknown
    # Create filter
    filter = Nanoc::Filter.new({})

    # Check filename
    assert_equal('?', filter.filename)
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

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