123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Support::WhitespaceChecks

Relationships & Source Files
Defined in: rspec-support/lib/rspec/support/spec/library_wide_checks.rb

Instance Method Summary

Instance Method Details

#check_for_extra_spaces(filename)

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/spec/library_wide_checks.rb', line 20

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)

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

[ GitHub ]

  
# File 'rspec-support/lib/rspec/support/spec/library_wide_checks.rb', line 10

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