Module: Nonnative::Cucumber::Assertions

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

Instance Method Summary collapse

Instance Method Details

#install_assertion_stepsObject



136
137
138
139
140
# File 'lib/nonnative/cucumber.rb', line 136

def install_assertion_steps
  install_memory_assertion_step
  install_error_assertion_steps
  install_log_assertion_steps
end

#install_error_assertion_stepsObject



153
154
155
156
157
158
159
160
161
# File 'lib/nonnative/cucumber.rb', line 153

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



163
164
165
166
167
168
169
170
171
172
# File 'lib/nonnative/cucumber.rb', line 163

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



142
143
144
145
146
147
148
149
150
151
# File 'lib/nonnative/cucumber.rb', line 142

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