-
Notifications
You must be signed in to change notification settings - Fork 20
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
Improve coverage for googlecharts.rb file #80
Conversation
1f66634
to
76f2868
Compare
spec/adapters/googlecharts_spec.rb
Outdated
it "Table class must be GoogleVisualr::DataTable when data objects are" \ | ||
" of class Daru::Vector" do | ||
expect(Daru::View::Table.new(@data_vec1, @options).table).to be_a GoogleVisualr::DataTable | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also verify the data
and options
attribute in Daru::View::Table
class.
We cantest it by the method where this private method( |
We can check the new coverage report of the file after running |
Sure. I will do this in a separate PR. Should I make any another changes in this code? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add other cases means list of rows, data frame in this PR only ? Please refer comments present in the code or iruby notebook examples for Google charts datatable, to see how to generate table.
spec/adapters/googlecharts_spec.rb
Outdated
@@ -36,5 +58,26 @@ | |||
expect(Daru::View::Table.new(@data_vec1, @options).options).to eq @options | |||
expect(Daru::View::Table.new(@data_vec1, @options).data).to eq @data_vec1 | |||
end | |||
it "Table class must be GoogleVisualr::DataTable when data objects are" \ | |||
" of class Daru::DataFrame" do | |||
expect(Daru::View::Table.new(@data_df, @options).table).to be_a GoogleVisualr::DataTable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check line length. You can do something like this :
expect(Daru::View::Table.new(
data_frame,
option)....
).to eq ...
spec/adapters/googlecharts_spec.rb
Outdated
end | ||
it "Table class must be GoogleVisualr::DataTable when data objects are" \ | ||
" of class Array" do | ||
expect(Daru::View::Table.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't better to put Daru::View::Table.new(@data_array2,@ options)
into one variable and use it in next 2 line rather than executing it again and again? Follow it in all cases.
It is better to use |
Partial fix for the issue #67.
Tests were already present for an empty array being passed to the
data
parameter.Adding tests when a vector is passed as
data
.It also improves coverage for the method add_vector_data: https://github.com/SciRuby/daru-view/blob/master/lib/daru/view/adapters/googlecharts.rb#L154-L160.
I also wanted to add tests for the method return_js_type: https://github.com/SciRuby/daru-view/blob/master/lib/daru/view/adapters/googlecharts.rb#L173-#L188.
I have tried testing it as:
it "when data is of class type String" do expect(Daru::View::Adapter::GooglechartsAdapter.return_js_type("daru")).to eq "string" end
But as this method is a private method and it is recommended not to test the private methods, is it possible if we could test it using ruby's send method?