googlecharts 1.6.8 → 1.6.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94b69525f188994f1689d2ba5014ca625662eee0
4
+ data.tar.gz: 856ca0857d23d0daf84a4bdbf9705a66963ff1ef
5
+ SHA512:
6
+ metadata.gz: 81edf88de45d3c7ef7dcd3fb2b23ab969e37617c51b6437f12d8a200ef6f7b510fc3e05fa436639b74aae004208d6b5406d3268abcdf7c2755f3e45e77f4b940
7
+ data.tar.gz: cda6cd7a28b7fdbe91f609fecd606c24acef7f4f355aa88feb6c4971a7fd0d5f888a08ae23b7f362931a41cfd8742c05e8fa4efe17b7e8139aacffffe1eb41e4
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
1
  .DS_Store
2
2
  log/*
3
3
  .manifest
4
- pkg
4
+ pkg
5
+ .rspec
6
+ .rvmrc
7
+ Gemfile.lock
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - ree
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
4
+ group :test do
5
+ gem 'rspec'
6
+ gem 'rake', '>= 0.8.7'
7
+ end
8
+
9
+
10
+
@@ -1,3 +1,9 @@
1
+ == 1.6.10
2
+ * added support for custom position on axis with label (parameter chxp)
3
+ * refactored bar chart
4
+ * fixed issue #44
5
+ * allows GChart to take a theme
6
+
1
7
  == 1.6.8
2
8
  * added title alignment support
3
9
 
@@ -1,3 +1,7 @@
1
+ ## Googlecharts
2
+
3
+ [![Build Status](https://travis-ci.org/mattetti/googlecharts.png?branch=master)](https://travis-ci.org/mattetti/googlecharts)
4
+
1
5
  The goal of this Gem is to make the creation of Google Charts a simple and easy task.
2
6
 
3
7
  require 'googlecharts'
@@ -291,6 +295,7 @@ Multi Lines Chart Sample :
291
295
 
292
296
  chart = Gchart.new( :type => 'line',
293
297
  :title => "example title",
298
+ :theme => :keynote,
294
299
  :data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]],
295
300
  :line_colors => 'e0440e,e62ae5,287eec',
296
301
  :legend => ['courbe 1','courbe 2','courbe 3'],
@@ -313,4 +318,4 @@ try yourself
313
318
  "http://chart.apis.google.com/chart?chs=300x200&chdl=matt|patrick&chd=s:AAANUIv,JENCN9y&chtt=SDRuby+Fu+level&chf=bg,lg,0,76A4FB,0,ffffff,1&cht=bvs&chco=ff0000,00ff00"
314
319
 
315
320
  Gchart.pie(:data => [20,10,15,5,50], :title => 'SDRuby Fu level', :size => '400x200', :labels => ['matt', 'rob', 'patrick', 'ryan', 'jordan'])
316
- http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
321
+ http://chart.apis.google.com/chart?cht=p&chs=400x200&chd=s:YMSG9&chtt=SDRuby+Fu+level&chl=matt|rob|patrick|ryan|jordan
data/Rakefile CHANGED
@@ -1 +1,12 @@
1
- require 'rubygems'
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc 'Default: run specs.'
4
+ task :default => :spec
5
+
6
+ desc "Run specs"
7
+ RSpec::Core::RakeTask.new do |task|
8
+ task.pattern = "**/spec/*_spec.rb"
9
+ task.rspec_opts = []
10
+ task.rspec_opts << '--color'
11
+ task.rspec_opts << '-f documentation'
12
+ end
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
6
6
  s.name = %q{googlecharts}
7
7
  s.version = GchartInfo::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Matt Aimonetti", "Andrey Deryabin"]
10
- s.date = %q{2011-05-21}
9
+ s.authors = ["Matt Aimonetti", "Andrey Deryabin", "Pedro Pimentel"]
10
+ s.date = %q{2014-12-15}
11
11
  s.summary = %q{Generate charts using Google API & Ruby}
12
12
  s.description = %q{Generate charts using Google API & Ruby}
13
- s.email = %q{mattaimonetti@gmail.com deriabin@gmail.com}
13
+ s.email = %q{mattaimonetti@gmail.com deriabin@gmail.com zukunft@gmail.com}
14
14
  s.homepage = %q{http://googlecharts.rubyforge.org/}
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
@@ -38,14 +38,14 @@ class Gchart
38
38
  'chart.png'
39
39
  end
40
40
 
41
- attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors,
42
- :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass,
41
+ attr_accessor :title, :type, :width, :height, :curved, :horizontal, :grouped, :overlapped, :legend, :legend_position, :labels, :data, :encoding, :bar_colors,
42
+ :title_color, :title_size, :title_alignment, :custom, :axis_with_labels, :custom_axis_with_labels, :axis_labels, :bar_width_and_spacing, :id, :alt, :klass,
43
43
  :range_markers, :geographical_area, :map_colors, :country_codes, :axis_range, :filename, :min, :max, :colors, :usemap
44
44
 
45
45
  attr_accessor :bg_type, :bg_color, :bg_angle, :chart_type, :chart_color, :chart_angle, :axis_range, :thickness, :new_markers, :grid_lines, :use_ssl
46
46
 
47
47
  attr_accessor :min_value, :max_value
48
-
48
+
49
49
  types.each do |type|
50
50
  instance_eval <<-DYNCLASSMETH
51
51
  def #{type}(options = {})
@@ -73,13 +73,21 @@ class Gchart
73
73
  end
74
74
 
75
75
  def initialize(options={})
76
+ # Allow Gchart to take a theme too
77
+ @theme = options[:theme]
78
+ options = @theme ? Chart::Theme.load(@theme).to_options.merge(options) : options
79
+ options.delete(:theme)
80
+
76
81
  @type = options[:type] || 'line'
77
82
  @data = []
78
83
  @width = 300
79
84
  @height = 200
80
85
  @curved = false
81
86
  @horizontal = false
87
+
82
88
  @grouped = false
89
+ @overlapped = false
90
+
83
91
  @use_ssl = false
84
92
  @encoding = 'simple'
85
93
  # @max_value = 'auto'
@@ -106,11 +114,11 @@ class Gchart
106
114
  def size=(size='300x200')
107
115
  @width, @height = size.split("x").map { |dimension| dimension.to_i }
108
116
  end
109
-
117
+
110
118
  def size
111
119
  "#{width}x#{height}"
112
120
  end
113
-
121
+
114
122
  def dimensions
115
123
  # TODO: maybe others?
116
124
  [:line_xy, :scatter].include?(type) ? 2 : 1
@@ -125,9 +133,14 @@ class Gchart
125
133
  end
126
134
  end
127
135
 
128
- # Sets the bar graph presentation (stacked or grouped)
129
- def stacked=(option=true)
130
- @grouped = option ? false : true
136
+ def bar_presentation
137
+ if @overlapped
138
+ 'o'
139
+ elsif @grouped
140
+ 'g'
141
+ else
142
+ 's'
143
+ end
131
144
  end
132
145
 
133
146
  def bg=(options)
@@ -149,7 +162,7 @@ class Gchart
149
162
  @chart_angle = options[:angle]
150
163
  end
151
164
  end
152
-
165
+
153
166
  def max_value=(max_v)
154
167
  if max_v =~ /false/
155
168
  @max_value = false
@@ -174,7 +187,7 @@ class Gchart
174
187
  ds.each_with_index do |mds, mds_index|
175
188
  mds[:min_value] ||= min_value
176
189
  mds[:max_value] ||= max_value
177
-
190
+
178
191
  if mds_index == 0 && type.to_s == 'bar'
179
192
  # TODO: unless you specify a zero line (using chp or chds),
180
193
  # the min_value of a bar chart is always 0.
@@ -235,7 +248,7 @@ class Gchart
235
248
  @dataset
236
249
  end
237
250
  end
238
-
251
+
239
252
  # Sets of data to handle multiple sets
240
253
  def datasets
241
254
  datasets = []
@@ -248,7 +261,7 @@ class Gchart
248
261
  end
249
262
  datasets
250
263
  end
251
-
264
+
252
265
  def self.jstize(string)
253
266
  # See http://github.com/mattetti/googlecharts/issues#issue/27
254
267
  #URI.escape( string ).gsub("%7C", "|")
@@ -313,7 +326,7 @@ class Gchart
313
326
  # The title size cannot be set without specifying a color.
314
327
  # A dark key will be used for the title color if no color is specified
315
328
  def set_title
316
- title_params = "chtt=#{title}"
329
+ title_params = "chtt=#{title}".gsub(/\|/,"\n")
317
330
  unless (title_color.nil? && title_size.nil? && title_alignment.nil?)
318
331
  title_params << "&chts=" + (color, size, alignment = (title_color || '454545'), title_size, (title_alignment.to_s[0,1] || 'c')).compact.join(',')
319
332
  end
@@ -460,6 +473,11 @@ class Gchart
460
473
  "chxt=#{axis_with_labels}"
461
474
  end
462
475
 
476
+ def set_custom_axis_with_labels
477
+ @custom_axis_with_labels = custom_axis_with_labels.join(',') if @custom_axis_with_labels.is_a?(Array)
478
+ "chxp=#{custom_axis_with_labels}"
479
+ end
480
+
463
481
  def set_axis_labels
464
482
  if axis_labels.is_a?(Array)
465
483
  if RUBY_VERSION.to_f < 1.9
@@ -519,7 +537,7 @@ class Gchart
519
537
  when 'radar'
520
538
  "r" + (curved? ? 's' : '')
521
539
  when 'bar'
522
- "b" + (horizontal? ? "h" : "v") + (grouped? ? "g" : "s")
540
+ "b" + (horizontal? ? "h" : "v") + bar_presentation
523
541
  end
524
542
  end
525
543
 
@@ -530,7 +548,7 @@ class Gchart
530
548
  when 'stripes' then 'ls'
531
549
  end
532
550
  end
533
-
551
+
534
552
  def number_visible
535
553
  n = 0
536
554
  dataset.each do |mds|
@@ -543,7 +561,7 @@ class Gchart
543
561
  end
544
562
  ""
545
563
  end
546
-
564
+
547
565
  # Turns input into an array of axis hashes, dependent on the chart type
548
566
  def convert_dataset(ds)
549
567
  if dimensions == 2
@@ -563,7 +581,7 @@ class Gchart
563
581
  end
564
582
  ds
565
583
  end
566
-
584
+
567
585
  # just an alias
568
586
  def axis_set
569
587
  dataset
@@ -577,7 +595,7 @@ class Gchart
577
595
  value.nil? ? "_" : value
578
596
  end
579
597
  end
580
-
598
+
581
599
  def convert_to_extended_value(number)
582
600
  if number.nil?
583
601
  '__'
@@ -586,7 +604,7 @@ class Gchart
586
604
  value.nil? ? "__" : value
587
605
  end
588
606
  end
589
-
607
+
590
608
  def encode_scaled_dataset(chars, nil_char)
591
609
  dsets = []
592
610
  dataset.each do |ds|
@@ -655,6 +673,7 @@ class Gchart
655
673
  def query_builder(options="")
656
674
  query_params = instance_variables.sort.map do |var|
657
675
  case var.to_s
676
+
658
677
  when '@data'
659
678
  set_data unless data == []
660
679
  # Set the graph size
@@ -673,7 +692,7 @@ class Gchart
673
692
  when '@thickness'
674
693
  set_line_thickness
675
694
  when '@new_markers'
676
- set_line_markers
695
+ set_line_markers
677
696
  when '@bg_color'
678
697
  set_colors
679
698
  when '@chart_color'
@@ -690,6 +709,8 @@ class Gchart
690
709
  set_range_markers
691
710
  when '@grid_lines'
692
711
  set_grid_lines
712
+ when '@custom_axis_with_labels'
713
+ set_custom_axis_with_labels
693
714
  when '@geographical_area'
694
715
  set_geographical_area
695
716
  when '@country_codes'
@@ -9,7 +9,6 @@ class Gchart
9
9
  alias_method :line_color=, :bar_colors=
10
10
  alias_method :slice_colors=, :bar_colors=
11
11
  alias_method :horizontal?, :horizontal
12
- alias_method :grouped?, :grouped
13
12
  alias_method :curved?, :curved
14
13
 
15
14
  end
@@ -1,3 +1,3 @@
1
1
  module GchartInfo #:nodoc:
2
- VERSION = "1.6.8"
2
+ VERSION = "1.6.10"
3
3
  end
@@ -7,11 +7,16 @@ Chart::Theme.add_theme_file("#{File.dirname(__FILE__)}/fixtures/test_theme.yml")
7
7
  # http://rspec.rubyforge.org/
8
8
  describe "The Gchart class" do
9
9
  it "should show supported_types on error" do
10
- Gchart.supported_types.should match(/line/)
10
+ expect(Gchart.supported_types).to match(/line/)
11
11
  end
12
12
 
13
13
  it "should return supported types" do
14
- Gchart.types.include?('line').should be_true
14
+ expect(Gchart.types).to include('line')
15
+ end
16
+
17
+ it "should support theme option" do
18
+ chart = Gchart.new(:type => 'line',:theme => :test)
19
+ expect(chart.send('url')).to include('chco=6886B4,FDD84E')
15
20
  end
16
21
  end
17
22
 
@@ -21,121 +26,122 @@ describe "generating a default Gchart" do
21
26
  @chart = Gchart.line
22
27
  end
23
28
 
29
+ it "should create a line break when a pipe character is encountered" do
30
+ @chart = Gchart.line(:title => "title|subtitle")
31
+ expect(@chart).to include("chtt=title\nsubtitle")
32
+ end
33
+
24
34
  it "should include the Google URL" do
25
- @chart.include?("http://chart.apis.google.com/chart?").should be_true
35
+ expect(@chart).to include("http://chart.apis.google.com/chart?")
26
36
  end
27
37
 
28
38
  it "should have a default size" do
29
- @chart.should include('chs=300x200')
39
+ expect(@chart).to include('chs=300x200')
30
40
  end
31
41
 
32
42
  it "should be able to have a custom size" do
33
- Gchart.line(:size => '400x600').include?('chs=400x600').should be_true
34
- Gchart.line(:width => 400, :height => 600).include?('chs=400x600').should be_true
43
+ expect(Gchart.line(:size => '400x600')).to include('chs=400x600')
44
+ expect(Gchart.line(:width => 400, :height => 600)).to include('chs=400x600')
35
45
  end
36
46
 
37
47
  it "should have query parameters in predictable order" do
38
- Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600').should match(/chxt=.+cht=.+chs=/)
48
+ expect(Gchart.line(:axis_with_labels => 'x,y,r', :size => '400x600')).to match(/chxt=.+cht=.+chs=/)
39
49
  end
40
50
 
41
51
  it "should have a type" do
42
- @chart.include?('cht=lc').should be_true
52
+ expect(@chart).to include('cht=lc')
43
53
  end
44
54
 
45
55
  it 'should use theme defaults if theme is set' do
46
- Gchart.line(:theme=>:test).should include('chco=6886B4,FDD84E')
47
- if RUBY_VERSION.to_f < 1.9
48
- Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=c,s,FFFFFF|bg,s,FFFFFF'))
49
- else
50
- Gchart.line(:theme=>:test).should include(Gchart.jstize('chf=bg,s,FFFFFF|c,s,FFFFFF'))
51
- end
56
+ expect(Gchart.line(:theme=>:test)).to include('chco=6886B4,FDD84E')
57
+ expect(Gchart.line(:theme=>:test)).to match(/chf=(c,s,FFFFFF\|bg,s,FFFFFF|bg,s,FFFFFF\|c,s,FFFFFF)/)
52
58
  end
53
59
 
54
60
  it "should use the simple encoding by default with auto max value" do
55
61
  # 9 is the max value in simple encoding, 26 being our max value the 2nd encoded value should be 9
56
- Gchart.line(:data => [0, 26]).should include('chd=s:A9')
57
- Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y').should include('chxr=0,0,26')
62
+ expect(Gchart.line(:data => [0, 26])).to include('chd=s:A9')
63
+ expect(Gchart.line(:data => [0, 26], :max_value => 26, :axis_with_labels => 'y')).to include('chxr=0,0,26')
58
64
  end
59
65
 
60
66
  it "should support simple encoding with and without max_value" do
61
- Gchart.line(:data => [0, 26], :max_value => 26).should include('chd=s:A9')
62
- Gchart.line(:data => [0, 26], :max_value => false).should include('chd=s:Aa')
67
+ expect(Gchart.line(:data => [0, 26], :max_value => 26)).to include('chd=s:A9')
68
+ expect(Gchart.line(:data => [0, 26], :max_value => false)).to include('chd=s:Aa')
63
69
  end
64
70
 
65
71
  it "should support the extended encoding and encode properly" do
66
- Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false).include?('chd=e:AA').should be_true
67
- Gchart.line(:encoding => 'extended',
72
+ expect(Gchart.line(:data => [0, 10], :encoding => 'extended', :max_value => false)).to include('chd=e:AA')
73
+ expect(Gchart.line(:encoding => 'extended',
68
74
  :max_value => false,
69
75
  :data => [[0,25,26,51,52,61,62,63], [64,89,90,115,4084]]
70
- ).include?('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0').should be_true
76
+ )).to include('chd=e:AAAZAaAzA0A9A-A.,BABZBaBz.0')
71
77
  end
72
78
 
73
79
  it "should auto set the max value for extended encoding" do
74
- Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false).should include('chd=e:AAAZ')
80
+ expect(Gchart.line(:data => [0, 25], :encoding => 'extended', :max_value => false)).to include('chd=e:AAAZ')
75
81
  # Extended encoding max value is '..'
76
- Gchart.line(:data => [0, 25], :encoding => 'extended').include?('chd=e:AA..').should be_true
82
+ expect(Gchart.line(:data => [0, 25], :encoding => 'extended')).to include('chd=e:AA..')
77
83
  end
78
84
 
79
85
  it "should be able to have data with text encoding" do
80
- Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,4,45,78')
86
+ expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,4,45,78')
81
87
  end
82
88
 
83
89
  it "should be able to have missing data points with text encoding" do
84
- Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text').should include('chd=t:10,5.2,_,45,78')
90
+ expect(Gchart.line(:data => [10, 5.2, nil, 45, 78], :encoding => 'text')).to include('chd=t:10,5.2,_,45,78')
85
91
  end
86
92
 
87
93
  it "should handle max and min values with text encoding" do
88
- Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=0,78')
94
+ expect(Gchart.line(:data => [10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=0,78')
89
95
  end
90
96
 
91
97
  it "should automatically handle negative values with proper max/min limits when using text encoding" do
92
- Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text').should include('chds=-10,78')
98
+ expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text')).to include('chds=-10,78')
93
99
  end
94
100
 
95
101
  it "should handle negative values with manual max/min limits when using text encoding" do
96
- Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100).include?('chds=-20,100').should be_true
102
+ expect(Gchart.line(:data => [-10, 5.2, 4, 45, 78], :encoding => 'text', :min_value => -20, :max_value => 100)).to include('chds=-20,100')
97
103
  end
98
104
 
99
105
  it "should set the proper axis values when using text encoding and negative values" do
100
- Gchart.bar( :data => [[-10], [100]],
106
+ expect(Gchart.bar( :data => [[-10], [100]],
101
107
  :encoding => 'text',
102
108
  :horizontal => true,
103
109
  :min_value => -20,
104
110
  :max_value => 100,
105
111
  :axis_with_labels => 'x',
106
- :bar_colors => ['FD9A3B', '4BC7DC']).should include("chxr=0,-20,100")
112
+ :bar_colors => ['FD9A3B', '4BC7DC'])).to include("chxr=0,-20,100")
107
113
  end
108
114
 
109
115
  it "should be able to have multiple set of data with text encoding" do
110
- Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text').include?(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99')).should be_true
116
+ expect(Gchart.line(:data => [[10, 5.2, 4, 45, 78], [20, 40, 70, 15, 99]], :encoding => 'text')).to include(Gchart.jstize('chd=t:10,5.2,4,45,78|20,40,70,15,99'))
111
117
  end
112
118
 
113
119
  it "should be able to receive a custom param" do
114
- Gchart.line(:custom => 'ceci_est_une_pipe').include?('ceci_est_une_pipe').should be_true
120
+ expect(Gchart.line(:custom => 'ceci_est_une_pipe')).to include('ceci_est_une_pipe')
115
121
  end
116
122
 
117
123
  it "should be able to set label axis" do
118
- Gchart.line(:axis_with_labels => 'x,y,r').include?('chxt=x,y,r').should be_true
119
- Gchart.line(:axis_with_labels => ['x','y','r']).include?('chxt=x,y,r').should be_true
124
+ expect(Gchart.line(:axis_with_labels => 'x,y,r')).to include('chxt=x,y,r')
125
+ expect(Gchart.line(:axis_with_labels => ['x','y','r'])).to include('chxt=x,y,r')
120
126
  end
121
127
 
122
128
  it "should be able to have axis labels" do
123
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true
124
- Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan']).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true
125
- Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true
126
- Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true
129
+ expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan', '0|100', 'A|B|C', '2005|2006|2007'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007'))
130
+ expect(Gchart.line(:axis_labels => ['Jan|July|Jan|July|Jan'])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan'))
131
+ expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan'))
132
+ expect(Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']])).to include(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007'))
127
133
  end
128
-
134
+
129
135
  def labeled_line(options = {})
130
136
  Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options))
131
137
  end
132
138
 
133
139
  it "should display ranges properly" do
134
140
  @data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]
135
- labeled_line(:axis_labels => [((1..24).to_a << 1)]).
136
- should include('chxr=0,85,672')
141
+ expect(labeled_line(:axis_labels => [((1..24).to_a << 1)])).
142
+ to include('chxr=0,85,672')
137
143
  end
138
-
144
+
139
145
  def labeled_bar(options = {})
140
146
  Gchart.bar({:data => @data,
141
147
  :axis_with_labels => 'x,y',
@@ -146,117 +152,115 @@ describe "generating a default Gchart" do
146
152
 
147
153
  it "should force the y range properly" do
148
154
  @data = [1,1,1,1,1,1,1,1,6,2,1,1]
149
- labeled_bar(
155
+ expect(labeled_bar(
150
156
  :axis_range => [[0,0],[0,16]]
151
- ).should include('chxr=0,0,0|1,0,16')
152
- labeled_bar(
157
+ )).to include('chxr=0,0,0|1,0,16')
158
+ expect(labeled_bar(
153
159
  :max_value => 16,
154
160
  :axis_range => [[0,0],[0,16]]
155
- ).should include('chxr=0,0,16|1,0,16')
161
+ )).to include('chxr=0,0,16|1,0,16')
156
162
 
157
163
  # nil means ignore axis
158
- labeled_bar(
164
+ expect(labeled_bar(
159
165
  :axis_range => [nil,[0,16]]
160
- ).should include('chxr=1,0,16')
166
+ )).to include('chxr=1,0,16')
161
167
 
162
168
  # empty array means take defaults
163
- labeled_bar(
169
+ expect(labeled_bar(
164
170
  :max_value => 16,
165
171
  :axis_range => [[],[0,16]]
166
- ).should include('chxr=0,0,16|1,0,16')
167
- labeled_bar(
172
+ )).to include('chxr=0,0,16|1,0,16')
173
+ expect(labeled_bar(
168
174
  :axis_range => [[],[0,16]]
169
- ).should include('chxr=0,0|1,0,16')
175
+ )).to include('chxr=0,0|1,0,16')
170
176
 
171
- Gchart.line(
177
+ expect(Gchart.line(
172
178
  :data => [0,20, 40, 60, 140, 230, 60],
173
- :axis_with_labels => 'y').should include("chxr=0,0,230")
179
+ :axis_with_labels => 'y')).to include("chxr=0,0,230")
174
180
  end
175
-
181
+
176
182
  it "should take in consideration the max value when creating a range" do
177
183
  data = [85,107,123,131,155,172,173,189,203,222,217,233,250,239,256,267,247,261,275,295,288,305,322,307,325,347,331,346,363,382,343,359,383,352,374,393,358,379,396,416,377,398,419,380,409,426,453,432,452,465,436,460,480,440,457,474,501,457,489,507,347,373,413,402,424,448,475,488,513,475,507,530,440,476,500,518,481,512,531,367,396,423,387,415,446,478,442,469,492,463,489,508,463,491,518,549,503,526,547,493,530,549,493,520,541,564,510,535,564,492,512,537,502,530,548,491,514,538,568,524,548,568,512,533,552,577,520,545,570,516,536,555,514,536,566,521,553,579,604,541,569,595,551,581,602,549,576,606,631,589,615,650,597,624,646,672,605,626,654,584,608,631,574,597,622,559,591,614,644,580,603,629,584,615,631,558,591,618,641,314,356,395,397,429,450,421,454,477,507,458,490,560,593]
178
184
  url = Gchart.line(:data => data, :axis_with_labels => 'x,y', :axis_labels => [((1..24).to_a << 1)], :max_value => 700)
179
- url.should include('chxr=0,85,700')
185
+ expect(url).to include('chxr=0,85,700')
180
186
  end
181
-
187
+
182
188
  it 'should generate different labels and legend' do
183
- Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three'))
189
+ expect(Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three))).to(include('chdl=1|2|3') && include('chl=one|two|three'))
184
190
  end
185
-
186
191
  end
187
192
 
188
193
  describe "generating different type of charts" do
189
194
 
190
195
  it "should be able to generate a line chart" do
191
- Gchart.line.should be_an_instance_of(String)
192
- Gchart.line.include?('cht=lc').should be_true
196
+ expect(Gchart.line).to be_an_instance_of(String)
197
+ expect(Gchart.line).to include('cht=lc')
193
198
  end
194
199
 
195
200
  it "should be able to generate a sparkline chart" do
196
- Gchart.sparkline.should be_an_instance_of(String)
197
- Gchart.sparkline.include?('cht=ls').should be_true
201
+ expect(Gchart.sparkline).to be_an_instance_of(String)
202
+ expect(Gchart.sparkline).to include('cht=ls')
198
203
  end
199
204
 
200
205
  it "should be able to generate a line xy chart" do
201
- Gchart.line_xy.should be_an_instance_of(String)
202
- Gchart.line_xy.include?('cht=lxy').should be_true
206
+ expect(Gchart.line_xy).to be_an_instance_of(String)
207
+ expect(Gchart.line_xy).to include('cht=lxy')
203
208
  end
204
209
 
205
210
  it "should be able to generate a scatter chart" do
206
- Gchart.scatter.should be_an_instance_of(String)
207
- Gchart.scatter.include?('cht=s').should be_true
211
+ expect(Gchart.scatter).to be_an_instance_of(String)
212
+ expect(Gchart.scatter).to include('cht=s')
208
213
  end
209
214
 
210
215
  it "should be able to generate a bar chart" do
211
- Gchart.bar.should be_an_instance_of(String)
212
- Gchart.bar.include?('cht=bvs').should be_true
216
+ expect(Gchart.bar).to be_an_instance_of(String)
217
+ expect(Gchart.bar).to include('cht=bvs')
213
218
  end
214
219
 
215
220
  it "should be able to generate a Venn diagram" do
216
- Gchart.venn.should be_an_instance_of(String)
217
- Gchart.venn.include?('cht=v').should be_true
221
+ expect(Gchart.venn).to be_an_instance_of(String)
222
+ expect(Gchart.venn).to include('cht=v')
218
223
  end
219
224
 
220
225
  it "should be able to generate a Pie Chart" do
221
- Gchart.pie.should be_an_instance_of(String)
222
- Gchart.pie.include?('cht=p').should be_true
226
+ expect(Gchart.pie).to be_an_instance_of(String)
227
+ expect(Gchart.pie).to include('cht=p')
223
228
  end
224
229
 
225
230
  it "should be able to generate a Google-O-Meter" do
226
- Gchart.meter.should be_an_instance_of(String)
227
- Gchart.meter.include?('cht=gom').should be_true
231
+ expect(Gchart.meter).to be_an_instance_of(String)
232
+ expect(Gchart.meter).to include('cht=gom')
228
233
  end
229
234
 
230
235
  it "should be able to generate a map chart" do
231
- Gchart.map.should be_an_instance_of(String)
232
- Gchart.map.include?('cht=t').should be_true
236
+ expect(Gchart.map).to be_an_instance_of(String)
237
+ expect(Gchart.map).to include('cht=t')
233
238
  end
234
239
 
235
240
  it "should not support other types" do
236
241
  msg = "sexy is not a supported chart format. Please use one of the following: #{Gchart.supported_types}."
237
- lambda{Gchart.sexy}.should raise_error(NoMethodError)
242
+ expect{Gchart.sexy}.to raise_error(NoMethodError)
238
243
  end
239
-
240
244
  end
241
245
 
242
246
 
243
247
  describe "range markers" do
244
248
 
245
249
  it "should be able to generate given a hash of range-marker options" do
246
- Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'}).include?('chm=r,ff0000,0,0.59,0.61').should be_true
250
+ expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'})).to include('chm=r,ff0000,0,0.59,0.61')
247
251
  end
248
252
 
249
253
  it "should be able to generate given an array of range-marker hash options" do
250
- Gchart.line(:range_markers => [
254
+ expect(Gchart.line(:range_markers => [
251
255
  {:start_position => 0.59, :stop_position => 0.61, :color => 'ff0000'},
252
256
  {:start_position => 0, :stop_position => 0.6, :color => '666666'},
253
257
  {:color => 'cccccc', :start_position => 0.6, :stop_position => 1}
254
- ]).include?(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1')).should be_true
258
+ ])).to include(Gchart.jstize('r,ff0000,0,0.59,0.61|r,666666,0,0,0.6|r,cccccc,0,0.6,1'))
255
259
  end
256
260
 
257
261
  it "should allow a :overlaid? to be set" do
258
- Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true}).include?('chm=r,ffffff,0,0.59,0.61,1').should be_true
259
- Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false}).include?('chm=r,ffffff,0,0.59,0.61').should be_true
262
+ expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => true})).to include('chm=r,ffffff,0,0.59,0.61,1')
263
+ expect(Gchart.line(:range_markers => {:start_position => 0.59, :stop_position => 0.61, :color => 'ffffff', :overlaid? => false})).to include('chm=r,ffffff,0,0.59,0.61')
260
264
  end
261
265
 
262
266
  describe "when setting the orientation option" do
@@ -265,75 +269,76 @@ describe "range markers" do
265
269
  end
266
270
 
267
271
  it "to vertical (R) if given a valid option" do
268
- Gchart.line(:range_markers => @options.merge(:orientation => 'v')).include?('chm=R').should be_true
269
- Gchart.line(:range_markers => @options.merge(:orientation => 'V')).include?('chm=R').should be_true
270
- Gchart.line(:range_markers => @options.merge(:orientation => 'R')).include?('chm=R').should be_true
271
- Gchart.line(:range_markers => @options.merge(:orientation => 'vertical')).include?('chm=R').should be_true
272
- Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical')).include?('chm=R').should be_true
272
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'v'))).to include('chm=R')
273
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'V'))).to include('chm=R')
274
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'R'))).to include('chm=R')
275
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'vertical'))).to include('chm=R')
276
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'Vertical'))).to include('chm=R')
273
277
  end
274
278
 
275
279
  it "to horizontal (r) if given a valid option (actually anything other than the vertical options)" do
276
- Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal')).include?('chm=r').should be_true
277
- Gchart.line(:range_markers => @options.merge(:orientation => 'h')).include?('chm=r').should be_true
278
- Gchart.line(:range_markers => @options.merge(:orientation => 'etc')).include?('chm=r').should be_true
280
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'horizontal'))).to include('chm=r')
281
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'h'))).to include('chm=r')
282
+ expect(Gchart.line(:range_markers => @options.merge(:orientation => 'etc'))).to include('chm=r')
279
283
  end
280
284
 
281
285
  it "if left blank defaults to horizontal (r)" do
282
- Gchart.line(:range_markers => @options).include?('chm=r').should be_true
286
+ expect(Gchart.line(:range_markers => @options)).to include('chm=r')
283
287
  end
284
288
  end
285
-
286
289
  end
287
290
 
288
291
 
289
292
  describe "a bar graph" do
290
293
 
291
294
  it "should have a default vertical orientation" do
292
- Gchart.bar.include?('cht=bvs').should be_true
295
+ expect(Gchart.bar).to include('cht=bvs')
293
296
  end
294
297
 
295
298
  it "should be able to have a different orientation" do
296
- Gchart.bar(:orientation => 'vertical').include?('cht=bvs').should be_true
297
- Gchart.bar(:orientation => 'v').include?('cht=bvs').should be_true
298
- Gchart.bar(:orientation => 'h').include?('cht=bhs').should be_true
299
- Gchart.bar(:orientation => 'horizontal').include?('cht=bhs').should be_true
300
- Gchart.bar(:horizontal => false).include?('cht=bvs').should be_true
299
+ expect(Gchart.bar(:orientation => 'vertical')).to include('cht=bvs')
300
+ expect(Gchart.bar(:orientation => 'v')).to include('cht=bvs')
301
+ expect(Gchart.bar(:orientation => 'h')).to include('cht=bhs')
302
+ expect(Gchart.bar(:orientation => 'horizontal')).to include('cht=bhs')
303
+ expect(Gchart.bar(:horizontal => false)).to include('cht=bvs')
301
304
  end
302
305
 
303
306
  it "should be set to be stacked by default" do
304
- Gchart.bar.include?('cht=bvs').should be_true
307
+ expect(Gchart.bar).to include('cht=bvs')
305
308
  end
306
309
 
307
- it "should be able to stacked or grouped" do
308
- Gchart.bar(:stacked => true).include?('cht=bvs').should be_true
309
- Gchart.bar(:stacked => false).include?('cht=bvg').should be_true
310
- Gchart.bar(:grouped => true).include?('cht=bvg').should be_true
311
- Gchart.bar(:grouped => false).include?('cht=bvs').should be_true
310
+ it "should be able to stacked, grouped or overlapped" do
311
+ expect(Gchart.bar(:stacked => true)).to include('cht=bvs')
312
+ expect(Gchart.bar(:stacked => false)).to include('cht=bvs')
313
+ expect(Gchart.bar(:grouped => true)).to include('cht=bvg')
314
+ expect(Gchart.bar(:grouped => false)).to include('cht=bvs')
315
+ expect(Gchart.bar(:overlapped => true)).to include('cht=bvo')
316
+ expect(Gchart.bar(:overlapped => false)).to include('cht=bvs')
312
317
  end
313
318
 
314
319
  it "should be able to have different bar colors" do
315
- Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=').should be_true
316
- Gchart.bar(:bar_colors => 'efefef,00ffff').include?('chco=efefef,00ffff').should be_true
320
+ expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=')
321
+ expect(Gchart.bar(:bar_colors => 'efefef,00ffff')).to include('chco=efefef,00ffff')
317
322
  # alias
318
- Gchart.bar(:bar_color => 'efefef').include?('chco=efefef').should be_true
323
+ expect(Gchart.bar(:bar_color => 'efefef')).to include('chco=efefef')
319
324
  end
320
325
 
321
326
  it "should be able to have different bar colors when using an array of colors" do
322
- Gchart.bar(:bar_colors => ['efefef','00ffff']).include?('chco=efefef,00ffff').should be_true
327
+ expect(Gchart.bar(:bar_colors => ['efefef','00ffff'])).to include('chco=efefef,00ffff')
323
328
  end
324
329
 
325
330
  it 'should be able to accept a string of width and spacing options' do
326
- Gchart.bar(:bar_width_and_spacing => '25,6').include?('chbh=25,6').should be_true
331
+ expect(Gchart.bar(:bar_width_and_spacing => '25,6')).to include('chbh=25,6')
327
332
  end
328
333
 
329
334
  it 'should be able to accept a single fixnum width and spacing option to set the bar width' do
330
- Gchart.bar(:bar_width_and_spacing => 25).include?('chbh=25').should be_true
335
+ expect(Gchart.bar(:bar_width_and_spacing => 25)).to include('chbh=25')
331
336
  end
332
337
 
333
338
  it 'should be able to accept an array of width and spacing options' do
334
- Gchart.bar(:bar_width_and_spacing => [25,6,12]).include?('chbh=25,6,12').should be_true
335
- Gchart.bar(:bar_width_and_spacing => [25,6]).include?('chbh=25,6').should be_true
336
- Gchart.bar(:bar_width_and_spacing => [25]).include?('chbh=25').should be_true
339
+ expect(Gchart.bar(:bar_width_and_spacing => [25,6,12])).to include('chbh=25,6,12')
340
+ expect(Gchart.bar(:bar_width_and_spacing => [25,6])).to include('chbh=25,6')
341
+ expect(Gchart.bar(:bar_width_and_spacing => [25])).to include('chbh=25')
337
342
  end
338
343
 
339
344
  describe "with a hash of width and spacing options" do
@@ -345,19 +350,36 @@ describe "a bar graph" do
345
350
  end
346
351
 
347
352
  it 'should be able to have a custom bar width' do
348
- Gchart.bar(:bar_width_and_spacing => {:width => 19}).include?("chbh=19,#{@default_spacing},#{@default_group_spacing}").should be_true
353
+ expect(Gchart.bar(:bar_width_and_spacing => {:width => 19})).to include("chbh=19,#{@default_spacing},#{@default_group_spacing}")
349
354
  end
350
355
 
351
356
  it 'should be able to have custom spacing' do
352
- Gchart.bar(:bar_width_and_spacing => {:spacing => 19}).include?("chbh=#{@default_width},19,#{@default_group_spacing}").should be_true
357
+ expect(Gchart.bar(:bar_width_and_spacing => {:spacing => 19})).to include("chbh=#{@default_width},19,#{@default_group_spacing}")
353
358
  end
354
359
 
355
360
  it 'should be able to have custom group spacing' do
356
- Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19}).include?("chbh=#{@default_width},#{@default_spacing},19").should be_true
361
+ expect(Gchart.bar(:bar_width_and_spacing => {:group_spacing => 19})).to include("chbh=#{@default_width},#{@default_spacing},19")
357
362
  end
363
+ end
364
+ end
365
+
366
+ describe "a radar chart" do
367
+
368
+ before(:each) do
369
+ @chart = Gchart.radar(:title => 'Chart Title')
370
+ end
358
371
 
372
+ it "should be able have a chart title" do
373
+ expect(@chart).to include("chtt=Chart+Title")
359
374
  end
360
375
 
376
+ it "should allow axis labels positions to be used" do
377
+ expect(Gchart.radar(:custom_axis_with_labels => '0,0,50,100')).to include('chxp=0,0,50,100')
378
+ end
379
+
380
+ it "should allow array of axis labels positions to be used " do
381
+ expect(Gchart.radar(:custom_axis_with_labels => ['0', '0', '50', '100'])).to include('chxp=0,0,50,100')
382
+ end
361
383
  end
362
384
 
363
385
  describe "a line chart" do
@@ -369,80 +391,73 @@ describe "a line chart" do
369
391
  end
370
392
 
371
393
  it 'should be able have a chart title' do
372
- @chart.include?("chtt=Chart+Title").should be_true
394
+ expect(@chart).to include("chtt=Chart+Title")
373
395
  end
374
396
 
375
397
  it "should be able to a custom color, size and alignment for title" do
376
- Gchart.line(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true
377
- Gchart.line(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true
378
- Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left).include?('chts=454545,20,l').should be_true
398
+ expect(Gchart.line(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000')
399
+ expect(Gchart.line(:title => @title, :title_size => '20')).to include('chts=454545,20')
400
+ expect(Gchart.line(:title => @title, :title_size => '20', :title_alignment => :left)).to include('chts=454545,20,l')
379
401
  end
380
402
 
381
403
  it "should be able to have multiple legends" do
382
- @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true
404
+ expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label"))
383
405
  end
384
406
 
385
407
  it "should escape text values in url" do
386
408
  title = 'Chart & Title'
387
409
  legend = ['first data & set label', 'n data set label']
388
410
  chart = Gchart.line(:title => title, :legend => legend)
389
- chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true
411
+ expect(chart).to include(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label"))
390
412
  end
391
413
 
392
414
  it "should be able to have one legend" do
393
415
  chart = Gchart.line(:legend => 'legend label')
394
- chart.include?("chdl=legend+label").should be_true
416
+ expect(chart).to include("chdl=legend+label")
395
417
  end
396
-
418
+
397
419
  it "should be able to set the position of the legend" do
398
420
  title = 'Chart & Title'
399
421
  legend = ['first data & set label', 'n data set label']
400
-
422
+
401
423
  chart = Gchart.line(:title => title, :legend => legend, :legend_position => :bottom_vertical)
402
- chart.include?("chdlp=bv").should be_true
403
-
424
+ expect(chart).to include("chdlp=bv")
425
+
404
426
  chart = Gchart.line(:title => title, :legend => legend, :legend_position => 'r')
405
- chart.include?("chdlp=r").should be_true
427
+ expect(chart).to include("chdlp=r")
406
428
  end
407
429
 
408
430
  it "should be able to set the background fill" do
409
- Gchart.line(:bg => 'efefef').should include("chf=bg,s,efefef")
410
- Gchart.line(:bg => {:color => 'efefef', :type => 'solid'}).should include("chf=bg,s,efefef")
431
+ expect(Gchart.line(:bg => 'efefef')).to include("chf=bg,s,efefef")
432
+ expect(Gchart.line(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef")
411
433
 
412
- Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1")
413
- Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).should include("chf=bg,lg,0,efefef,0,ffffff,1")
414
- Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).should include("chf=bg,lg,90,efefef,0,ffffff,1")
434
+ expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
435
+ expect(Gchart.line(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
436
+ expect(Gchart.line(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1")
415
437
 
416
- Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'}).should include("chf=bg,ls,90,efefef,0.2,ffffff,0.2")
438
+ expect(Gchart.line(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2")
417
439
  end
418
440
 
419
441
  it "should be able to set a graph fill" do
420
- Gchart.line(:graph_bg => 'efefef').should include("chf=c,s,efefef")
421
- Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true
422
- Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
423
- Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
424
- Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true
442
+ expect(Gchart.line(:graph_bg => 'efefef')).to include("chf=c,s,efefef")
443
+ expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef")
444
+ expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
445
+ expect(Gchart.line(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
446
+ expect(Gchart.line(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1")
425
447
  end
426
448
 
427
449
  it "should be able to set both a graph and a background fill" do
428
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true
429
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
430
- if RUBY_VERSION.to_f < 1.9
431
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
432
- else
433
- Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true
434
- end
450
+ expect(Gchart.line(:bg => 'efefef', :graph_bg => '76A4FB')).to match /chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/
435
451
  end
436
452
 
437
453
  it "should be able to have different line colors" do
438
- Gchart.line(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
439
- Gchart.line(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
454
+ expect(Gchart.line(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
455
+ expect(Gchart.line(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
440
456
  end
441
457
 
442
458
  it "should be able to render a graph where all the data values are 0" do
443
- Gchart.line(:data => [0, 0, 0]).should include("chd=s:AAA")
459
+ expect(Gchart.line(:data => [0, 0, 0])).to include("chd=s:AAA")
444
460
  end
445
-
446
461
  end
447
462
 
448
463
  describe "a sparkline chart" do
@@ -456,61 +471,54 @@ describe "a sparkline chart" do
456
471
  end
457
472
 
458
473
  it "should create a sparkline" do
459
- @chart.include?('cht=ls').should be_true
474
+ expect(@chart).to include('cht=ls')
460
475
  end
461
476
 
462
477
  it 'should be able have a chart title' do
463
- @chart.include?("chtt=Chart+Title").should be_true
478
+ expect(@chart).to include("chtt=Chart+Title")
464
479
  end
465
480
 
466
481
  it "should be able to a custom color and size title" do
467
- Gchart.sparkline(:title => @title, :title_color => 'FF0000').include?('chts=FF0000').should be_true
468
- Gchart.sparkline(:title => @title, :title_size => '20').include?('chts=454545,20').should be_true
482
+ expect(Gchart.sparkline(:title => @title, :title_color => 'FF0000')).to include('chts=FF0000')
483
+ expect(Gchart.sparkline(:title => @title, :title_size => '20')).to include('chts=454545,20')
469
484
  end
470
485
 
471
486
  it "should be able to have multiple legends" do
472
- @chart.include?(Gchart.jstize("chdl=first+data+set+label|n+data+set+label")).should be_true
487
+ expect(@chart).to include(Gchart.jstize("chdl=first+data+set+label|n+data+set+label"))
473
488
  end
474
489
 
475
490
  it "should be able to have one legend" do
476
491
  chart = Gchart.sparkline(:legend => 'legend label')
477
- chart.include?("chdl=legend+label").should be_true
492
+ expect(chart).to include("chdl=legend+label")
478
493
  end
479
494
 
480
495
  it "should be able to set the background fill" do
481
- Gchart.sparkline(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true
482
- Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
496
+ expect(Gchart.sparkline(:bg => 'efefef')).to include("chf=bg,s,efefef")
497
+ expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef")
483
498
 
484
- Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
485
- Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=bg,lg,0,efefef,0,ffffff,1").should be_true
486
- Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=bg,lg,90,efefef,0,ffffff,1").should be_true
499
+ expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
500
+ expect(Gchart.sparkline(:bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=bg,lg,0,efefef,0,ffffff,1")
501
+ expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=bg,lg,90,efefef,0,ffffff,1")
487
502
 
488
- Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'}).include?("chf=bg,ls,90,efefef,0.2,ffffff,0.2").should be_true
503
+ expect(Gchart.sparkline(:bg => {:color => 'efefef', :type => 'stripes'})).to include("chf=bg,ls,90,efefef,0.2,ffffff,0.2")
489
504
  end
490
505
 
491
506
  it "should be able to set a graph fill" do
492
- Gchart.sparkline(:graph_bg => 'efefef').include?("chf=c,s,efefef").should be_true
493
- Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'}).include?("chf=c,s,efefef").should be_true
494
- Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
495
- Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'}).include?("chf=c,lg,0,efefef,0,ffffff,1").should be_true
496
- Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90}).include?("chf=c,lg,90,efefef,0,ffffff,1").should be_true
507
+ expect(Gchart.sparkline(:graph_bg => 'efefef')).to include("chf=c,s,efefef")
508
+ expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'solid'})).to include("chf=c,s,efefef")
509
+ expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
510
+ expect(Gchart.sparkline(:graph_bg => {:color => 'efefef,0,ffffff,1', :type => 'gradient'})).to include("chf=c,lg,0,efefef,0,ffffff,1")
511
+ expect(Gchart.sparkline(:graph_bg => {:color => 'efefef', :type => 'gradient', :angle => 90})).to include("chf=c,lg,90,efefef,0,ffffff,1")
497
512
  end
498
513
 
499
514
  it "should be able to set both a graph and a background fill" do
500
- Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("bg,s,efefef").should be_true
501
- Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?("c,s,76A4FB").should be_true
502
- if RUBY_VERSION.to_f < 1.9
503
- Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=c,s,76A4FB|bg,s,efefef")).should be_true
504
- else
505
- Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB').include?(Gchart.jstize("chf=bg,s,efefef|c,s,76A4FB")).should be_true
506
- end
515
+ expect(Gchart.sparkline(:bg => 'efefef', :graph_bg => '76A4FB')).to match(/chf=(bg,s,efefef\|c,s,76A4FB|c,s,76A4FB\|bg,s,efefef)/)
507
516
  end
508
517
 
509
518
  it "should be able to have different line colors" do
510
- Gchart.sparkline(:line_colors => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
511
- Gchart.sparkline(:line_color => 'efefef|00ffff').include?(Gchart.jstize('chco=efefef|00ffff')).should be_true
519
+ expect(Gchart.sparkline(:line_colors => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
520
+ expect(Gchart.sparkline(:line_color => 'efefef|00ffff')).to include(Gchart.jstize('chco=efefef|00ffff'))
512
521
  end
513
-
514
522
  end
515
523
 
516
524
  describe "a 3d pie chart" do
@@ -524,13 +532,12 @@ describe "a 3d pie chart" do
524
532
  end
525
533
 
526
534
  it "should create a pie" do
527
- @chart.include?('cht=p').should be_true
535
+ expect(@chart).to include('cht=p')
528
536
  end
529
537
 
530
538
  it "should be able to be in 3d" do
531
- Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true
539
+ expect(Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)).to include('cht=p3')
532
540
  end
533
-
534
541
  end
535
542
 
536
543
  describe "a google-o-meter" do
@@ -543,19 +550,18 @@ describe "a google-o-meter" do
543
550
  end
544
551
 
545
552
  it "should create a meter" do
546
- @chart.include?('cht=gom').should be_true
553
+ expect(@chart).to include('cht=gom')
547
554
  end
548
555
 
549
556
  it "should be able to set a solid background fill" do
550
- Gchart.meter(:bg => 'efefef').include?("chf=bg,s,efefef").should be_true
551
- Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
557
+ expect(Gchart.meter(:bg => 'efefef')).to include("chf=bg,s,efefef")
558
+ expect(Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'})).to include("chf=bg,s,efefef")
552
559
  end
553
560
 
554
561
  it "should be able to set labels by using the legend or labesl accessor" do
555
- Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}")
556
- Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data)
562
+ expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to include("chl=#{@jstized_legend}")
563
+ expect(Gchart.meter(:title => @title, :labels => @legend, :data => @data)).to eq(Gchart.meter(:title => @title, :legend => @legend, :data => @data))
557
564
  end
558
-
559
565
  end
560
566
 
561
567
  describe "a map chart" do
@@ -571,81 +577,80 @@ describe "a map chart" do
571
577
  end
572
578
 
573
579
  it "should create a map" do
574
- @chart.include?('cht=t').should be_true
580
+ expect(@chart).to include('cht=t')
575
581
  end
576
582
 
577
583
  it "should set the geographical area" do
578
- @chart.include?('chtm=usa').should be_true
584
+ expect(@chart).to include('chtm=usa')
579
585
  end
580
586
 
581
587
  it "should set the map colors" do
582
- @chart.include?('chco=FFFFFF,FF0000,FFFF00,00FF00').should be_true
588
+ expect(@chart).to include('chco=FFFFFF,FF0000,FFFF00,00FF00')
583
589
  end
584
590
 
585
591
  it "should set the country/state codes" do
586
- @chart.include?('chld=MTWYIDSD').should be_true
592
+ expect(@chart).to include('chld=MTWYIDSD')
587
593
  end
588
594
 
589
595
  it "should set the chart data" do
590
- @chart.include?('chd=t:0,100,50,32').should be_true
596
+ expect(@chart).to include('chd=t:0,100,50,32')
591
597
  end
592
-
593
598
  end
594
599
 
595
600
  describe 'exporting a chart' do
596
601
 
597
602
  it "should be available in the url format by default" do
598
- Gchart.line(:data => [0, 26], :format => 'url').should == Gchart.line(:data => [0, 26])
603
+ expect(Gchart.line(:data => [0, 26], :format => 'url')).to eq(Gchart.line(:data => [0, 26]))
599
604
  end
600
605
 
601
606
  it "should be available as an image tag" do
602
- Gchart.line(:data => [0, 26], :format => 'image_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/)
607
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/)
603
608
  end
604
609
 
605
610
  it "should be available as an image tag using img_tag alias" do
606
- Gchart.line(:data => [0, 26], :format => 'img_tag').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/)
611
+ expect(Gchart.line(:data => [0, 26], :format => 'img_tag')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" \/>/)
607
612
  end
608
613
 
609
614
  it "should be available as an image tag using custom dimensions" do
610
- Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400').should match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/)
615
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :size => '400x400')).to match(/<img src=(.*) width="400" height="400" alt="Google Chart" \/>/)
611
616
  end
612
617
 
613
618
  it "should be available as an image tag using custom alt text" do
614
- Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/)
619
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :alt => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Sexy chart" \/>/)
615
620
  end
616
621
 
617
622
  it "should be available as an image tag using custom title text" do
618
- Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart').should match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/)
623
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :title => 'Sexy chart')).to match(/<img src=(.*) width="300" height="200" alt="Google Chart" title="Sexy chart" \/>/)
619
624
  end
620
625
 
621
626
  it "should be available as an image tag using custom css id selector" do
622
- Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart').should match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/)
627
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :id => 'chart')).to match(/<img id="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/)
623
628
  end
624
629
 
625
630
  it "should be available as an image tag using custom css class selector" do
626
- Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/)
631
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to match(/<img class="chart" src=(.*) width="300" height="200" alt="Google Chart" \/>/)
627
632
  end
628
633
 
629
634
  it "should use ampersands to separate key/value pairs in URLs by default" do
630
- Gchart.line(:data => [0, 26]).should satisfy {|chart| chart.include? "&" }
631
- Gchart.line(:data => [0, 26]).should_not satisfy {|chart| chart.include? "&amp;" }
635
+ expect(Gchart.line(:data => [0, 26])).to include "&"
636
+ expect(Gchart.line(:data => [0, 26])).not_to include "&amp;"
632
637
  end
633
638
 
634
639
  it "should escape ampersands in URLs when used as an image tag" do
635
- Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart').should satisfy {|chart| chart.include? "&amp;" }
640
+ expect(Gchart.line(:data => [0, 26], :format => 'image_tag', :class => 'chart')).to satisfy {|chart| expect(chart).to include "&amp;" }
636
641
  end
637
642
 
638
643
  it "should be available as a file" do
639
644
  File.delete('chart.png') if File.exist?('chart.png')
640
645
  Gchart.line(:data => [0, 26], :format => 'file')
641
- File.exist?('chart.png').should be_true
646
+ expect(File.exist?('chart.png')).to be
642
647
  File.delete('chart.png') if File.exist?('chart.png')
643
648
  end
644
649
 
645
650
  it "should be available as a file using a custom file name" do
646
651
  File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')
647
652
  Gchart.line(:data => [0, 26], :format => 'file', :filename => 'custom_file_name.png')
648
- File.exist?('custom_file_name.png').should be_true
653
+ expect(File.exist?('custom_file_name.png')).to be
649
654
  File.delete('custom_file_name.png') if File.exist?('custom_file_name.png')
650
655
  end
651
656
 
@@ -658,21 +663,22 @@ describe 'exporting a chart' do
658
663
  :format => "file",
659
664
  :filename => "foo.png"
660
665
  )
661
- File.exist?('foo.png').should be_true
666
+ expect(File.exist?('foo.png')).to be
662
667
  File.delete('foo.png') if File.exist?('foo.png')
663
668
  end
664
-
665
669
  end
666
670
 
667
671
  describe 'SSL support' do
668
672
  it 'should change url if is presented' do
669
- Gchart.line(:use_ssl => true).should include('https://chart.googleapis.com/chart?')
673
+ expect(Gchart.line(:use_ssl => true)).to include('https://chart.googleapis.com/chart?')
670
674
  end
671
-
675
+
672
676
  it "should be available as a file" do
677
+ pending "unexpected error under Travis CI (should be fixed using http://martinottenwaelter.fr/2010/12/ruby19-and-the-ssl-error/)"
673
678
  File.delete('chart.png') if File.exist?('chart.png')
674
679
  Gchart.line(:data => [0, 26], :format => 'file', :use_ssl => true)
675
- File.exist?('chart.png').should be_true
680
+ expect(File.exist?('chart.png')).to be_true
676
681
  File.delete('chart.png') if File.exist?('chart.png')
677
682
  end
678
683
  end
684
+