File: callback_spec.rb

package info (click to toggle)
ruby-rghost 0.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,188 kB
  • sloc: ruby: 3,374; makefile: 6; sh: 1
file content (39 lines) | stat: -rw-r--r-- 1,505 bytes parent folder | download
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
# frozen_string_literal: true

RSpec.describe RGhost::Callback do
  it "should create a callback block" do
    b = RGhost::Callback.new "a_test_callback" do
    end

    expect(b.ps.strip).to eq(%(/a_test_callback 3 dict def a_test_callback begin \n/proc {     } bind def \n/except []  def \n/only []  def \nend))
  end

  it "should use 'except' when available" do
    b = RGhost::Callback.new "a_test_callback", except: [1, 2] do
    end

    expect(b.ps.strip).to eq(%(/a_test_callback 3 dict def a_test_callback begin \n/proc {     } bind def \n/except [1 2]  def \n/only []  def \nend))
  end

  it "should use 'only' when available" do
    b = RGhost::Callback.new "a_test_callback", only: [1, 2] do
    end

    expect(b.ps.strip).to eq(%(/a_test_callback 3 dict def a_test_callback begin \n/proc {     } bind def \n/except []  def \n/only [1 2]  def \nend))
  end

  it "should define ps objects inside of proc block" do
    b = RGhost::Callback.new "a_test_callback", only: [1, 2] do |cb|
      cb.showpage
    end

    expect(b.ps.strip).to eq(%(/a_test_callback 3 dict def a_test_callback begin \n/proc {   showpage    } bind def \n/except []  def \n/only [1 2]  def \nend))

    b = RGhost::Callback.new "a_test_callback", only: [1, 2] do |cb|
      cb.showpage
      cb.moveto x: 10, y: 40
    end

    expect(b.ps.strip).to eq(%(/a_test_callback 3 dict def a_test_callback begin \n/proc {   showpage  10 cm  40 cm  moveto    } bind def \n/except []  def \n/only [1 2]  def \nend))
  end
end