Class: Bogus::InteractionsRepository
- Inherits:
-
Object
- Object
- Bogus::InteractionsRepository
- Defined in:
- lib/bogus/contracts/interactions_repository.rb
Instance Method Summary collapse
- #for_fake(fake_name) ⇒ Object
-
#initialize ⇒ InteractionsRepository
constructor
A new instance of InteractionsRepository.
- #record(fake_name, method, *args, &block) ⇒ Object
- #recorded?(fake_name, interaction) ⇒ Boolean
Constructor Details
#initialize ⇒ InteractionsRepository
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
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 |