From c4f1238b64714385be143ae121a51f320ca73f4e Mon Sep 17 00:00:00 2001 From: Aditya Prakash Date: Mon, 7 Mar 2016 12:57:29 +0530 Subject: Add test for checking quality of documentation --- spec/quality_spec.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index c68bfa1533..8fccdbba99 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -40,6 +40,30 @@ describe "The library itself" do "#{filename} has spaces on the EOL on lines #{failing_lines.join(", ")}" end + def check_for_expendable_words(filename) + failing_line_message = [] + useless_words = /\b(actually|obviously|just|clearly|basically|really)\b/i + + File.readlines(filename).each_with_index do |line, number| + next unless word_found = useless_words.match(line) + failing_line_message << "#{filename} has '#{word_found}' on line #{number + 1}. Avoid using these kinds of weak modifiers." + end + + failing_line_message unless failing_line_message.empty? + end + + def check_for_specific_pronouns(filename) + failing_line_message = [] + specific_pronouns = /\b(he|she|his|hers|him|her|himself|herself)\b/i + + File.readlines(filename).each_with_index do |line, number| + next unless word_found = specific_pronouns.match(line) + failing_line_message << "#{filename} has '#{word_found}' on line #{number + 1}. Use more generic pronouns in documentation." + end + + failing_line_message unless failing_line_message.empty? + end + RSpec::Matchers.define :be_well_formed do match(&:empty?) @@ -73,6 +97,19 @@ describe "The library itself" do expect(error_messages.compact).to be_well_formed end + it "maintains language quality of the documentation" do + included = /ronn/ + error_messages = [] + Dir.chdir(File.expand_path("../../man", __FILE__)) do + `git ls-files -z`.split("\x0").each do |filename| + next unless filename =~ included + error_messages << check_for_expendable_words(filename) + error_messages << check_for_specific_pronouns(filename) + end + end + expect(error_messages.compact).to be_well_formed + end + it "can still be built" do Dir.chdir(root) do `gem build bundler.gemspec` -- cgit v1.2.1