Module: Poisol::Stubs

Extended by:
Stubs
Included in:
Stubs
Defined in:
lib/poisol/stub_mapper/stubs.rb

Instance Method Summary collapse

Instance Method Details

#add(stub) ⇒ Object



9
10
11
12
# File 'lib/poisol/stub_mapper/stubs.rb', line 9

def add stub
  @stubs = [] if @stubs.blank?
  @stubs << stub
end

#allObject



5
6
7
# File 'lib/poisol/stub_mapper/stubs.rb', line 5

def all
  @stubs
end

#get_match(actual_request) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/poisol/stub_mapper/stubs.rb', line 18

def get_match actual_request
  return nil if @stubs.blank?
  matches = @stubs.select{|stub| RequestMatcher.matches? actual_request,stub.request}
  return nil unless matches.present?
  match = matches.last
  match.called_count = match.called_count + 1
  return match
end

#resetObject



14
15
16
# File 'lib/poisol/stub_mapper/stubs.rb', line 14

def reset
  @stubs = []
end

#unusedObject



27
28
29
# File 'lib/poisol/stub_mapper/stubs.rb', line 27

def unused
  @stubs.select{|stub| stub.called_count ==0}
end