Skip to content

Commit 98c9e00

Browse files
committed
change testing code for more automation
1 parent 0aa9b87 commit 98c9e00

4 files changed

Lines changed: 109 additions & 283 deletions

File tree

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,23 @@ When the `draw` method in `Axes` is called, the call sequence is as follows:
2626
* Consolidate plots like bar plots into 'Multi-' plots.
2727
* Figure out location of the Axes title.
2828
* Figure out location of the legends.
29+
30+
## Test infrastructure
31+
32+
Since it is quite tough to generate the exact same plot with the exact same
33+
pixels on all systems, we perform automated testing by running the same
34+
plotting code twice, saving the generated files of each run in separate files
35+
then comparing them both pixel by pixel.
36+
37+
To make this as smooth as possible, we use the `RSpec.configure` method to define
38+
an `after(:example)` block which will run each example twice, save the image generated
39+
by each run to a separate file and then compare both the files.
40+
41+
The `after(:example)` block requires a `@figure` instance variable which it will use
42+
for performing the plotting. A check will be performed for the `@figure` instance
43+
variable before the example is run.
44+
45+
## Artist defaults convention
46+
47+
Due to nature of a viz library, each Artist tends to have many instance variables
48+
for storing various kinds of information about the Artist.

lib/rubyplot/artist/figure.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ def write file_name
6666

6767
def setup_default_theme
6868
defaults = {
69-
marker_color: 'white',
70-
font_color: 'black',
69+
marker_color: :white,
70+
font_color: :black,
7171
background_image: nil
7272
}
7373
@theme_options = defaults.merge Themes::CLASSIC_WHITE
7474
@marker_color = @theme_options[:marker_color]
7575
@font_color = @theme_options[:font_color] || @marker_color
7676
@backend.set_base_image_gradient(
77-
@theme_options[:background_colors][0],
78-
@theme_options[:background_colors][1],
77+
Rubyplot::Color::COLOR_INDEX[@theme_options[:background_colors][0]],
78+
Rubyplot::Color::COLOR_INDEX[@theme_options[:background_colors][1]],
7979
@width,
8080
@height,
8181
@theme_options[:background_direction]

0 commit comments

Comments
 (0)