Skip to content

Commit b442433

Browse files
committed
Add spec over style class
1 parent 2a802c3 commit b442433

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

spec/lib/ruby_gnuplot/style_spec.rb

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,66 @@
1-
describe Gnuplot::Plot do
1+
describe Gnuplot::Plot::Style do
22
subject(:style) { described_class.new }
33

4-
xit "Adds tests here"
4+
let(:index) { style.index }
5+
6+
describe '#to_s' do
7+
context "when nothing has been set" do
8+
it 'creates an empty style' do
9+
expect(style.to_s).to eq("set style line #{index}")
10+
end
11+
end
12+
13+
context 'when setting the stype' do
14+
before do
15+
style.ls = 1
16+
style.lw = 2
17+
style.lc = 3
18+
style.pt = 4
19+
style.ps = 5
20+
style.fs = 6
21+
end
22+
23+
it 'creates and indexes the style' do
24+
expect(style.to_s).to eq(
25+
"set style line #{index} ls 1 lw 2 lc 3 pt 4 ps 5 fs 6"
26+
)
27+
end
28+
end
29+
30+
context 'when setting the stype on initialize' do
31+
subject(:style) do
32+
described_class.new do |style|
33+
style.ls = 1
34+
style.lw = 2
35+
style.lc = 3
36+
style.pt = 4
37+
style.ps = 5
38+
style.fs = 6
39+
end
40+
end
41+
42+
it 'creates and indexes the style' do
43+
expect(style.to_s).to eq(
44+
"set style line #{index} ls 1 lw 2 lc 3 pt 4 ps 5 fs 6"
45+
)
46+
end
47+
end
48+
49+
context 'when setting using the full method name' do
50+
before do
51+
style.linestyle = 1
52+
style.linewidth = 2
53+
style.linecolor = 3
54+
style.pointtype = 4
55+
style.pointsize = 5
56+
style.fill = 6
57+
end
58+
59+
it 'creates and indexes the style' do
60+
expect(style.to_s).to eq(
61+
"set style line #{index} ls 1 lw 2 lc 3 pt 4 ps 5 fs 6"
62+
)
63+
end
64+
end
65+
end
566
end

0 commit comments

Comments
 (0)