Module: RSpec::Support::WhitespaceChecks

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/library_wide_checks.rb

Instance Method Summary collapse

Instance Method Details

#check_for_extra_spaces(filename) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/library_wide_checks.rb', line 18

def check_for_extra_spaces(filename)
  failing_lines = []
  File.readlines(filename).each_with_index do |line, number|
    next if line =~ /^\s+#.*\s+\n$/
    failing_lines << number + 1 if line =~ /\s+\n$/
  end

  return if failing_lines.empty?
  "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
end

#check_for_tab_characters(filename) ⇒ Object

This malformed whitespace detection logic has been borrowed from bundler: github.com/bundler/bundler/blob/v1.8.0/spec/quality_spec.rb



8
9
10
11
12
13
14
15
16
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/library_wide_checks.rb', line 8

def check_for_tab_characters(filename)
  failing_lines = []
  File.readlines(filename).each_with_index do |line, number|
    failing_lines << number + 1 if line =~ /\t/
  end

  return if failing_lines.empty?
  "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
end