[Tomoe-cvs 1092] CVS update: tomoe/test

Back to archive index

Kouhei Sutou kous****@users*****
2006年 11月 27日 (月) 13:23:47 JST


Index: tomoe/test/writing_spec.rb
diff -u tomoe/test/writing_spec.rb:1.3 tomoe/test/writing_spec.rb:1.4
--- tomoe/test/writing_spec.rb:1.3	Sun Nov 26 16:30:37 2006
+++ tomoe/test/writing_spec.rb	Mon Nov 27 13:23:47 2006
@@ -1,27 +1,43 @@
 require 'tomoe-spec-utils'
 
 context "Tomoe::Writing" do
-  specify "should each all strokes" do
-    writing = Tomoe::Writing.new
-    strokes = [
-               [[51, 29], [177, 41]],
-               [[99, 65], [219, 77]],
-               [[27, 131], [261, 131]],
-               [[129, 17], [57, 203]],
-               [[111, 71], [219, 173]],
-               [[81, 161], [93, 281]],
-               [[99, 167], [207, 167], [189, 245]],
-               [[99, 227], [189, 227]],
-               [[111, 257], [189, 245]],
+  setup do
+    @writing = Tomoe::Writing.new
+    @strokes = [
+                [[51, 29], [177, 41]],
+                [[99, 65], [219, 77]],
+                [[27, 131], [261, 131]],
+                [[129, 17], [57, 203]],
+                [[111, 71], [219, 173]],
+                [[81, 161], [93, 281]],
+                [[99, 167], [207, 167], [189, 245]],
+                [[99, 227], [189, 227]],
+                [[111, 257], [189, 245]],
               ]
-    strokes.each do |first_point, *rest_points|
-      writing.move_to(*first_point)
+    @strokes.each do |first_point, *rest_points|
+      @writing.move_to(*first_point)
       rest_points.each do |x, y|
-        writing.line_to(x, y)
+        @writing.line_to(x, y)
       end
     end
+  end
 
-    writing.strokes.should == strokes
-    writing.collect{|stroke| stroke}.should == strokes
+  specify "should each all strokes" do
+    @writing.strokes.should == @strokes
+    @writing.collect{|stroke| stroke}.should == @strokes
+  end
+
+  specify "should dump XML" do
+    xml = ""
+    xml << "    <strokes>\n"
+    @strokes.each do |stroke|
+      xml << "      <stroke>\n"
+      stroke.each do |x, y|
+        xml << "        <point x=\"#{x}\" y=\"#{y}\"/>\n"
+      end
+      xml << "      </stroke>\n"
+    end
+    xml << "    </strokes>\n"
+    @writing.to_xml.should == xml
   end
 end


tomoe-cvs メーリングリストの案内
Back to archive index