Sha256: 45aa868e937c64c5ed32de44053b0e80d72e82d513548b3cbd8345cf4b55bff4

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

# encoding: utf-8

class Nanoc::DataSourceTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  def test_loading
    # Create data source
    data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
    data_source.expects(:up).times(1)
    data_source.expects(:down).times(1)

    # Test nested loading
    assert_equal(0, data_source.instance_eval { @references })
    data_source.loading do
      assert_equal(1, data_source.instance_eval { @references })
      data_source.loading do
        assert_equal(2, data_source.instance_eval { @references })
      end
      assert_equal(1, data_source.instance_eval { @references })
    end
    assert_equal(0, data_source.instance_eval { @references })
  end

  def test_not_implemented
    # Create data source
    data_source = Nanoc::DataSource.new(nil, nil, nil, nil)

    # Test optional methods
    data_source.up
    data_source.down
    data_source.update

    # Test required methods - general
    assert_raises(NotImplementedError) { data_source.setup }

    # Test methods - loading data
    assert_equal [],  data_source.items
    assert_equal [],  data_source.layouts

    # Test required method - creating data
    assert_raises(NotImplementedError) { data_source.create_item(nil, nil, nil) }
    assert_raises(NotImplementedError) { data_source.create_layout(nil, nil, nil) }
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
nanoc-3.6.1 test/base/test_data_source.rb
nanoc-3.6.0 test/base/test_data_source.rb
nanoc-3.5.0 test/base/test_data_source.rb
nanoc-3.5.0b2 test/base/test_data_source.rb
nanoc-3.5.0b1 test/base/test_data_source.rb
nanoc-3.4.3 test/base/test_data_source.rb
nanoc-3.4.2 test/base/test_data_source.rb
nanoc-3.4.1 test/base/test_data_source.rb
nanoc-3.4.0 test/base/test_data_source.rb
nanoc-3.3.7 test/base/test_data_source.rb
nanoc-3.3.6 test/base/test_data_source.rb
nanoc-3.3.5 test/base/test_data_source.rb
nanoc-3.3.4 test/base/test_data_source.rb
nanoc-3.3.3 test/base/test_data_source.rb
nanoc-3.3.2 test/base/test_data_source.rb
nanoc-3.3.1 test/base/test_data_source.rb
nanoc-3.3.0 test/base/test_data_source.rb