Sha256: 1eacf0a5d46d3561c74ff226bda5844ea52631251809d09072d596cc02141137

Contents?: true

Size: 706 Bytes

Versions: 5

Compression:

Stored size: 706 Bytes

Contents

require 'logger'

LOG_FILE_NAME = "cucumber_log_file.log"

Given(/^I am logging to a log file(?: at the (#{STRING_OR_SYM}) level)?$/) do |level|
  step "an empty file named \"#{LOG_FILE_NAME}\""
  in_current_dir do
    @logger = Logger.new(LOG_FILE_NAME)
  end
  step "I set the log level to #{level || "info"}"
  scenario_config[:logger] = @logger
end

Given(/^I set the log level to (#{STRING_OR_SYM})$/) do |level|
  level = level ? level.to_s.upcase : "INFO"
  @logger.level = Logger::SEV_LABEL.find_index(level)
end

Then "the log file should contain:" do |string|
  step "the file \"#{LOG_FILE_NAME}\" should contain:", string
end

After do
  if @logger
    @logger.close
    @logger = nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message-driver-0.2.2 features/step_definitions/logging_steps.rb
message-driver-0.2.1 features/step_definitions/logging_steps.rb
message-driver-0.2.0 features/step_definitions/logging_steps.rb
message-driver-0.2.0.rc2 features/step_definitions/logging_steps.rb
message-driver-0.2.0.rc1 features/step_definitions/logging_steps.rb