Class: PdfSpec::Matchers::IdenticalPdfs

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_spec/matchers.rb

Overview

Class that conforms to RSpec specifications for matchers

Instance Method Summary collapse

Constructor Details

#initialize(pdf_data) ⇒ IdenticalPdfs

Returns a new instance of IdenticalPdfs.



7
8
9
# File 'lib/pdf_spec/matchers.rb', line 7

def initialize(pdf_data)
  @expected_pages = pdf_to_pixel_pages(pdf_data)
end

Instance Method Details

#failure_messageObject

:nodoc:



19
20
21
# File 'lib/pdf_spec/matchers.rb', line 19

def failure_message # :nodoc:
  "expected #{@target_pages.inspect} to look the same as #{@expected_pages.inspect}"
end

#matches?(pdf_data) ⇒ Boolean

Compares given PDF data against

Parameters:

  • pdf_data (String)

    PDF content as a Ruby string

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/pdf_spec/matchers.rb', line 14

def matches?(pdf_data)
  @target_pages = pdf_to_pixel_pages(pdf_data)
  @target_pages == @expected_pages
end

#negative_failure_messageObject

:nodoc:



23
24
25
# File 'lib/pdf_spec/matchers.rb', line 23

def negative_failure_message # :nodoc:
  "expected #{@target_pages.inspect} not to look the same as #{@expected_pages.inspect}"
end