Skip to content

Commit

Permalink
Auto merge of rubygems#4463 - RochesterinNYC:add-quality-spec-for-deb…
Browse files Browse the repository at this point in the history
…ugging-mechanisms, r=segiddins

Create quality check spec for leftover debugging/development mechanisms

Example mechanisms that are screened for:
- `sleep`
- `binding.pry`
- `debugger`
- focused `rspec` tests via `fit`

- Related to discussion at rubygems#4439 (comment)
  • Loading branch information
homu committed May 10, 2016
2 parents 10a2254 + c359410 commit fb1dc9a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/quality_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ def check_for_spec_defs_with_single_quotes(filename)
"#{filename} uses inconsistent single quotes on lines #{failing_lines.join(", ")}"
end

def check_for_debugging_mechanisms(filename)
debugging_mechanisms_regex = /
(binding\.pry)|
(debugger)|
(sleep\s*\(?\d+)|
(fit\s*\(?("|\w))
/x

failing_lines = []
File.readlines(filename).each_with_index do |line, number|
failing_lines << number + 1 if line =~ debugging_mechanisms_regex
end

return if failing_lines.empty?
"#{filename} has debugging mechanisms (like binding.pry, sleep, debugger, rspec focusing, etc.) on lines #{failing_lines.join(", ")}"
end

def check_for_tab_characters(filename)
failing_lines = []
File.readlines(filename).each_with_index do |line, number|
Expand Down Expand Up @@ -97,6 +114,20 @@ def check_for_specific_pronouns(filename)
expect(error_messages.compact).to be_well_formed
end

it "does not include any leftover debugging or development mechanisms" do
included = /spec/
exempt = /quality\_spec\.rb/
error_messages = []
Dir.chdir(File.expand_path("../", __FILE__)) do
`git ls-files -z`.split("\x0").each do |filename|
next unless filename =~ included
next if filename =~ exempt
error_messages << check_for_debugging_mechanisms(filename)
end
end
expect(error_messages.compact).to be_well_formed
end

it "maintains language quality of the documentation" do
included = /ronn/
error_messages = []
Expand Down

0 comments on commit fb1dc9a

Please sign in to comment.