Class: Shokkenki::Consumer::Model::Provider

Inherits:
Role
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/shokkenki/consumer/model/provider.rb

Instance Attribute Summary collapse

Attributes inherited from Role

#label, #name

Instance Method Summary collapse

Methods inherited from Role

#to_hash

Methods included from Simplification

#simplify

Constructor Details

#initialize(attributes) ⇒ Provider



14
15
16
17
# File 'lib/shokkenki/consumer/model/provider.rb', line 14

def initialize attributes
  super attributes
  @stubber = attributes[:stubber] || Shokkenki::Consumer::Stubber::LocalServerStubber.new({})
end

Instance Attribute Details

#stubberObject (readonly)

Returns the value of attribute stubber.



12
13
14
# File 'lib/shokkenki/consumer/model/provider.rb', line 12

def stubber
  @stubber
end

Instance Method Details

#assert_all_interactions_used!Object



25
26
27
28
29
# File 'lib/shokkenki/consumer/model/provider.rb', line 25

def assert_all_interactions_used!
  unused_interactions = @stubber.unused_interactions
  message = "In provider '#{@name}' the following interactions were never used: #{JSON.pretty_generate(unused_interactions)}"
  raise message unless unused_interactions.empty?
end

#assert_all_requests_matched!Object



19
20
21
22
23
# File 'lib/shokkenki/consumer/model/provider.rb', line 19

def assert_all_requests_matched!
  unmatched_requests = @stubber.unmatched_requests
  message = "In provider '#{@name}' the following requests were not matched: #{JSON.pretty_generate(unmatched_requests)}"
  raise message unless unmatched_requests.empty?
end