class Object
Public Instance Methods
check_for_extra_spaces(filename)
click to toggle source
# File lib/rspec/support/spec/library_wide_checks.rb, line 116 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)
click to toggle source
This malformed whitespace detection logic has been borrowed from bundler: github.com/bundler/bundler/blob/v1.8.0/spec/quality_spec.rb
# File lib/rspec/support/spec/library_wide_checks.rb, line 106 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
command_from(code_lines)
click to toggle source
# File lib/rspec/support/spec/library_wide_checks.rb, line 27 def command_from(code_lines) code_lines.join("\n") end
expected_encoding?()
click to toggle source
Depends on chaining :with_same_encoding for it to check for string encoding.
# File lib/rspec/support/spec/string_matcher.rb, line 24 def expected_encoding? if defined?(@expect_same_encoding) && @expect_same_encoding actual.encoding == expected.encoding else true end end
have_successful_no_warnings_output()
click to toggle source
# File lib/rspec/support/spec/library_wide_checks.rb, line 75 def have_successful_no_warnings_output eq ["", "", 0] end
load_all_files(files, preamble, postamble=nil)
click to toggle source
# File lib/rspec/support/spec/library_wide_checks.rb, line 31 def load_all_files(files, preamble, postamble=nil) requires = files.map { |f| "require '#{f}'" } command = command_from(Array(preamble) + requires + Array(postamble)) stdout, stderr, status = with_env 'NO_COVERAGE' => '1' do options = %w[ -w ] options << "--disable=gem" if RUBY_VERSION.to_f >= 1.9 && RSpec::Support::Ruby.mri? run_ruby_with_current_load_path(command, *options) end # Ignore bundler warning. stderr = stderr.split("\n").reject { |l| l =~ %r{bundler/source/rubygems} }.join("\n") [stdout, stderr, status.exitstatus] end