Module: Nonnative::Cucumber::LifecycleSteps

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

Instance Method Summary collapse

Instance Method Details

#install_attempt_start_stepObject



90
91
92
93
94
95
96
97
# File 'lib/nonnative/cucumber.rb', line 90

def install_attempt_start_step
  When('I attempt to start the system') do
    @start_error = nil
    Nonnative.start
  rescue StandardError => e
    @start_error = e
  end
end

#install_attempt_stop_stepObject



99
100
101
102
103
104
105
106
# File 'lib/nonnative/cucumber.rb', line 99

def install_attempt_stop_step
  When('I attempt to stop the system') do
    @stop_error = nil
    Nonnative.stop
  rescue StandardError => e
    @stop_error = e
  end
end

#install_healthy_stepObject



117
118
119
120
121
122
123
124
# File 'lib/nonnative/cucumber.rb', line 117

def install_healthy_step
  opts = observability_options

  Then('I should see {string} as healthy') do |service|
    wait_for { Nonnative.observability.health(opts).code }.to eq(200)
    wait_for { Nonnative.observability.health(opts).body }.to_not include(service)
  end
end

#install_start_stepObject



84
85
86
87
88
# File 'lib/nonnative/cucumber.rb', line 84

def install_start_step
  When('I start the system') do
    Nonnative.start
  end
end

#install_state_stepsObject



76
77
78
79
80
81
82
# File 'lib/nonnative/cucumber.rb', line 76

def install_state_steps
  install_start_step
  install_attempt_start_step
  install_attempt_stop_step
  install_unhealthy_step
  install_healthy_step
end

#install_unhealthy_stepObject



108
109
110
111
112
113
114
115
# File 'lib/nonnative/cucumber.rb', line 108

def install_unhealthy_step
  opts = observability_options

  Then('I should see {string} as unhealthy') do |service|
    wait_for { Nonnative.observability.health(opts).code }.to eq(503)
    wait_for { Nonnative.observability.health(opts).body }.to include(service)
  end
end

#observability_optionsObject



126
127
128
129
130
131
132
# File 'lib/nonnative/cucumber.rb', line 126

def observability_options
  {
    headers: { content_type: :json, accept: :json },
    read_timeout: 10,
    open_timeout: 10
  }
end