Class: Spec::Rails::Matchers::PresentMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/presenter/rspec.rb

Instance Method Summary collapse

Constructor Details

#initialize(presenter, format) ⇒ PresentMatcher

Returns a new instance of PresentMatcher.



6
7
8
9
# File 'lib/presenter/rspec.rb', line 6

def initialize(presenter, format)
  @presenter = presenter
  @format = format
end

Instance Method Details

#failure_messageObject



17
18
19
# File 'lib/presenter/rspec.rb', line 17

def failure_message
  "Expected #{@expect.inspect}, found #{@actual.inspect}"
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/presenter/rspec.rb', line 11

def matches?(response)
  @expect = response.body
  @actual = @presenter.send("to_#{@format.to_sym}")
  @actual == @expect
end

#negative_failure_messageObject



21
22
23
# File 'lib/presenter/rspec.rb', line 21

def negative_failure_message
  "Found unexpected #{@actual.inspect}"
end