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.



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

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.



22
23
24
# File 'lib/rspec/active_model_serializers/matchers/render_serializer.rb', line 22

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.



27
28
29
# File 'lib/rspec/active_model_serializers/matchers/render_serializer.rb', line 27

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)


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

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