Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the coverage report for view.rb file #77

Merged
merged 4 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ AllCops:
Include:
- 'lib/**/*'
Exclude:
# - 'daru-view.gemspec'
- 'Rakefile'
- 'Gemfile'
- 'Guardfile'
Expand Down
8 changes: 3 additions & 5 deletions lib/daru/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ def table_library=(lib)
case lib
when :googlecharts
# plot chart and table drawing
@plotting_library = lib
Daru::View::Plot.adapter = lib
Daru::View::Table.adapter = lib
@plotting_library = @table_library = lib
Daru::View::Plot.adapter = Daru::View::Table.adapter = lib
when :datatables
# only for table drawing
Daru::View::Table.adapter = lib
@table_library = Daru::View::Table.adapter = lib
else
raise ArgumentError, "Unsupported library #{lib}"
end

# When code is running in console/terminal then IRuby NameError.
# Since IRuby methods can't work in console.
begin
Expand Down
6 changes: 5 additions & 1 deletion spec/plot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
let(:plot_df) { Daru::View::Plot.new(df, type: :line, x: :a, y: :c) }
let(:plot_dv) { Daru::View::Plot.new(dv, type: :line) }
context 'initialize' do
before { Daru::View.plotting_library = :nyaplot }
# before { Daru::View.plotting_library = :nyaplot }
context 'Default plotting_library is nyaplot' do
it { expect(Daru::View.plotting_library).to eq(:nyaplot)}
end

context 'chart using DataFrame' do
it { expect(plot_df).to be_a Daru::View::Plot }
it { expect(plot_df.chart.class).to eq Nyaplot::Plot }
Expand Down
47 changes: 47 additions & 0 deletions spec/view_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
describe Daru::View, "Daru::View class basic methods" do
context "#plotting_library" do
context 'Set plotting library to googlecharts' do
before { Daru::View.plotting_library = :googlecharts}
it { expect(Daru::View.plotting_library).to eq(:googlecharts) }
end

context 'Set plotting library to highcharts' do
before { Daru::View.plotting_library = :highcharts}
it { expect(Daru::View.plotting_library).to eq(:highcharts) }
end

context 'Set plotting library to nyaplot' do
before { Daru::View.plotting_library = :nyaplot}
it { expect(Daru::View.plotting_library).to eq(:nyaplot) }
end

context 'Set plotting library to xyz, which is unsupported' do
it "should raise ArgumentError" do
expect{
Daru::View.plotting_library = :xyz_library
}.to raise_error(ArgumentError)
end
end
end

context "#table_library" do
context 'Set table library to googlecharts' do
before { Daru::View.table_library = :googlecharts}
it { expect(Daru::View.table_library).to eq(:googlecharts) }
end

context 'Set table library to datatables' do
before { Daru::View.table_library = :datatables}
it { expect(Daru::View.table_library).to eq(:datatables) }
end

context 'Set table library to xyz, which is unsupported' do
it "should raise ArgumentError" do
expect{
Daru::View.table_library = :xyz_library
}.to raise_error(ArgumentError)
end
end
end

end