rubyvis 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +6 -6
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +27 -21
  5. data/History.txt +10 -0
  6. data/lib/rubyvis.rb +1 -4
  7. data/lib/rubyvis/mark/panel.rb +1 -1
  8. data/lib/rubyvis/scene/svg_line.rb +0 -1
  9. data/lib/rubyvis/scene/svg_panel.rb +3 -0
  10. data/lib/rubyvis/scene/svg_rule.rb +0 -1
  11. data/lib/rubyvis/sceneelement.rb +1 -0
  12. data/lib/rubyvis/version.rb +6 -0
  13. data/rubyvis.gemspec +1 -2
  14. data/spec/anchor_spec.rb +11 -11
  15. data/spec/area_spec.rb +10 -10
  16. data/spec/bar_spec.rb +13 -13
  17. data/spec/color_spec.rb +24 -24
  18. data/spec/dom_spec.rb +77 -77
  19. data/spec/dot_spec.rb +3 -3
  20. data/spec/flatten_spec.rb +2 -2
  21. data/spec/histogram_spec.rb +5 -5
  22. data/spec/image_spec.rb +2 -2
  23. data/spec/internal_spec.rb +58 -58
  24. data/spec/javascript_behaviour_spec.rb +14 -14
  25. data/spec/label_spec.rb +9 -9
  26. data/spec/layout_arc_spec.rb +5 -5
  27. data/spec/layout_cluster_spec.rb +4 -4
  28. data/spec/layout_grid_spec.rb +5 -5
  29. data/spec/layout_horizon_spec.rb +5 -5
  30. data/spec/layout_indent_spec.rb +3 -3
  31. data/spec/layout_matrix_spec.rb +6 -6
  32. data/spec/layout_pack_spec.rb +2 -2
  33. data/spec/layout_partition_spec.rb +4 -4
  34. data/spec/layout_stack_spec.rb +11 -11
  35. data/spec/layout_tree_spec.rb +4 -4
  36. data/spec/layout_treemap_spec.rb +2 -2
  37. data/spec/line_spec.rb +14 -14
  38. data/spec/mark_spec.rb +7 -7
  39. data/spec/nest_spec.rb +3 -3
  40. data/spec/panel_spec.rb +10 -10
  41. data/spec/readme_spec.rb +6 -6
  42. data/spec/ruby_api_spec.rb +4 -4
  43. data/spec/rule_spec.rb +3 -3
  44. data/spec/scale_linear_datetime_spec.rb +23 -23
  45. data/spec/scale_linear_spec.rb +37 -37
  46. data/spec/scale_log_spec.rb +28 -28
  47. data/spec/scale_ordinal_spec.rb +21 -21
  48. data/spec/scale_spec.rb +2 -2
  49. data/spec/spec_helper.rb +6 -5
  50. data/spec/vector_spec.rb +8 -8
  51. data/spec/wedge_spec.rb +4 -4
  52. data/web/build_site.rb +1 -1
  53. metadata +4 -4
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  describe Rubyvis::Layout::Treemap do
3
3
  include Rubyvis::LayoutSpec
4
4
  it "should have correct properties" do
5
- props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :links, :mode, :nodes, :order, :overflow, :padding_bottom, :padding_left, :padding_right, :padding_top, :reverse, :right, :round, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
5
+ props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :links, :mode, :nodes, :order, :overflow, :padding_bottom, :padding_left, :padding_right, :padding_top, :reverse, :right, :round, :stroke_style, :title, :top, :transform, :visible, :view_box, :width].inject({}) {|ac, v| ac[v]=true; ac}
6
6
  Rubyvis::Layout::Treemap.properties.should==props
7
7
  end
8
8
  describe "rendered" do
@@ -35,7 +35,7 @@ describe Rubyvis::Layout::Treemap do
35
35
  end
36
36
 
37
37
  it "should render equal to protovis version " do
38
- @vis.to_svg.should have_same_svg_elements(@pv_out)
38
+ expect(@vis.to_svg).to have_same_svg_elements(@pv_out)
39
39
  end
40
40
  end
41
41
  end
@@ -3,7 +3,7 @@ describe Rubyvis::Line do
3
3
  include Rubyvis::GeneralSpec
4
4
  it "should have correct properties" do
5
5
  props=[:antialias, :bottom, :cursor, :data, :eccentricity, :events, :fill_style, :id, :interpolate, :left, :line_join, :line_width, :reverse, :right, :segmented, :stroke_dasharray, :stroke_style, :tension, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
6
- Rubyvis::Line.properties.should==props
6
+ expect(Rubyvis::Line.properties).to eq(props)
7
7
  end
8
8
  it "should render correctly 'line_interpolation.html' example" do
9
9
  data = pv.range(0, 10, 0.2).map {|x|
@@ -54,7 +54,7 @@ top(5)
54
54
  end
55
55
  vis.render()
56
56
  pv_out=fixture_svg_read("line_interpolation.svg")
57
- vis.to_svg.should have_same_svg_elements(pv_out)
57
+ expect(vis.to_svg).to have_same_svg_elements(pv_out)
58
58
  end
59
59
  it "should render correctly 'line_interpolation_segmented.html' example" do
60
60
  data = pv.range(0, 10, 0.2).map {|x|
@@ -106,7 +106,7 @@ top(5)
106
106
  end
107
107
  vis.render()
108
108
  pv_out=fixture_svg_read("line_interpolation_segmented.svg")
109
- vis.to_svg.should have_same_svg_elements(pv_out)
109
+ expect(vis.to_svg).to have_same_svg_elements(pv_out)
110
110
  end
111
111
  it "SvgScene.path_join should return correct value" do
112
112
  s0=OpenStruct.new({:left=>1,:top=>2,:visible=>true, :line_width=>2.5})
@@ -116,9 +116,9 @@ top(5)
116
116
  # obj.attributes["d"].value
117
117
  exp_data="M2.1161165235168156,4.883883476483184L4.116116523516816,6.883883476483184 5.883883476483184,5.116116523516816 3.8838834764831844,3.1161165235168156"
118
118
  obs=""
119
- obs.stub(:attributes).and_return({'d'=>OpenStruct.new({:value=>Rubyvis::SvgScene.path_join(s0,s1,s2,s3)})})
119
+ allow(obs).to receive(:attributes).and_return({'d'=>OpenStruct.new({:value=>Rubyvis::SvgScene.path_join(s0,s1,s2,s3)})})
120
120
 
121
- obs.should have_path_data_close_to exp_data
121
+ expect(obs).to have_path_data_close_to exp_data
122
122
 
123
123
  s0=OpenStruct.new({:left=>1.5,:top=>2,:visible=>true, :line_width=>3})
124
124
  s1=OpenStruct.new({:left=>3.5,:top=>4,:visible=>true, :line_width=>3.5})
@@ -126,8 +126,8 @@ top(5)
126
126
  s3=OpenStruct.new({:left=>7.5,:top=>8,:visible=>true, :line_width=>4.5})
127
127
  exp_data="M2.2625631329235425,5.2374368670764575L4.2625631329235425,7.2374368670764575 6.7374368670764575,4.7625631329235425 4.7374368670764575,2.7625631329235425"
128
128
  obs=""
129
- obs.stub(:attributes).and_return({'d'=>OpenStruct.new({:value=>Rubyvis::SvgScene.path_join(s0,s1,s2,s3)})})
130
- obs.should have_path_data_close_to exp_data
129
+ allow(obs).to receive(:attributes).and_return({'d'=>OpenStruct.new({:value=>Rubyvis::SvgScene.path_join(s0,s1,s2,s3)})})
130
+ expect(obs).to have_path_data_close_to exp_data
131
131
 
132
132
  end
133
133
  context "rendered" do
@@ -143,26 +143,26 @@ top(5)
143
143
  it "should return correct default (linear) path" do
144
144
  @vis.render
145
145
  doc=Nokogiri::XML(@vis.to_svg)
146
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180L20 160L40 180L60 120L80 180L100 100L100 200L80 200L60 200L40 200L20 200L0 200Z"
146
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180L20 160L40 180L60 120L80 180L100 100L100 200L80 200L60 200L40 200L20 200L0 200Z"
147
147
  end
148
148
  it "should return correct path for interpolate=step-before" do
149
149
  @area.interpolate('step-before')
150
150
  @vis.render
151
151
  doc=Nokogiri::XML(@vis.to_svg)
152
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180V160H20V180H40V120H60V180H80V100H100"
152
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0,180V160H20V180H40V120H60V180H80V100H100"
153
153
  end
154
154
  it "should return correct path for interpolate=step-after" do
155
155
  @area.interpolate('step-after')
156
156
  @vis.render
157
157
  doc=Nokogiri::XML(@vis.to_svg)
158
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180H20V160H40V180H60V120H80V180H100V100"
158
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0,180H20V160H40V180H60V120H80V180H100V100"
159
159
  end
160
160
 
161
161
  it "should return correct path for interpolate=polar" do
162
162
  @area.interpolate('polar')
163
163
  @vis.render
164
164
  doc=Nokogiri::XML(@vis.to_svg)
165
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180A14.142135623730951,14.142135623730951 0 0,1 20,160A14.142135623730951,14.142135623730951 0 0,1 40,180A31.622776601683793,31.622776601683793 0 0,1 60,120A31.622776601683793,31.622776601683793 0 0,1 80,180A41.23105625617661,41.23105625617661 0 0,1 100,100"
165
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0,180A14.142135623730951,14.142135623730951 0 0,1 20,160A14.142135623730951,14.142135623730951 0 0,1 40,180A31.622776601683793,31.622776601683793 0 0,1 60,120A31.622776601683793,31.622776601683793 0 0,1 80,180A41.23105625617661,41.23105625617661 0 0,1 100,100"
166
166
  end
167
167
 
168
168
 
@@ -171,19 +171,19 @@ top(5)
171
171
  @area.interpolate('polar-reverse')
172
172
  @vis.render
173
173
  doc=Nokogiri::XML(@vis.to_svg)
174
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0,180A14.142135623730951,14.142135623730951 0 0,0 20,160A14.142135623730951,14.142135623730951 0 0,0 40,180A31.622776601683793,31.622776601683793 0 0,0 60,120A31.622776601683793,31.622776601683793 0 0,0 80,180A41.23105625617661,41.23105625617661 0 0,0 100,100"
174
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0,180A14.142135623730951,14.142135623730951 0 0,0 20,160A14.142135623730951,14.142135623730951 0 0,0 40,180A31.622776601683793,31.622776601683793 0 0,0 60,120A31.622776601683793,31.622776601683793 0 0,0 80,180A41.23105625617661,41.23105625617661 0 0,0 100,100"
175
175
  end
176
176
  it "should return correct path for interpolate=basis" do
177
177
  @area.interpolate('basis')
178
178
  @vis.render
179
179
  doc=Nokogiri::XML(@vis.to_svg)
180
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180C0 180 0 180 3.333333333333333 176.66666666666666C6.666666666666666 173.33333333333331 13.333333333333332 166.66666666666666 20 166.66666666666666C26.666666666666664 166.66666666666666 33.33333333333333 173.33333333333331 40 166.66666666666666C46.666666666666664 160 53.33333333333333 140 60 140C66.66666666666666 140 73.33333333333333 160 80 156.66666666666666C86.66666666666666 153.33333333333331 93.33333333333331 126.66666666666666 96.66666666666666 113.33333333333331C99.99999999999999 99.99999999999999 99.99999999999999 99.99999999999999 99.99999999999997 99.99999999999997"
180
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180C0 180 0 180 3.333333333333333 176.66666666666666C6.666666666666666 173.33333333333331 13.333333333333332 166.66666666666666 20 166.66666666666666C26.666666666666664 166.66666666666666 33.33333333333333 173.33333333333331 40 166.66666666666666C46.666666666666664 160 53.33333333333333 140 60 140C66.66666666666666 140 73.33333333333333 160 80 156.66666666666666C86.66666666666666 153.33333333333331 93.33333333333331 126.66666666666666 96.66666666666666 113.33333333333331C99.99999999999999 99.99999999999999 99.99999999999999 99.99999999999999 99.99999999999997 99.99999999999997"
181
181
  end
182
182
  it "should return correct path for interpolate=cardinal" do
183
183
  @area.interpolate('cardinal')
184
184
  @vis.render
185
185
  doc=Nokogiri::XML(@vis.to_svg)
186
- doc.at_xpath("//xmlns:path").should have_path_data_close_to "M0 180Q16 160 20 160C26 160 34 186 40 180S54 120 60 120S74 183 80 180Q84 178 100 100"
186
+ expect(doc.at_xpath("//xmlns:path")).to have_path_data_close_to "M0 180Q16 160 20 160C26 160 34 186 40 180S54 120 60 120S74 183 80 180Q84 178 100 100"
187
187
  end
188
188
  end
189
189
  end
@@ -2,19 +2,19 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  describe Rubyvis::Mark do
3
3
  it "should have correct properties" do
4
4
  props=[:antialias, :bottom, :cursor, :data, :events, :id, :left, :reverse, :right, :title, :top, :visible].inject({}) {|ac, v| ac[v]=true; ac}
5
- Rubyvis::Mark.properties.should==props
5
+ expect(Rubyvis::Mark.properties).to eq(props)
6
6
  end
7
7
  it "should return correct defaults" do
8
8
  props=Rubyvis::Mark.defaults._properties.sort {|a,b| a.name.to_s<=>b.name.to_s}
9
- props[1].name.should==:data
10
- props[1].value.should be_instance_of Proc
11
- props[3].name.should==:visible
12
- props[0].name.should==:antialias
13
- props[2].name.should==:events
9
+ expect(props[1].name).to eq(:data)
10
+ expect(props[1].value).to be_instance_of Proc
11
+ expect(props[3].name).to eq(:visible)
12
+ expect(props[0].name).to eq(:antialias)
13
+ expect(props[2].name).to eq(:events)
14
14
  end
15
15
  it "should have 'mark' as type" do
16
16
  m=Rubyvis::Mark.new
17
- m.type.should eql "mark"
17
+ expect(m.type).to eql "mark"
18
18
  end
19
19
 
20
20
  end
@@ -12,13 +12,13 @@ describe Rubyvis::Nest do
12
12
  nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d| d[:city]}).map()
13
13
 
14
14
  expected={2010=>{"London"=>[{:year=>2010, :city=>"London", :value=>1}], "France"=>[{:year=>2010, :city=>"France", :value=>2}]}, 2011=>{"London"=>[{:year=>2011, :city=>"London", :value=>5}], "France"=>[{:year=>2011, :city=>"France", :value=>6}]}}
15
- nest.should==expected
15
+ expect(nest).to eq(expected)
16
16
 
17
17
  end
18
18
  it "should generate correct rollup" do
19
19
  nest = pv.nest(@data).key(lambda {|d| d[:year]}).key(lambda {|d| d[:city]}).rollup(lambda {|d| d.map{|dd| dd[:value]}})
20
20
  expected={2010=>{"London"=>[1], "France"=>[2]}, 2011=>{"London"=>[5], "France"=>[6]}}
21
- nest.should==expected
21
+ expect(nest).to eq(expected)
22
22
 
23
23
  end
24
24
  it "should generate correct entries" do
@@ -40,7 +40,7 @@ describe Rubyvis::Nest do
40
40
  ])
41
41
  ]
42
42
 
43
- nest.should==expected
43
+ expect(nest).to eq(expected)
44
44
 
45
45
  end
46
46
 
@@ -3,33 +3,33 @@ describe Rubyvis::Panel do
3
3
  before do
4
4
  @h=200
5
5
  @w=200
6
- @vis = Rubyvis.Panel.new.width(@w).height(@h)
6
+ @vis = Rubyvis.Panel.new.width(@w).height(@h).view_box("0 0 #{@w} #{@h}")
7
7
  end
8
8
  it "should have correct properties" do
9
- props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
9
+ props=[:antialias, :bottom, :canvas, :cursor, :data, :events, :fill_style, :height, :id, :left, :line_width, :overflow, :reverse, :right, :stroke_style, :title, :top, :transform, :view_box, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
10
10
  Rubyvis::Panel.properties.should==props
11
11
  end
12
12
  it "should have correct defaults" do
13
- Rubyvis::Panel.defaults._properties.size.should==2
13
+ expect(Rubyvis::Panel.defaults._properties.size).to eq(2)
14
14
  end
15
15
  it "should build propertly" do
16
- lambda {@vis.render}.should_not raise_exception
16
+ expect {@vis.render}.not_to raise_exception
17
17
  end
18
18
  it "should return valid svg" do
19
19
  @vis.render
20
20
  doc=Nokogiri::XML(@vis.to_svg)
21
- doc.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"200.0", "height"=>"200.0"})
21
+ doc.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"200.0", "height"=>"200.0", "viewBox" => "0 0 200 200"})
22
22
  end
23
23
  it "should allow multiple panel definitions" do
24
- vis2 = Rubyvis.Panel.new.width(@w+100).height(@h+100)
24
+ vis2 = Rubyvis.Panel.new.width(@w+100).height(@h+100).view_box("0 0 #{@w+100} #{@h+100}")
25
25
  @vis.render
26
26
  vis2.render
27
27
  doc1=Nokogiri::XML(@vis.to_svg)
28
28
  doc2=Nokogiri::XML(vis2.to_svg)
29
29
 
30
- doc1.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"200.0", "height"=>"200.0"})
31
-
32
- doc2.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"300.0", "height"=>"300.0"})
30
+ doc1.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"200.0", "height"=>"200.0", "viewBox" => "0 0 200 200"})
33
31
 
32
+ doc2.at_xpath("//xmlns:svg").should have_svg_attributes({"font-size"=>"10px", "font-family"=>"sans-serif", "fill"=>"none", "stroke"=>"none", "stroke-width"=>"1.5", "width"=>"300.0", "height"=>"300.0", "viewBox" => "0 0 300 300"})
33
+
34
34
  end
35
- end
35
+ end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  describe "Rubyvis Readme" do
3
3
  it "should work with RBP API" do
4
4
  vis=nil
5
- lambda {
5
+ expect {
6
6
  vis = Rubyvis::Panel.new do
7
7
  width 150
8
8
  height 150
@@ -15,12 +15,12 @@ describe "Rubyvis Readme" do
15
15
  end
16
16
  end
17
17
 
18
- vis.render}.should_not raise_exception
19
- vis.to_svg.size.should>0
18
+ vis.render}.not_to raise_exception
19
+ expect(vis.to_svg.size).to be > 0
20
20
  end
21
21
  it "should work with Protovis API" do
22
22
  vis=nil
23
- lambda {
23
+ expect {
24
24
  vis = Rubyvis::Panel.new.width(150).height(150);
25
25
 
26
26
  vis.add(pv.Bar).
@@ -31,8 +31,8 @@ describe "Rubyvis Readme" do
31
31
  left(lambda {self.index * 25});
32
32
 
33
33
  vis.render
34
- }.should_not raise_exception
35
- vis.to_svg.size.should>0
34
+ }.not_to raise_exception
35
+ expect(vis.to_svg.size).to be > 0
36
36
  end
37
37
 
38
38
  end
@@ -5,12 +5,12 @@ shared_examples_for "Ruby API for Rubyvis" do
5
5
  @w=200
6
6
  end
7
7
  it "should create a Panel with a block" do
8
- lambda {@vis = Rubyvis.Panel.new {
8
+ expect {@vis = Rubyvis.Panel.new {
9
9
  width @w
10
10
  height @h
11
11
  }
12
- }.should_not raise_exception
13
- @vis._properties.size.should==2
12
+ }.not_to raise_exception
13
+ expect(@vis._properties.size).to eq(2)
14
14
  end
15
15
  it "should create a Bar with new method" do
16
16
  vis1=Rubyvis.Panel.new.width(@w).height(@h)
@@ -41,7 +41,7 @@ shared_examples_for "Ruby API for Rubyvis" do
41
41
  }
42
42
  vis2.render
43
43
  svg2=vis2.to_svg
44
- svg1.should==svg2
44
+ expect(svg1).to eq(svg2)
45
45
 
46
46
  end
47
47
  end
@@ -3,10 +3,10 @@ describe Rubyvis::Rule do
3
3
  include Rubyvis::GeneralSpec
4
4
  it "should have correct properties" do
5
5
  props=[:antialias, :bottom, :cursor, :data, :events, :height, :id, :left, :line_width, :reverse, :right, :stroke_style, :stroke_dasharray, :title, :top, :visible, :width].inject({}) {|ac, v| ac[v]=true; ac}
6
- Rubyvis::Rule.properties.should==props
6
+ expect(Rubyvis::Rule.properties).to eq(props)
7
7
  end
8
8
  it "Rubyvis.Rule be the same as Rubyvis::Rule" do
9
- Rubyvis.Rule.should eql Rubyvis::Rule
9
+ expect(Rubyvis.Rule).to eql Rubyvis::Rule
10
10
  end
11
11
  it "should render equal to protovis 'rule-anchor.html' test" do
12
12
  vis = Rubyvis::Panel.new().
@@ -27,7 +27,7 @@ describe Rubyvis::Rule do
27
27
 
28
28
  vis.render();
29
29
  pv_out=fixture_svg_read("rule_anchor.svg")
30
- vis.to_svg.should have_same_svg_elements(pv_out)
30
+ expect(vis.to_svg).to have_same_svg_elements(pv_out)
31
31
  end
32
32
 
33
33
  end
@@ -17,51 +17,51 @@ describe "Rubyvis::Scale::Linear with dates" do
17
17
  end
18
18
  it "should not crash on :week_day precision (bug #15)" do
19
19
  ct=Time.utc(2012,03,19,10,10,10)
20
- @y.mock_ticks_floor(ct,:week_day).should==Time.utc(2012,03,18,10,10,10)
20
+ expect(@y.mock_ticks_floor(ct,:week_day)).to eq(Time.utc(2012,03,18,10,10,10))
21
21
  end
22
22
  it "y should be a Scale" do
23
- @y.should be_a(Rubyvis::Scale::Linear)
23
+ expect(@y).to be_a(Rubyvis::Scale::Linear)
24
24
  end
25
25
  it "should respond to domain" do
26
- @y.domain.should==[@bd, @ed]
26
+ expect(@y.domain).to eq([@bd, @ed])
27
27
  @y.domain(@bd)
28
- @y.domain.should==[@bd,@bd]
28
+ expect(@y.domain).to eq([@bd,@bd])
29
29
  @y.domain(@bd,@ed,@ed+1)
30
- @y.domain.should==[@bd,@ed,@ed+1]
30
+ expect(@y.domain).to eq([@bd,@ed,@ed+1])
31
31
  end
32
32
  it "should respond to range" do
33
- @y.range.should==[0, @h]
33
+ expect(@y.range).to eq([0, @h])
34
34
  @y.range(1)
35
- @y.range.should==[1,1]
35
+ expect(@y.range).to eq([1,1])
36
36
  @y.range(1,100,300)
37
- @y.range.should==[1,100,300]
37
+ expect(@y.range).to eq([1,100,300])
38
38
  end
39
39
  it "should returns correct scale" do
40
- @y.scale(@bd).should==0
41
- @y.scale(@ed).should==@h
42
- @y[@ed].should==@h
40
+ expect(@y.scale(@bd)).to eq(0)
41
+ expect(@y.scale(@ed)).to eq(@h)
42
+ expect(@y[@ed]).to eq(@h)
43
43
  val= (@ed.to_f+@bd.to_f) / 2.0
44
- @y.scale(val).should be_within( 0.001).of(@h / 2.0)
44
+ expect(@y.scale(val)).to be_within( 0.001).of(@h / 2.0)
45
45
  end
46
46
  it "should returns correct invert" do
47
- @y.invert(0).should==@bd
48
- @y.invert(@h).should==@ed
47
+ expect(@y.invert(0)).to eq(@bd)
48
+ expect(@y.invert(@h)).to eq(@ed)
49
49
  end
50
50
  it "should returns correct ticks" do
51
- @y.ticks.size.should==5
52
- @y.ticks(5).size.should==5
53
- @y.ticks(5)[0].should be_instance_of Time
51
+ expect(@y.ticks.size).to eq(5)
52
+ expect(@y.ticks(5).size).to eq(5)
53
+ expect(@y.ticks(5)[0]).to be_instance_of Time
54
54
 
55
55
  #p @y.ticks
56
56
  end
57
57
  it "should return correct tick_floor" do
58
58
  ct=Time.utc(2012,04,05,10,10,10)
59
- @y.mock_ticks_floor(ct,:month).should==Time.utc(2012,01,05,10,10,10)
60
- @y.mock_ticks_floor(ct,:month_day).should==Time.utc(2012,04,01,10,10,10)
61
- @y.mock_ticks_floor(ct,:week_day).should==Time.utc(2012,04,01,10,10,10)
62
- @y.mock_ticks_floor(ct,:hour).should==Time.utc(2012,04,05,00,10,10)
63
- @y.mock_ticks_floor(ct,:minute).should==Time.utc(2012,04,05,10,00,10)
64
- @y.mock_ticks_floor(ct,:second).should==Time.utc(2012,04,05,10,10,00)
59
+ expect(@y.mock_ticks_floor(ct,:month)).to eq(Time.utc(2012,01,05,10,10,10))
60
+ expect(@y.mock_ticks_floor(ct,:month_day)).to eq(Time.utc(2012,04,01,10,10,10))
61
+ expect(@y.mock_ticks_floor(ct,:week_day)).to eq(Time.utc(2012,04,01,10,10,10))
62
+ expect(@y.mock_ticks_floor(ct,:hour)).to eq(Time.utc(2012,04,05,00,10,10))
63
+ expect(@y.mock_ticks_floor(ct,:minute)).to eq(Time.utc(2012,04,05,10,00,10))
64
+ expect(@y.mock_ticks_floor(ct,:second)).to eq(Time.utc(2012,04,05,10,10,00))
65
65
 
66
66
  end
67
67
 
@@ -21,30 +21,30 @@ describe Rubyvis::Scale::Linear do
21
21
  it "domain() implemented equally" do
22
22
  @y.domain(@v1)
23
23
  @rt.evaluate("y.domain(v1)")
24
- @y.domain.should==@rt.evaluate("y.domain()").to_a
24
+ expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
25
25
  @y.domain(@v1,@v2,@v3)
26
26
  @rt.evaluate("y.domain(v1,v2,v3)")
27
- @y.domain.should==@rt.evaluate("y.domain()").to_a
27
+ expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
28
28
  end
29
29
  it "scale() implemented equally for complex domain" do
30
30
  @y.domain(@v1,@v2,@v3)
31
31
  @rt.evaluate("y.domain(v1,v2,v3)")
32
- @y.scale(@v1+1).should==@rt.evaluate("y(v1+1)")
33
- @y.scale(@v2+1).should==@rt.evaluate("y(v2+1)")
34
- @y.scale(@v3+1).should==@rt.evaluate("y(v3+1)")
32
+ expect(@y.scale(@v1+1)).to eq(@rt.evaluate("y(v1+1)"))
33
+ expect(@y.scale(@v2+1)).to eq(@rt.evaluate("y(v2+1)"))
34
+ expect(@y.scale(@v3+1)).to eq(@rt.evaluate("y(v3+1)"))
35
35
  end
36
36
  it "invert() implemented equally" do
37
37
  @y.domain(@v1,@v2,@v3)
38
38
  @rt.evaluate("y.domain(v1,v2,v3)")
39
- @y.invert(@v1+1).should==@rt.evaluate("y.invert(v1+1)")
40
- @y.invert(@v2+1).should==@rt.evaluate("y.invert(v2+1)")
41
- @y.invert(@v3+1).should==@rt.evaluate("y.invert(v3+1)")
39
+ expect(@y.invert(@v1+1)).to eq(@rt.evaluate("y.invert(v1+1)"))
40
+ expect(@y.invert(@v2+1)).to eq(@rt.evaluate("y.invert(v2+1)"))
41
+ expect(@y.invert(@v3+1)).to eq(@rt.evaluate("y.invert(v3+1)"))
42
42
  end
43
43
  it "ticks() implemented equally for numbers" do
44
- @y.ticks.should==@rt.evaluate("y.ticks()").to_a
44
+ expect(@y.ticks).to eq(@rt.evaluate("y.ticks()").to_a)
45
45
  (5..20).each {|i|
46
46
  @rt[:i]=i
47
- @y.ticks(i).should==@rt.evaluate("y.ticks(i)").to_a
47
+ expect(@y.ticks(i)).to eq(@rt.evaluate("y.ticks(i)").to_a)
48
48
  }
49
49
  end
50
50
  it "nice() implemented equally" do
@@ -52,7 +52,7 @@ describe Rubyvis::Scale::Linear do
52
52
  @rt.evaluate("y.domain(v1,v2)")
53
53
  @y.nice
54
54
  @rt.evaluate("y.nice()")
55
- @y.domain.should==@rt.evaluate("y.domain()").to_a
55
+ expect(@y.domain).to eq(@rt.evaluate("y.domain()").to_a)
56
56
  end
57
57
 
58
58
  end
@@ -69,27 +69,27 @@ describe Rubyvis::Scale::Linear do
69
69
  @y = Rubyvis.Scale.linear(0, @h_dom).range(0,@h)
70
70
  end
71
71
  it "y should be a Scale" do
72
- @y.should be_a(Rubyvis::Scale::Linear)
72
+ expect(@y).to be_a(Rubyvis::Scale::Linear)
73
73
  end
74
74
  it "should respond to domain" do
75
- @y.domain.should==[0, 1000]
75
+ expect(@y.domain).to eq([0, 1000])
76
76
  @y.domain(1)
77
- @y.domain.should==[1,1]
77
+ expect(@y.domain).to eq([1,1])
78
78
  @y.domain(1,100,300)
79
- @y.domain.should==[1,100,300]
79
+ expect(@y.domain).to eq([1,100,300])
80
80
  end
81
81
  it "should respond to range" do
82
- @y.range.should==[0, 280]
82
+ expect(@y.range).to eq([0, 280])
83
83
  @y.range(1)
84
- @y.range.should==[1,1]
84
+ expect(@y.range).to eq([1,1])
85
85
  @y.range(1,100,300)
86
- @y.range.should==[1,100,300]
86
+ expect(@y.range).to eq([1,100,300])
87
87
  end
88
88
  it "should returns correct scale" do
89
- @y.scale(@h_dom).should==280
90
- @y[@h_dom].should==280
89
+ expect(@y.scale(@h_dom)).to eq(280)
90
+ expect(@y[@h_dom]).to eq(280)
91
91
  val=20
92
- @y.scale(val).should be_within( 0.001).of(val.quo(@h_dom)*@h.to_f)
92
+ expect(@y.scale(val)).to be_within( 0.001).of(val.quo(@h_dom)*@h.to_f)
93
93
  end
94
94
  it "should return correct scale when values are extracted from data " do
95
95
  data = pv.range(0, 10, 0.1).map {|x| OpenStruct.new({:x=> x, :y=> Math.sin(x) + 2+rand()}) }
@@ -97,44 +97,44 @@ describe Rubyvis::Scale::Linear do
97
97
  h = 200
98
98
  x = pv.Scale.linear(data, lambda {|d| d.x}).range(0, w)
99
99
  y = pv.Scale.linear(data, lambda {|d| d.y}).range(0, h)
100
- lambda {y.scale 0.5}.should_not raise_error
100
+ expect {y.scale 0.5}.not_to raise_error
101
101
  end
102
102
  it "should returns correct invert" do
103
- @y.invert(100).should be_within( 0.001).of(357.1428)
104
- @y.invert(200).should be_within( 0.001).of(714.2857)
103
+ expect(@y.invert(100)).to be_within( 0.001).of(357.1428)
104
+ expect(@y.invert(200)).to be_within( 0.001).of(714.2857)
105
105
  end
106
106
  it "should returns correct ticks" do
107
- @y.ticks.should==[0,100,200,300,400,500,600,700,800,900,1000]
108
- @y.ticks(13).should==[0,100,200,300,400,500,600,700,800,900,1000]
109
- @y.ticks(5).should==[0,200,400,600,800,1000]
107
+ expect(@y.ticks).to eq([0,100,200,300,400,500,600,700,800,900,1000])
108
+ expect(@y.ticks(13)).to eq([0,100,200,300,400,500,600,700,800,900,1000])
109
+ expect(@y.ticks(5)).to eq([0,200,400,600,800,1000])
110
110
  end
111
111
  it "should return correct tick when domain is a scalar" do
112
- @y.domain(1,1,1).ticks.should==[1]
112
+ expect(@y.domain(1,1,1).ticks).to eq([1])
113
113
  end
114
114
 
115
115
  it "should nice nicely" do
116
116
  @y.domain([0.20147987687960267, 0.996679553296417])
117
117
  @y.nice
118
- @y.domain().should==[0.2,1]
118
+ expect(@y.domain()).to eq([0.2,1])
119
119
  end
120
120
 
121
121
  it "should returns correct tick_format" do
122
- @y.tick_format.should be_instance_of Proc
123
- @y.tick_format.call( 2).should=='2'
124
- @y.tick_format.call(2.0).should=='2'
125
- @y.tick_format.call(2.1).should=='2.1'
126
- @y.tick_format.call("a").should==''
122
+ expect(@y.tick_format).to be_instance_of Proc
123
+ expect(@y.tick_format.call( 2)).to eq('2')
124
+ expect(@y.tick_format.call(2.0)).to eq('2')
125
+ expect(@y.tick_format.call(2.1)).to eq('2.1')
126
+ expect(@y.tick_format.call("a")).to eq('')
127
127
  end
128
128
  it "should return correct tick_format for small numbers" do
129
129
  @y.domain(0.00001,0.0001)
130
130
  @y.range(0.000001,0.0001)
131
- @y.ticks.should==[1.quo(100000), 1.quo(50000), 3.quo(100000), 1.quo(25000), 1.quo(20000), 3.quo(50000), 7.quo(100000), 1.quo(12500), 9.quo(100000), 1.quo(10000)]
132
- @y.tick_format.call(0.2).should=='0.20000'
131
+ expect(@y.ticks).to eq([1.quo(100000), 1.quo(50000), 3.quo(100000), 1.quo(25000), 1.quo(20000), 3.quo(50000), 7.quo(100000), 1.quo(12500), 9.quo(100000), 1.quo(10000)])
132
+ expect(@y.tick_format.call(0.2)).to eq('0.20000')
133
133
  end
134
134
  it "should return correct by" do
135
135
  by=@y.by(lambda {|v| v.value})
136
136
  a=OpenStruct.new({:value=>rand})
137
- by.call(a).should==@y[a.value]
137
+ expect(by.call(a)).to eq(@y[a.value])
138
138
  end
139
139
 
140
140
  end