forked from ievgrafov/gnuplotrb
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsplot_spec.rb
64 lines (54 loc) · 1.74 KB
/
splot_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'spec_helper.rb'
describe Splot do
before(:all) do
@tmp_dir = File.join('spec', 'tmp')
Dir.mkdir(@tmp_dir)
@datafile_path = File.join('spec', 'points.data')
end
after(:all) do
FileUtils.rm_r(@tmp_dir)
end
context 'creation' do
before do
@title = 'Awesome spec'
@formula = %w(sin(x) cos(x) exp(-x))
@options = { title: @title, term: 'dumb' }
end
it 'should use *splot* command instead of *plot*' do
plot = Splot.new(*@formula, **@options)
expect(plot).to be_an_instance_of(Splot)
expect(plot.instance_variable_get(:@cmd)).to eql('splot ')
end
end
context 'options handling' do
before do
@options = Hamster::Hash[title: 'GnuplotRB::Plot', yrange: 0..3]
@plot = Splot.new(**@options)
end
it 'should return Splot object' do
new_options = { title: 'Another title', xrange: 1..5 }
new_plot = @plot.options(new_options)
expect(new_plot).to_not equal(@plot)
expect(new_plot).to be_an_instance_of(Splot)
end
end
context 'modifying datasets' do
before do
@plot_math = Splot.new(['sin(x)', title: 'Just a sin'])
@dataset = Dataset.new('exp(-x)')
@plot_two_ds = Splot.new(['cos(x)'], ['x*x'])
end
it 'should create new *Splot* when user adds a dataset' do
new_plot = @plot_math.add_dataset(@dataset)
expect(new_plot).to be_instance_of(Splot)
end
it 'should create new *Splot* when user adds a dataset using #<<' do
new_plot = @plot_math << @dataset
expect(new_plot).to be_instance_of(Splot)
end
it 'should create new *Splot* when user removes a dataset' do
new_plot = @plot_two_ds.remove_dataset
expect(new_plot).to be_instance_of(Splot)
end
end
end