Module: Nonnative::Cucumber::Assertions

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

Instance Method Summary collapse

Instance Method Details

#install_assertion_stepsObject



151
152
153
154
155
# File 'lib/nonnative/cucumber.rb', line 151

def install_assertion_steps
  install_memory_assertion_step
  install_error_assertion_steps
  install_log_assertion_steps
end

#install_error_assertion_stepsObject



168
169
170
171
172
173
174
175
176
# File 'lib/nonnative/cucumber.rb', line 168

def install_error_assertion_steps
  Then('starting the system should raise an error') do
    expect(@start_error).to be_a(Nonnative::StartError)
  end

  Then('stopping the system should raise an error') do
    expect(@stop_error).to be_a(Nonnative::StopError)
  end
end

#install_log_assertion_stepsObject



178
179
180
181
182
183
184
185
186
187
# File 'lib/nonnative/cucumber.rb', line 178

def install_log_assertion_steps
  Then('I should see a log entry of {string} for process {string}') do |message, process|
    process = Nonnative.configuration.process_by_name(process)
    expect(Nonnative.log_lines(process.log, ->(l) { l.include?(message) }).first).to include(message)
  end

  Then('I should see a log entry of {string} in the file {string}') do |message, path|
    expect(Nonnative.log_lines(path, ->(l) { l.include?(message) }).first).to include(message)
  end
end

#install_memory_assertion_stepObject



157
158
159
160
161
162
163
164
165
166
# File 'lib/nonnative/cucumber.rb', line 157

def install_memory_assertion_step
  Then('the process {string} should consume less than {string} of memory') do |name, mem|
    process = Nonnative.pool.process_by_name(name)
    _, size, type = mem.split(/(\d+)/)
    actual = process.memory.send(type)
    size = size.to_i

    expect(actual).to be < size
  end
end