Class: Sbmt::Pact::Provider::ProviderStateConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/pact/provider/provider_state_configuration.rb

Defined Under Namespace

Classes: ProviderStateConfigurationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts: {}) ⇒ ProviderStateConfiguration

Returns a new instance of ProviderStateConfiguration.



11
12
13
14
15
16
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 11

def initialize(name, opts: {})
  @name = name
  @opts = opts
  @setup_proc = nil
  @teardown_proc = nil
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 7

def name
  @name
end

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 7

def opts
  @opts
end

#setup_procObject (readonly)

Returns the value of attribute setup_proc.



7
8
9
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 7

def setup_proc
  @setup_proc
end

#teardown_procObject (readonly)

Returns the value of attribute teardown_proc.



7
8
9
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 7

def teardown_proc
  @teardown_proc
end

Instance Method Details

#set_up(&block) ⇒ Object



18
19
20
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 18

def set_up(&block)
  @setup_proc = block
end

#tear_down(&block) ⇒ Object



22
23
24
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 22

def tear_down(&block)
  @teardown_proc = block
end

#validate!Object



26
27
28
# File 'lib/sbmt/pact/provider/provider_state_configuration.rb', line 26

def validate!
  raise ProviderStateConfigurationError.new("no hooks configured for state #{@name}: \"provider_state\" declaration only needed if setup/teardown hooks are used for that state. Please add hooks or remove \"provider_state\" declaration") unless @setup_proc || @teardown_proc
end