class TestBench::Fixture::Output::Substitute::Output
Public Instance Methods
match_records(*contexts, &block)
click to toggle source
# File lib/test_bench/fixture/output/substitute.rb, line 52 def match_records(*contexts, &block) block ||= proc { true } raw_records.select do |record| context_iterator = record.context.to_enum contexts_match = contexts.all? do |context| until context_iterator.peek == context context_iterator.next end true rescue StopIteration false end contexts_match && block.(record.signal, *record.data, record.context) end end
one_record(*contexts, &block)
click to toggle source
# File lib/test_bench/fixture/output/substitute.rb, line 32 def one_record(*contexts, &block) matching_records = match_records(*contexts, &block) return if matching_records.empty? unless matching_records.one? raise MatchError, "More than one records match" end matching_records.shift end
recorded?(*contexts, &block)
click to toggle source
# File lib/test_bench/fixture/output/substitute.rb, line 26 def recorded?(*contexts, &block) records = match_records(*contexts, &block) records.any? end
recorded_once?(*contexts, &block)
click to toggle source
# File lib/test_bench/fixture/output/substitute.rb, line 20 def recorded_once?(*contexts, &block) record = one_record(*contexts, &block) record ? true : false end
records(*contexts, &block)
click to toggle source
# File lib/test_bench/fixture/output/substitute.rb, line 44 def records(*contexts, &block) if contexts.empty? && block.nil? return raw_records end match_records(*contexts, &block) end
Also aliased as: raw_records
scope(*contexts, &block)
click to toggle source
# File lib/test_bench/fixture/output/substitute.rb, line 14 def scope(*contexts, &block) records = records(*contexts, &block) Scope.build(records) end