Class: Bogus::InteractionsRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/bogus/contracts/interactions_repository.rb

Instance Method Summary collapse

Constructor Details

#initializeInteractionsRepository

Returns a new instance of InteractionsRepository.



3
4
5
# File 'lib/bogus/contracts/interactions_repository.rb', line 3

def initialize
  @interactions = Hash.new { |hash, fake_name| hash[fake_name] = [] }
end

Instance Method Details

#for_fake(fake_name) ⇒ Object



15
16
17
# File 'lib/bogus/contracts/interactions_repository.rb', line 15

def for_fake(fake_name)
  @interactions[fake_name]
end

#record(fake_name, method, *args, &block) ⇒ Object



7
8
9
# File 'lib/bogus/contracts/interactions_repository.rb', line 7

def record(fake_name, method, *args, &block)
  @interactions[fake_name] << Interaction.new(method, args, &block)
end

#recorded?(fake_name, interaction) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/bogus/contracts/interactions_repository.rb', line 11

def recorded?(fake_name, interaction)
  @interactions[fake_name].any?{ |i| Interaction.same?(stubbed: interaction, recorded: i) }
end