File: interactions_repository.rb

package info (click to toggle)
ruby-bogus 0.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 860 kB
  • sloc: ruby: 4,219; makefile: 8; sh: 2
file content (19 lines) | stat: -rw-r--r-- 500 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Bogus
  class InteractionsRepository
    def initialize
      @interactions = Hash.new { |hash, fake_name| hash[fake_name] = [] }
    end

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

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

    def for_fake(fake_name)
      @interactions[fake_name]
    end
  end
end