Module: Nonnative::Cucumber::ProxySteps

Included in:
Registration
Defined in:
lib/nonnative/cucumber.rb

Constant Summary collapse

PROXY_OPERATIONS =
{
  'close_all' => :close_all,
  'delay' => :delay,
  'invalid_data' => :invalid_data,
  'reset' => :reset
}.freeze

Instance Method Summary collapse

Instance Method Details

#apply_proxy_operation(proxy, operation) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/nonnative/cucumber.rb', line 81

def apply_proxy_operation(proxy, operation)
  method = PROXY_OPERATIONS.fetch(operation) do
    raise ArgumentError, "Unsupported proxy operation '#{operation}'"
  end

  proxy.public_send(method)
end

#install_proxy_mutation_stepsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/nonnative/cucumber.rb', line 47

def install_proxy_mutation_steps
  Given('I set the proxy for process {string} to {string}') do |name, operation|
    process = Nonnative.pool.process_by_name(name)
    Nonnative::Cucumber::Registration.apply_proxy_operation(process.proxy, operation)
  end

  Given('I set the proxy for server {string} to {string}') do |name, operation|
    server = Nonnative.pool.server_by_name(name)
    Nonnative::Cucumber::Registration.apply_proxy_operation(server.proxy, operation)
  end

  Given('I set the proxy for service {string} to {string}') do |name, operation|
    service = Nonnative.pool.service_by_name(name)
    Nonnative::Cucumber::Registration.apply_proxy_operation(service.proxy, operation)
  end
end

#install_proxy_reset_stepsObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/nonnative/cucumber.rb', line 64

def install_proxy_reset_steps
  Then('I should reset the proxy for process {string}') do |name|
    process = Nonnative.pool.process_by_name(name)
    process.proxy.reset
  end

  Then('I should reset the proxy for server {string}') do |name|
    server = Nonnative.pool.server_by_name(name)
    server.proxy.reset
  end

  Then('I should reset the proxy for service {string}') do |name|
    service = Nonnative.pool.service_by_name(name)
    service.proxy.reset
  end
end

#install_proxy_stepsObject



42
43
44
45
# File 'lib/nonnative/cucumber.rb', line 42

def install_proxy_steps
  install_proxy_mutation_steps
  install_proxy_reset_steps
end