class RkRspec::TestDataGenerator

Public Instance Methods

revision_completed_data() click to toggle source
# File lib/results_keeper_rspec/test_data_generator.rb, line 11
def revision_completed_data
  { revision: RkRspec::Config.config[:revision_name], project: RkRspec::Config.config[:project_name], completed: 1 }
end
revision_data() click to toggle source
# File lib/results_keeper_rspec/test_data_generator.rb, line 7
def revision_data
  { revision: RkRspec::Config.config[:revision_name], project: RkRspec::Config.config[:project_name] }
end
save_screenshot(scenario) click to toggle source
# File lib/results_keeper_rspec/test_data_generator.rb, line 33
def save_screenshot(scenario)
  if scenario.exception
    begin
      screenshot_name = "#{Time.now.to_i}_#{rand(1000..9999)}.png"
      @file_path = "tmp/screenshots/#{screenshot_name}"
      Capybara.page.save_screenshot(@file_path)
      @file_path
    rescue
      RkRspec::Messages.take_screenshot_error
      nil
    end
  end
end
test_data(scenario, revision) click to toggle source
# File lib/results_keeper_rspec/test_data_generator.rb, line 15
def test_data(scenario, revision)
  revision ||= { revision_id: nil }
  test_duration = Time.now - scenario.metadata[:execution_result].started_at
  status = scenario.exception ? 'failed' : 'passed'
  scenario_error = scenario.exception.message if scenario.exception
  run_path = "rspec #{scenario.location}"
  {
    name: "#{scenario.example_group.description} - #{scenario.description}",
    status: status,
    feature_name: scenario.example_group.description,
    run_path: run_path,
    error: scenario_error,
    revision_id: revision['revision_id'],
    duration: test_duration,
    tags: tags(scenario).join(', ')
  }
end

Private Instance Methods

tags(scenario) click to toggle source
# File lib/results_keeper_rspec/test_data_generator.rb, line 49
def tags(scenario)
  tags = []
  default_keys = [:block, :description_args, :description, :full_description,
                  :described_class, :file_path, :line_number, :location,
                  :absolute_file_path, :rerun_file_path, :scoped_id,
                  :type, :execution_result, :example_group, :caller,
                  :shared_group_inclusion_backtrace, :last_run_status]
  scenario.metadata.each do |key, value|
    tags << '@' + key.to_s unless default_keys.include?(key)
  end
  tags
end