Permalink
Browse files

DOTScript ignores types with empty data

  • Loading branch information...
1 parent 9c0898a commit 7504cb201cd9d1257c365b5c8e558f949aa8526b @markus1189 markus1189 committed Jul 7, 2012
Showing with 10 additions and 3 deletions.
  1. +4 −2 lib/graphviz/dot_script.rb
  2. +6 −1 test/test_dot_script.rb
@@ -10,19 +10,21 @@ def initialize
end
def append(line)
- @script << assure_ends_with(line, "\n")
+ @script << assure_ends_with(line.to_s,"\n")
self
end
alias :<< :append
def prepend(line)
- @script = assure_ends_with(line,"\n") + @script
+ @script = assure_ends_with(line.to_s,"\n") + @script
self
end
def add_type(type, data)
+ return self if data.empty?
+
case type
when "graph_attr"
append_statement(" " + data)
@@ -32,7 +32,12 @@
script.to_s.must_match(/\s*node\s*\[\s*#{data}\s*\]\s*/m)
end
+ it "does nothing if data is empty" do
+ script.add_type("anything", "")
+ script.to_s.must_be :empty?
+ end
+
it "raises an argument error on unknown types" do
- -> { script.add_type("invalid", "") }.must_raise(ArgumentError)
+ -> { script.add_type("invalid", "some data") }.must_raise(ArgumentError)
end
end

0 comments on commit 7504cb2

Please sign in to comment.