Skip to content

Commit

Permalink
Create quality check spec for leftover debugging/development mechanisms
Browse files Browse the repository at this point in the history
Example mechanisms:
- sleep
- binding.pry
- debugger
- focused rspec tests via fit
  • Loading branch information
RochesterinNYC committed May 10, 2016
1 parent 0f20a95 commit c359410
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 c359410

Please sign in to comment.