module SpecSelectorUtil::DataPresentation

The DataPresentation module contains methods used to render mapped data.

Public Instance Methods

display_example() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 147
def display_example
  @example_display = true
  clear_frame
  display_filter_mode
  test_data_summary
  status = @selected.execution_result.status
  @list, data = example_list
  example_summary_instructions
  @output.puts 'Added to filter √' if @selected.metadata[:include]
  @selector_index = @list.index(@selected)
  view_other_examples(status) if @list.count > 1 && @instructions
  format_example(status, data)
end
display_list() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 116
def display_list
  clear_frame
  display_filter_mode
  test_data_summary
  print_messages unless @messages.empty?
  all_passed_message if all_passing?
  basic_instructions
  empty_line

  @list.each { |item| format_list_item(item) }
end
errors_before_formatter_initialization() click to toggle source

If an exception is raised before an instance of SpecSelector is initialized (for instance, a TypeError raised due to a configuration problem), the MessageNotification will be sent to the registered default formatter instead and will not be accessable to SpecSelector. In such a case, the formatted error information is printed immediately in the manner determined by the default formatter. This method simply checks for a condition caused by that situation and leaves the error information displayed until the user exits.

# File lib/spec_selector/data_presentation.rb, line 19
def errors_before_formatter_initialization
  if @outside_errors_count.positive? && @messages == ['No examples found.']
    empty_line
    exit_only
  end
end
errors_summary(notification) click to toggle source
# File lib/spec_selector/data_presentation.rb, line 57
def errors_summary(notification)
  err_count = notification.errors_outside_of_examples_count
  word_form = err_count > 1 ? 'errors' : 'error'
  italicize "Finished in #{notification.duration} seconds"
  italicize "Files loaded in #{notification.load_time}"
  empty_line
  italicize "#{err_count} #{word_form} occurred outside of examples"
  italicize 'Examples were not successfully executed'
  exit_only
end
example_list() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 161
def example_list
  status = @selected.execution_result.status
  result_list = @failed if status == :failed
  result_list = @pending if status == :pending
  result_list = @passed if status == :passed

  data = @failure_summaries[@selected] if status == :failed
  data = @pending_summaries[@selected] if status == :pending

  [result_list, data]
end
examples_summary(notification) click to toggle source
# File lib/spec_selector/data_presentation.rb, line 44
def examples_summary(notification)
  @summary_notification = notification
  status_summary(notification)

  @list = if @inclusion_filter.empty? || @inclusion_filter.count > 10
            @map[:top_level]
          else
            @inclusion_filter
          end

  selector
end
exclude_passing!() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 80
def exclude_passing!
  alt_map = @map.reject { |_, v| v.all? { |g| all_passed?(fetch_examples(g)) } }
  alt_map.transform_values! { |v| v.reject { |g| all_passed?(fetch_examples(g)) } }
  @active_map = alt_map
  @exclude_passing = true
end
include_passing!() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 87
def include_passing!
  @active_map = @map
  @exclude_passing = false
end
messages_only() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 173
def messages_only
  clear_frame
  print_messages
  exit_only
end
print_errors(notification) click to toggle source
print_messages() click to toggle source
print_summary() click to toggle source
refresh_display() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 142
def refresh_display
  set_selected
  @example_display ? display_example : display_list
end
status_count() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 68
def status_count
  pass_count
  pending_count if @pending_count.positive?
  fail_count
  empty_line
end
status_summary(notification) click to toggle source
# File lib/spec_selector/data_presentation.rb, line 109
def status_summary(notification)
  @summary = []
  @summary << "Total Examples: #{@example_count}"
  @summary << "Finished in #{notification.duration} seconds"
  @summary << "Files loaded in #{notification.load_time} seconds"
end
test_data_summary() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 6
def test_data_summary
  status_count
  print_summary
end
toggle_passing() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 92
def toggle_passing
  return if all_passing?

  @exclude_passing ? include_passing! : exclude_passing!
  return if @example_display && @list != @passed && !@instructions

  exit_instruction_page if @instructions
  p_data = parent_data(@selected.metadata)
  key = p_data ? p_data[:block] : :top_level
  new_list = @active_map[key]
  @list = new_list
  @selected = nil
  @example_display = false
  set_selected
  display_list
end
view_inclusion_filter() click to toggle source
# File lib/spec_selector/data_presentation.rb, line 128
def view_inclusion_filter
  if @inclusion_filter.empty?
    empty_filter_notice
    return
  end

  @example_display = false
  exit_instruction_page if @instructions
  @list = @inclusion_filter
  @selected = @list.first unless @selected.metadata[:include]
  set_selected
  display_list
end