Skip to content

Commit 8e42b90

Browse files
committed
Add arrtest_spec
1 parent 5024cdd commit 8e42b90

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

spec/integration/arrtest_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
describe "Array Plot Example" do
2+
let(:file_path) { 'spec/tmp/array_plot.eps' }
3+
let(:fixture_path) { 'spec/fixtures/plots/array_plot.eps' }
4+
5+
let(:file_content) { File.read(file_path) }
6+
let(:fixture_content) { File.read(fixture_path) }
7+
8+
before do
9+
path = file_path
10+
11+
Gnuplot.open do |gp|
12+
Gnuplot::Plot.new( gp ) do |plot|
13+
14+
plot.title "Array Plot Example"
15+
plot.ylabel "x"
16+
plot.xlabel "x^2"
17+
plot.set "term","postscript eps"
18+
plot.set "out", "'#{path}'"
19+
20+
x = (0..50).collect { |v| v.to_f }
21+
y = x.collect { |v| v ** 2 }
22+
23+
plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
24+
ds.with = "linespoints"
25+
ds.notitle
26+
end
27+
end
28+
end
29+
30+
end
31+
32+
after do
33+
File.delete(file_path)
34+
end
35+
36+
it do
37+
expect(file_content).to eq(fixture_content)
38+
end
39+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# it.
1414
#
1515
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16+
require "gnuplot"
17+
1618
RSpec.configure do |config|
1719
# rspec-expectations config goes here. You can use an alternate
1820
# assertion/expectation library such as wrong or the stdlib/minitest

spec/tmp/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)