2020-09-19 00:08:09 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2020-11-23 17:14:43 +09:00
|
|
|
require "tempfile"
|
2020-11-06 10:00:55 +09:00
|
|
|
require_relative '../test_helper'
|
2020-08-19 23:47:37 +09:00
|
|
|
|
2020-11-23 13:09:16 +09:00
|
|
|
class YouPlotCommandTest < Test::Unit::TestCase
|
2020-11-23 20:09:32 +09:00
|
|
|
def startup
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-23 17:14:43 +09:00
|
|
|
def setup
|
2020-11-23 20:09:32 +09:00
|
|
|
@stdin = $stdin.dup
|
|
|
|
|
$stdin = File.open(File.expand_path("../fixtures/iris.csv", __dir__), "r")
|
2020-11-23 17:14:43 +09:00
|
|
|
@stderr = $stderr.dup
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-23 20:09:32 +09:00
|
|
|
def cleanup
|
|
|
|
|
$stdin = @stdin
|
|
|
|
|
$stderr = @stderr
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def fixture(fname)
|
|
|
|
|
File.read(File.expand_path("../fixtures/#{fname}", __dir__))
|
|
|
|
|
end
|
|
|
|
|
|
2020-11-23 17:14:43 +09:00
|
|
|
test :scatter do
|
2020-11-23 20:09:32 +09:00
|
|
|
Tempfile.new do |tmp_file|
|
2020-11-23 17:14:43 +09:00
|
|
|
$stderr = tmp_file
|
|
|
|
|
YouPlot::Command.new(["scatter", "-H", "-d,", "-t", "IRIS"]).run
|
2020-11-23 20:09:32 +09:00
|
|
|
assert_equal fixture('iris-scatter.txt'), tmp_file.read
|
2020-11-23 17:14:43 +09:00
|
|
|
end
|
|
|
|
|
end
|
2020-11-23 20:09:32 +09:00
|
|
|
|
|
|
|
|
test :barplot do
|
|
|
|
|
Tempfile.new do |tmp_file|
|
|
|
|
|
$stderr = tmp_file
|
|
|
|
|
YouPlot::Command.new(["barplot", "-H", "-d,", "-t", "IRIS"]).run
|
|
|
|
|
assert_equal fixture('iris-bar.txt'), tmp_file.read
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-19 23:47:37 +09:00
|
|
|
end
|