module SpecSelectorUtil::Instructions

The Instructions module contains methods used to render the appropriate user instructions.

Public Instance Methods

all_passed_message() click to toggle source
# File lib/spec_selector/instructions.rb, line 13
def all_passed_message
  bold("ALL EXAMPLES PASSED\n")
end
back_instructions() click to toggle source
# File lib/spec_selector/instructions.rb, line 36
def back_instructions
  back_inst = 'Press [back] to view to parent group list'
  escape_inst = 'Press [escape] to view to top-level group list'

  [back_inst, escape_inst].each do |inst|
    if @instructions
      bold(inst)
      empty_line
    else
      @output.puts inst
    end
  end
end
basic_instructions() click to toggle source
# File lib/spec_selector/instructions.rb, line 7
def basic_instructions
  i_for_instructions
  up_down_select_instructions
  q_to_exit
end
display_filter_mode() click to toggle source
# File lib/spec_selector/instructions.rb, line 26
def display_filter_mode
  unless @inclusion_filter.empty?
    notice = "FILTER MODE: #{@filter_mode.to_s.upcase}"
    col = term_width / 2 - notice.length / 2
    position_cursor(1, col)
    italicize notice
    reset_cursor
  end
end
empty_filter_notice() click to toggle source
# File lib/spec_selector/instructions.rb, line 17
def empty_filter_notice
  notice = '**********FILTER EMPTY**********'
  row = term_width / 2 - notice.length / 2
  position_cursor(1, row)
  @output.puts notice
  reset_cursor
  nil
end
example_summary_instructions() click to toggle source
# File lib/spec_selector/instructions.rb, line 129
def example_summary_instructions
  i_for_instructions
  @output.puts 'Press M to remove from filter' if @selected.metadata[:include]
  @output.puts 'Press C to clear filter' unless @inclusion_filter.empty?
  top_fail_text unless @failed.empty? || @selected == @failed.first
  back_instructions
  q_to_exit
  empty_line
end
exit_instruction_page() click to toggle source
# File lib/spec_selector/instructions.rb, line 124
def exit_instruction_page
  @instructions = false
  close_alt_buffer
end
filter_pass_instructions() click to toggle source
# File lib/spec_selector/instructions.rb, line 59
def filter_pass_instructions
  verb = @exclude_passing ? 'show' : 'hide'
  bold "Press P to #{verb} passing examples in current set"
end
i_for_instructions() click to toggle source
# File lib/spec_selector/instructions.rb, line 64
def i_for_instructions
  @output.puts 'Press I to view full instructions'
end
q_to_exit() click to toggle source
# File lib/spec_selector/instructions.rb, line 50
def q_to_exit
  @output.puts 'Press Q to exit'
end
top_fail_text() click to toggle source
# File lib/spec_selector/instructions.rb, line 120
def top_fail_text
  bold 'Press [spacebar] to view top failed example'
end
up_down_select_instructions() click to toggle source
# File lib/spec_selector/instructions.rb, line 68
def up_down_select_instructions
  up_down_inst = 'Press ↑ or ↓ to navigate list' if @list.count > 1
  select_inst = 'press [enter] to select'

  [up_down_inst, select_inst].each do |inst|
    if @instructions
      bold(inst)
      empty_line
    else
      @output.puts inst
    end
  end
end
view_instructions_page() click to toggle source
# File lib/spec_selector/instructions.rb, line 82
def view_instructions_page
  @instructions = true
  open_alt_buffer

  unless @failed.empty? || @selected == @failed.first
    top_fail_text
    empty_line
  end

  unless all_passing? || none_passing?
    filter_pass_instructions
    empty_line
  end

  up_down_select_instructions
  back_instructions unless top_level?
  bold('Press R to rerun examples with filter selection')
  empty_line
  bold('Press F to rerun only failed examples')
  empty_line
  bold('Press T to rerun only the top failed example')
  empty_line
  bold('Press M to include or remove selected item from run filter')
  empty_line

  if @inclusion_filter.size.positive?
    bold('Press C to clear filter')
    empty_line
    bold('Press A to clear filter and rerun all examples')
    empty_line
  end

  bold('Press I to exit instructions')
  empty_line
  bold('Press Q to quit')
  bind_input
end
view_other_examples(status) click to toggle source
# File lib/spec_selector/instructions.rb, line 54
def view_other_examples(status)
  verb = (status == :passed ? 'passing' : status.to_s)
  @output.puts "Press ↑ or ↓ to view other #{verb} examples"
end