File: view_spec.rb

package info (click to toggle)
ruby-prawn 2.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,220 kB
  • ctags: 826
  • sloc: ruby: 14,469; sh: 43; makefile: 18
file content (42 lines) | stat: -rw-r--r-- 1,044 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
40
41
42
# encoding: utf-8

require_relative "spec_helper"

describe "Prawn::View" do
  let(:view_object) { Object.new.tap { |o| o.extend(Prawn::View) } }

  it "provides a Prawn::Document object by default" do
    expect(view_object.document).to be_kind_of(Prawn::Document)
  end

  it "delegates unhandled methods to object returned by document method" do
    doc = double("Document")
    allow(view_object).to receive(:document).and_return(doc)

    expect(doc).to receive(:some_delegated_method)

    view_object.some_delegated_method
  end

  it "allows a block-like DSL via the update method" do
    doc = double("Document")
    allow(view_object).to receive(:document).and_return(doc)

    expect(doc).to receive(:foo)
    expect(doc).to receive(:bar)

    view_object.update do
      foo
      bar
    end
  end

  it "aliases save_as() to document.render_file()" do
    doc = double("Document")
    expect(doc).to receive(:render_file)

    allow(view_object).to receive(:document).and_return(doc)

    view_object.save_as("foo.pdf")
  end
end