Fixes Rubyvis::Image example and adds test coverage #14

Merged
merged 1 commit into from Jul 21, 2012
@@ -15,10 +15,9 @@ def self.image(scenes)
"x"=> s.left,
"y"=> s.top,
"width"=> s.width,
- "height"=> s.height
+ "height"=> s.height,
+ "xlink:href" => s.url
})
-
- e.add_attribute("xlink:href", s.url);
end
e = self.append(e, scenes, i);
@@ -0,0 +1 @@
+<svg font-size="10px" font-family="sans-serif" fill="none" stroke="none" stroke-width="1.5" width="440" height="440"><g transform="translate(20,20)"><image preserveAspectRatio="none" width="400" height="400" xlink:href="fixtures/tipsy.gif"/></g><rect x="20" y="20" width="400" height="400" fill="none" stroke="rgb(204,204,204)"/></svg>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,27 @@
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
+describe Rubyvis::Image do
+
+ include Rubyvis::GeneralSpec
+
+ it "Rubyvis.Image be the same as Rubyvis::Image" do
+ Rubyvis.Image.should eql Rubyvis::Image
+ end
+
+ it "should render correctly" do
+ w = 400
+ h = 400
+
+ vis = Rubyvis::Panel.new().
+ width(w).
+ height(h).
+ margin(20).
+ stroke_style("#ccc");
+
+ vis.add(Rubyvis::Image).url('fixtures/tipsy.gif')
+ vis.render()
+
+ pv_out=fixture_svg_read("image.svg")
+ vis.to_svg.should have_same_svg_elements(pv_out)
+ end
+
+end