Class: Pact::MockService::Interactions::MergingInteractionsFilter

Inherits:
InteractionsFilter show all
Defined in:
lib/pact/mock_service/interactions/interactions_filter.rb

Instance Method Summary collapse

Methods inherited from InteractionsFilter

#index_of, #initialize

Constructor Details

This class inherits a constructor from Pact::MockService::Interactions::InteractionsFilter

Instance Method Details

#<<(interaction) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pact/mock_service/interactions/interactions_filter.rb', line 48

def << interaction
  if (ndx = index_of(interaction))
    if same_same_but_different?(@interactions[ndx], interaction)
      message = Interactions::InteractionDiffMessage.new(@interactions[ndx], interaction).to_s
      raise SameSameButDifferentError, message
    end
    @interactions[ndx] = interaction
  else
    @interactions << interaction
  end
end

#same_same_but_different?(existing_interaction, new_interaction) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/pact/mock_service/interactions/interactions_filter.rb', line 60

def same_same_but_different?(existing_interaction, new_interaction)
  existing_interaction != new_interaction
end