Sha256: 0c48dbec874cf19148f3a11ffebb85212d2252b3357d6c0fbab586e19b8cbc68

Contents?: true

Size: 1.36 KB

Versions: 73

Compression:

Stored size: 1.36 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestDependencyGraph < Test::Unit::TestCase
  def setup
    @dg = DependencyGraph.new
  end
  
  # new
  
  def test_new_should_accept_zero_arguments
    assert @dg.instance_of?(DependencyGraph)
  end
  
  # add
  
  def test_add_should_create_and_store_two_new_nodes
    @dg.add('foo', 'bar')
    assert_equal 2, @dg.nodes.size
    assert @dg.nodes['foo'].instance_of?(DependencyGraph::Node)
    assert @dg.nodes['bar'].instance_of?(DependencyGraph::Node)
  end
  
  def test_add_should_record_dependency
    @dg.add('foo', 'bar')
    assert_equal 1, @dg.nodes['foo'].dependencies.size
    assert_equal @dg.nodes['bar'], @dg.nodes['foo'].dependencies.first
  end
  
  def test_add_should_ignore_dups
    @dg.add('foo', 'bar')
    @dg.add('foo', 'bar')
    assert_equal 2, @dg.nodes.size    
    assert_equal 1, @dg.nodes['foo'].dependencies.size
  end
end


class TestDependencyGraphNode < Test::Unit::TestCase
  def setup
    @foo = DependencyGraph::Node.new('foo')
    @bar = DependencyGraph::Node.new('bar')
  end
  
  # new
  
  def test_new_should_accept_zero_arguments
    assert @foo.instance_of?(DependencyGraph::Node)
  end
  
  # add
  
  def test_add_should_store_node_as_dependency
    @foo.add(@bar)
    assert_equal 1, @foo.dependencies.size
  end
  
  # has_node?
  
  def test_has_node
    assert @foo.has_node?(@foo)
  end
end

Version data entries

73 entries across 73 versions & 22 rubygems

Version Path
mojombo-god-0.7.11 test/test_dependency_graph.rb
mojombo-god-0.7.12 test/test_dependency_graph.rb
mojombo-god-0.7.13 test/test_dependency_graph.rb
mojombo-god-0.7.14 test/test_dependency_graph.rb
mojombo-god-0.7.15 test/test_dependency_graph.rb
mojombo-god-0.7.16 test/test_dependency_graph.rb
mojombo-god-0.7.20 test/test_dependency_graph.rb
mojombo-god-0.7.7 test/test_dependency_graph.rb
mojombo-god-0.7.9 test/test_dependency_graph.rb
obitum-god-0.7.14.1 test/test_dependency_graph.rb
obitum-god-0.7.14 test/test_dependency_graph.rb
pjhyett-god-0.7.12 test/test_dependency_graph.rb
relevance-god-0.7.12.1 test/test_dependency_graph.rb
relevance-god-0.7.12 test/test_dependency_graph.rb
saimonmoore-god-0.7.9 test/test_dependency_graph.rb
samhendley-god-0.7.13 test/test_dependency_graph.rb
strobemonkey-god-0.7.13 test/test_dependency_graph.rb
firenxis-god-0.11.0 test/test_dependency_graph.rb
god-0.11.0 test/test_dependency_graph.rb
god-0.10.1 test/test_dependency_graph.rb