Skip to content

Commit f550805

Browse files
committed
Improove gplot spec
1 parent 2b577b1 commit f550805

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

spec/integration/arrtest_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
plot.title "Array Plot Example"
2020
plot.ylabel "x"
2121
plot.xlabel "x^2"
22-
plot.set "term","postscript eps"
23-
plot.set "out", "'#{path}'"
22+
plot.set "term","postscript eps"
23+
plot.set "out", "'#{path}'"
2424

2525
x = (0..50).collect { |v| v.to_f }
2626
y = x.collect { |v| v ** 2 }

spec/lib/ruby_gnuplot/plot_spec.rb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,48 @@
22
subject(:plot) { described_class.new }
33

44
describe '#to_gplot' do
5+
let(:expected_string) do
6+
[
7+
'set title "Array Plot Example"',
8+
'set ylabel "x"',
9+
'set xlabel "x^2"',
10+
'set term postscript eps',
11+
'set output "file.eps"',
12+
''
13+
].join("\n")
14+
end
15+
16+
517
context 'when nothing has been set' do
618
it "returns an empty string" do
719
expect(plot.to_gplot).to eq('')
820
end
921
end
1022

1123
context 'when titles and labels have been set' do
12-
let(:expected_string) do
13-
[
14-
'set title "Array Plot Example"',
15-
'set ylabel "x"',
16-
'set xlabel "x^2"',
17-
''
18-
].join("\n")
19-
end
20-
2124
before do
2225
plot.title "Array Plot Example"
2326
plot.ylabel "x"
2427
plot.xlabel "x^2"
28+
plot.term "postscript eps"
29+
plot.output "file.eps"
30+
end
31+
32+
it "wraps strings with quotes when needed" do
33+
expect(plot.to_gplot).to eq(expected_string)
34+
end
35+
end
36+
37+
context 'when variables are set throgh set call' do
38+
before do
39+
plot.set "title", "Array Plot Example"
40+
plot.set "ylabel", "x"
41+
plot.set "xlabel", "x^2"
42+
plot.set "term", "postscript eps"
43+
plot.set "output", "file.eps"
2544
end
2645

27-
it "sets title and axis labels" do
46+
it "wraps strings with quotes when needed" do
2847
expect(plot.to_gplot).to eq(expected_string)
2948
end
3049
end

0 commit comments

Comments
 (0)