Class: RSpec::ActiveModelSerializers::Matchers::RenderSerializer::RenderSerializerMatcher

Inherits:
Matchers::BuiltIn::BaseMatcher
  • Object
show all
Defined in:
lib/rspec/active_model_serializers/matchers/render_serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(scope, expected, message = nil) ⇒ RenderSerializerMatcher

Returns a new instance of RenderSerializerMatcher.



10
11
12
13
14
# File 'lib/rspec/active_model_serializers/matchers/render_serializer.rb', line 10

def initialize(scope, expected, message=nil)
  @expected = expected
  @message = message
  @scope = scope
end

Instance Method Details

#failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rspec/active_model_serializers/matchers/render_serializer.rb', line 24

def failure_message
  rescued_exception.message
end

#failure_message_when_negatedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/rspec/active_model_serializers/matchers/render_serializer.rb', line 29

def failure_message_when_negated
  "expected not to render #{expected.inspect}, but did"
end

#matches?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/rspec/active_model_serializers/matchers/render_serializer.rb', line 17

def matches?(*)
  match_unless_raises ActiveSupport::TestCase::Assertion do
    @scope.assert_serializer expected, @message
  end
end