Sha256: c6a32238c628a5c09c10fe53143cb02e8cf7cde1fa4124f0c7ec39abea63dea0

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

# -*- encoding: utf-8 -*-

require 'minitest/autorun'
require 'webgen/item_tracker/node_meta_info'

class TestNodeMetaInfo < MiniTest::Unit::TestCase

  def setup
    @website = MiniTest::Mock.new
    @node = MiniTest::Mock.new
    @node.expect(:meta_info, {'key' => 'value'})
    @website.expect(:tree, {'alcn' => @node})
    @obj = Webgen::ItemTracker::NodeMetaInfo.new(@website)
  end

  def test_item_id
    assert_equal(['id', nil], @obj.item_id('id'))
    assert_equal(['id', 'key'], @obj.item_id('id', 'key'))
  end

  def test_item_data
    assert_equal({'key' => 'value'}, @obj.item_data('alcn'))
    refute_same(@node.meta_info, @obj.item_data('alcn'))
    assert_equal('value', @obj.item_data('alcn', 'key'))
    refute_same(@node.meta_info['key'], @obj.item_data('alcn', 'key'))
    @website.verify
    @node.verify
  end

  def test_item_changed?
    @node.expect(:nil?, false)
    assert(@obj.item_changed?(['unknown', nil], 'old'))
    assert(@obj.item_changed?(['alcn', nil], {"key" => 'value', 'other' => 'new'}))
    assert(@obj.item_changed?(['alcn', 'key'], 'new'))
    @website.verify
    @node.verify
  end

  def test_referenced_nodes
    assert_equal(['alcn'], @obj.referenced_nodes(['alcn', nil], 'mi'))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webgen-1.0.0.beta2 test/webgen/item_tracker/test_node_meta_info.rb