test/test_graph.rb in graph-2.8.2 vs test/test_graph.rb in graph-2.9.0
- old
+ new
@@ -12,10 +12,13 @@
class TestGraph < Minitest::Test
attr_accessor :graph
def assert_attribute k, v, a
assert_kind_of Graph::Attribute, a
+
+ v = v.dump if String === v
+
assert_equal "#{k} = #{v}", a.attr
end
def assert_graph graph, *lines
lines = lines.map { |l| " #{l};" }.join("\n")
@@ -31,11 +34,11 @@
def test_boxes
assert_graph graph, '"a" -> "b"'
graph.boxes
- assert_graph graph, 'node [ shape = box ]', '"a" -> "b"'
+ assert_graph graph, 'node [ shape = "box" ]', '"a" -> "b"'
end
def test_colorscheme
assert_attribute "colorscheme", "blah", graph.colorscheme("blah")
assert_empty graph.node_attribs
@@ -55,17 +58,17 @@
def test_fillcolor
assert_attribute "fillcolor", "blah", graph.fillcolor("blah")
end
def test_font
- assert_attribute "fontname", '"blah"', graph.font("blah")
+ assert_attribute "fontname", "blah", graph.font("blah")
end
def test_font_size
# cheating... but I didn't want to write a more complex assertion
- assert_attribute "fontname", '"blah"', graph.font("blah")
- assert_attribute "fontsize", '12', graph.fontsize(12)
+ assert_attribute "fontname", "blah", graph.font("blah")
+ assert_attribute "fontsize", 12, graph.fontsize(12)
end
def test_digraph
g = digraph do
edge "a", "b", "c"
@@ -206,10 +209,14 @@
def test_save_nil
assert_save nil
end
+ def test_save_cmd
+ assert_save "png", "neato"
+ end
+
def test_shape
assert_attribute "shape", "blah", graph.shape("blah")
end
def test_style
@@ -285,23 +292,23 @@
assert_graph(graph,
g_s, # HACK: indentation is really messy right now
'"a" -> "b"')
end
- def assert_save type
+ def assert_save type, cmd = "dot"
path = File.join(Dir.tmpdir, "blah.#{$$}")
actual = expected = false
mc = (class << graph; self; end)
mc.send :define_method, :system do |*args|
actual = args
end
- graph.save(path, type)
+ graph.save(path, type, cmd)
assert_equal graph.to_s + "\n", File.read("#{path}.dot")
- expected = ["dot -T#{type} #{path}.dot > #{path}.png"] if type
+ expected = ["#{cmd} -T#{type} #{path}.dot > #{path}.png"] if type
assert_equal expected, actual
ensure
File.unlink path rescue nil
end
end