From c3672e0e6e30a0a568640ed88bca64d2867b11fd Mon Sep 17 00:00:00 2001 From: Prakriti-nith Date: Mon, 23 Jul 2018 01:49:48 +0530 Subject: [PATCH] Modified specs --- spec/adapters/googlecharts/display_spec.rb | 12 ++++++----- spec/adapters/googlecharts_spec.rb | 25 ++++++++++------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/spec/adapters/googlecharts/display_spec.rb b/spec/adapters/googlecharts/display_spec.rb index 98821f8..7281a4b 100644 --- a/spec/adapters/googlecharts/display_spec.rb +++ b/spec/adapters/googlecharts/display_spec.rb @@ -23,24 +23,26 @@ data_spreadsheet, {width: 800} ) } + let(:user_options) {{chart_class: 'Chartwrapper'}} + let(:data_table) {Daru::View::Table.new(data)} let(:area_chart_options) {{ type: :area }} let(:column_chart_options) {{ type: :column }} - let(:user_options) {{ + let(:user_options_listener) {{ listeners: { select: "alert('A table row was selected');" } }} - let(:data_table) {Daru::View::Table.new(data, {}, user_options)} + let(:data_table) {Daru::View::Table.new(data, {}, user_options_listener)} let(:area_chart_chart) { Daru::View::Plot. new(data_table.table, area_chart_options)} let(:column_chart_chart) { Daru::View::Plot.new( data_table.table, column_chart_options, - user_options) + user_options_listener) } let(:area_chart_wrapper) {Daru::View::Plot.new( data_table.table, @@ -51,7 +53,7 @@ Daru::View::Plot.new( data_spreadsheet, {type: :area}, - chart_class: 'ChartWrapper' + user_options ) } let (:table_spreadsheet_chartwrapper) { @@ -62,7 +64,7 @@ ) } let(:table_chart_wrapper) {Daru::View::Table.new( - data, {}, {chart_class: 'Chartwrapper'}) + data, {}, user_options) } describe "#to_html" do diff --git a/spec/adapters/googlecharts_spec.rb b/spec/adapters/googlecharts_spec.rb index e5f0fa5..8d73c12 100644 --- a/spec/adapters/googlecharts_spec.rb +++ b/spec/adapters/googlecharts_spec.rb @@ -41,7 +41,7 @@ ['2013'], ] end - let(:user_options) {{ + let(:user_options_listener) {{ listeners: { select: "alert('A table row was selected');" } @@ -54,7 +54,7 @@ Daru::View::Plot.new( data_spreadsheet, {type: :column, width: 800}, - user_options + user_options_listener ) } let (:table_spreadsheet) { @@ -62,7 +62,8 @@ data_spreadsheet, {width: 800} ) } - let(:data_table) {Daru::View::Table.new(data, {}, user_options)} + let(:user_options) {{chart_class: 'Chartwrapper'}} + let(:data_table) {Daru::View::Table.new(data, {}, user_options_listener)} let(:area_chart_options) {{ type: :area }} @@ -72,17 +73,17 @@ let(:area_chart_chart) {Daru::View::Plot. new(data_table.table, area_chart_options)} let(:column_chart_chart) {Daru::View::Plot. - new(data_table.table, column_chart_options, user_options)} + new(data_table.table, column_chart_options, user_options_listener)} let(:area_chart_wrapper) {Daru::View::Plot.new( data_table.table, area_chart_options, - {chart_class: 'Chartwrapper'}) + user_options) } let(:table_chart_wrapper) {Daru::View::Table.new( - data, {}, {chart_class: 'Chartwrapper'}) + data, {}, user_options) } let(:table_wrapper_spreadsheet) {Daru::View::Table.new( - data_spreadsheet, {}, {chart_class: 'Chartwrapper'}) + data_spreadsheet, {}, user_options) } describe "initialization Charts" do @@ -111,9 +112,7 @@ # TODO: all other kinds of charts it "sets correct user_options and data" do expect(area_chart_chart.chart.user_options).to be_empty - expect( - area_chart_wrapper.chart.user_options - ).to eq :chart_class=> 'Chartwrapper' + expect(area_chart_wrapper.chart.user_options).to eq user_options expect(area_chart_chart.chart.data).to eq data_table.table end end @@ -155,10 +154,8 @@ expect{Daru::View::Table.new(1234)}.to raise_error(ArgumentError) end it "sets correct user_options and data of the DataTable" do - expect(data_table.table.user_options).to eq user_options - expect( - table_wrapper_spreadsheet.table.user_options - ).to eq :chart_class=> 'Chartwrapper' + expect(data_table.table.user_options).to eq user_options_listener + expect(table_wrapper_spreadsheet.table.user_options).to eq user_options expect(data_table.table.data).to eq data expect(table_wrapper_spreadsheet.table.data).to eq data_spreadsheet end