Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Merged
merged 1 commit into from over 1 year ago

2 participants

Kyle Wilcox Claudio Bustos
Kyle Wilcox

fixes #13

Claudio Bustos clbustos merged commit c575346 into from July 20, 2012
Claudio Bustos clbustos closed this July 20, 2012
Claudio Bustos
Owner

Sorry for the delay.

Thank you very much for spot the error!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 10, 2012
Kyle Wilcox Fix Image example and add simple test coverage for Rubyvis::Image
fixes #13
c575346
This page is out of date. Refresh to see the latest.
5  lib/rubyvis/scene/svg_image.rb
@@ -15,10 +15,9 @@ def self.image(scenes)
15 15
           "x"=> s.left,
16 16
           "y"=> s.top,
17 17
           "width"=> s.width,
18  
-          "height"=> s.height
  18
+          "height"=> s.height,
  19
+          "xlink:href" => s.url
19 20
           })
20  
-          
21  
-          e.add_attribute("xlink:href", s.url);
22 21
         end
23 22
         e = self.append(e, scenes, i);
24 23
         
1  spec/fixtures/image.svg
... ...
@@ -0,0 +1 @@
  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>
BIN  spec/fixtures/tipsy.gif
27  spec/image_spec.rb
... ...
@@ -0,0 +1,27 @@
  1
+require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
  2
+describe Rubyvis::Image do
  3
+
  4
+  include Rubyvis::GeneralSpec
  5
+
  6
+  it "Rubyvis.Image be the same as Rubyvis::Image" do
  7
+    Rubyvis.Image.should eql Rubyvis::Image
  8
+  end
  9
+  
  10
+  it "should render correctly" do
  11
+    w = 400
  12
+    h = 400
  13
+    
  14
+    vis = Rubyvis::Panel.new().
  15
+      width(w).
  16
+      height(h).
  17
+      margin(20).
  18
+      stroke_style("#ccc");
  19
+    
  20
+    vis.add(Rubyvis::Image).url('fixtures/tipsy.gif')
  21
+    vis.render()
  22
+    
  23
+    pv_out=fixture_svg_read("image.svg")
  24
+    vis.to_svg.should have_same_svg_elements(pv_out)
  25
+  end
  26
+   
  27
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.