Class: RSpec::JsonMatchers::Expectation::Builder Private

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

Overview

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

Represents a builder that returns a RSpec::JsonMatchers::Expectation object from an input object

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Builder

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.

Creates a bullder with an object that might or might not be a RSpec::JsonMatchers::Expectation object

Parameters:



69
70
71
# File 'lib/rspec/json_matchers/expectation.rb', line 69

def initialize(object)
  @object = object
end

Instance Method Details

#buildExpectation

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.

Create and return a RSpec::JsonMatchers::Expectation object according to one of the following

- the class of object
- does the object respond to `#call`
- the ancestors of the object (when it's a class)


80
81
82
83
84
85
86
87
# File 'lib/rspec/json_matchers/expectation.rb', line 80

def build
  return object if object.is_a?(Expectation)
  return expectation_by_class unless expectation_by_class.nil?
  return expectation_for_call if object.respond_to?(:call)
  return expectation_by_ancestors if object.is_a?(Class)

  Expectations::Private::Eq[object]
end