test/test_dot_script.rb in ruby-graphviz-1.0.9 vs test/test_dot_script.rb in ruby-graphviz-1.1.0
- old
+ new
@@ -1,43 +1,47 @@
-require "minitest/autorun"
-require_relative "../lib/graphviz/dot_script"
+require 'helper'
-describe GraphViz::DOTScript do
- let(:script) { GraphViz::DOTScript.new }
+class GraphVizDOTScriptTest < Test::Unit::TestCase
+ def setup
+ @script = GraphViz::DOTScript.new
+ end
- it "appends a newline character if it is missing" do
- str = "Test without newline"
- script.append(str)
- script.to_s.must_equal(str + "\n")
- end
+ def test_appends_a_newline_character_if_it_is_missing
+ str = "Test without newline"
+ @script.append(str)
+ assert_equal @script.to_s, str + "\n"
+ end
- it "does not append a newline if already present" do
- str = "Linebreak follows at my tail:\n"
- script.append(str)
- script.to_s.must_equal(str)
- end
+ def test_does_not_append_a_newline_if_already_present
+ str = "Linebreak follows at my tail:\n"
+ @script.append(str)
+ assert_equal @script.to_s, str
+ end
- it "can prepend lines to its content" do
- start_content = "I want to be at the top!\n"
- additional_content = "No way!\n"
+ def test_can_prepend_lines_to_its_content
+ start_content = "I want to be at the top!\n"
+ additional_content = "No way!\n"
- script.append(start_content)
- script.prepend(additional_content)
+ @script.append(start_content)
+ @script.prepend(additional_content)
- script.to_s.must_equal(additional_content + start_content)
- end
+ assert_equal @script.to_s, additional_content + start_content
+ end
- it "can add types with data" do
- data = "some random data"
- script.add_type("node_attr", data)
- script.to_s.must_match(/\s*node\s*\[\s*#{data}\s*\]\s*/m)
- end
+ def test_can_add_types_with_data
+ data = "some random data"
+ @script.add_type("node_attr", data)
+ assert_match(/\s*node\s*\[\s*#{data}\s*\]\s*/, @script.to_s)
+ end
- it "does nothing if data is empty" do
- script.add_type("anything", "")
- script.to_s.must_be :empty?
- end
+ def test_does_nothing_if_data_is_empty
+ @script.add_type("anything", "")
+ assert_equal true, @script.to_s.empty?
+ end
- it "raises an argument error on unknown types" do
- -> { script.add_type("invalid", "some data") }.must_raise(ArgumentError)
+ def test_raises_an_argument_error_on_unknown_types
+ assert_raise ArgumentError do
+ @script.add_type("invalid", "some data")
end
+ end
end
+