8000 Added image display option in testing · SciRuby/rubyplot@19b77fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 19b77fe

Browse files
author
alishdipani
committed
Added image display option in testing
1 parent cedd20e commit 19b77fe

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

spec/spec_helper.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
SPEC_ROOT = File.dirname(__FILE__) + "/"
88
TEMP_DIR = SPEC_ROOT + "temp/"
99
FIXTURES_DIR = SPEC_ROOT + "fixtures/"
10+
display_img = nil
1011

1112
backend = ENV['RUBYPLOT_BACKEND']
1213

@@ -50,9 +51,21 @@ def compare_with_reference(test_image, reference_image)
5051
config.before(:suite) do
5152
FileUtils.mkdir_p TEMP_DIR
5253
FileUtils.mkdir_p FIXTURES_DIR
54+
$stdout.puts 'Do you want to display the image? [y/n]'
55+
display_img = $stdin.gets.chomp.strip[0].downcase
56+
while display_img != "y" && display_img != "n"
57+
$stdout.puts 'Please enter y or n'
58+
display_img = $stdin.gets.chomp.strip[0].downcase
59+
end
60+
if display_img == "y"
61+
display_img = true
62+
else
63+
display_img = false
64+
end
5365
end
54-
55-
config.after(:example) do |example|
66+
67+
config.after(:example) do |example|
68+
@figure.show if display_img
5669
if @figure.is_a?(Rubyplot::Artist::Figure)
5770
plot_name = example.description.split.join("_") + ".png"
5871
base_image = TEMP_DIR + plot_name

0 commit comments

Comments
 (0)
0