Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ def metadata_for(topic)
flunk "invalid YAML: #{ex.message}"
end
end

def text_for(topic)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might call this body_for. 🤔

path = File.join(topics_dir, topic, "index.md")
return "" unless File.file?(path)

parts = File.read(path).split("---", 3)
return "" unless parts.size >= 2

parts[2]
end
50 changes: 50 additions & 0 deletions test/topics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,56 @@
assert metadata.key?(key), "expected to have '#{key}' defined for topic"
assert metadata[key] && metadata[key].strip.size > 0,
"expected to have a value for '#{key}'"
end

it "follows the Topic Page Style Guide" do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keeping us honest, Mike. 😅

text = text_for(topic)
end_punctuation = %w[. , ; :]
text.lines do |line|
line.chomp!

refute_includes line, "&", 'Use "and" rather than an ampersand'
refute_includes line, "!", "Avoid exclamation points in topic pages"
refute_includes line, "open-source",
"Use open source without a hyphen"

%w[Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec].each do |month|
refute_includes line, "#{month} ", "Include and spell out the month"
end

%w[1st 2nd 3rd 1th 2th 3th 4th 5th 6th 7th 8th 9th].each do |date_end|
refute_includes line, date_end,
'Include the day number without the "th" or "nd" at the end'
end

%w[GitHubbing Gitting].each do |no_git_verb|
refute_includes line, no_git_verb,
"Never use “GitHub” or “Git” as a verb."
end

%w[Github github].each do |wrong_github|
refute_includes line, wrong_github,
'Always use correct capitalization when referring to "GitHub"'
end

(end_punctuation + [" "]).each do |punctuation|
refute_includes line, "git#{punctuation}",
'Always use correct capitalization when referring to "Git"'

(1..10).each do |digit|
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be ... to exclude 10, if we want numbers less than 10.

refute_includes line, " #{digit}#{punctuation}",
'Write out "one" and every number less than 10'
end
end
end
text.delete("\n").split(".").each do |sentence|
# This is arbitrary; 2 is more correct but 3 avoids false positives.
next if sentence.count(",") < 3

%w[and or].each do |conjunction|
next unless sentence.include? " #{conjunction} "
assert_includes sentence, ", #{conjunction}", "Always use the Oxford comma"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏 😭

end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion topics/csharp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ topic: csharp
url: https://docs.microsoft.com/en-us/dotnet/csharp/csharp
wikipedia_url: https://en.wikipedia.org/wiki/C_Sharp_(programming_language)
---
C# is a programming language used for web development. It is a hybrid of C & C++ that functions similar to Java and is meant for Microsoft's .NET framework.
C# is a programming language used for web development. It is a hybrid of C and C++ that functions similar to Java and is meant for Microsoft's .NET framework.
2 changes: 1 addition & 1 deletion topics/database/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ short_description: A database is a structured set of data held in a computer, us
topic: database
wikipedia_url: https://en.wikipedia.org/wiki/Database
---
A database is a structured set of data held in a computer, most often a server. Databases use a database management system (DBMS) that interacts with users, similar to a lookup table. Modern databases are designed to allow for creation, querying, updating and administration of the data it holds.
A database is a structured set of data held in a computer, most often a server. Databases use a database management system (DBMS) that interacts with users, similar to a lookup table. Modern databases are designed to allow for creation, querying, updating, and administration of the data it holds.
2 changes: 1 addition & 1 deletion topics/gulp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ topic: gulp
url: http://gulpjs.com/
wikipedia_url: https://en.wikipedia.org/wiki/Gulp.js
---
Gulp is an open source toolkit built on Node.js & npm. It is used for automating and streamlining repetitive tasks in front-end web development.
Gulp is an open source toolkit built on Node.js and npm. It is used for automating and streamlining repetitive tasks in front-end web development.
2 changes: 1 addition & 1 deletion topics/ios/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ topic: ios
url: https://www.apple.com/ios/
wikipedia_url: https://en.wikipedia.org/wiki/IOS
---
iOS is the operating system for all of Apple’s mobile products. The operating system was unveiled at Macworld Conference & Expo in 2007 to support the company’s new venture, the iPhone. Since then, the operating system has grown to incorporate other products, including the iPad and iPod Touch.
iOS is the operating system for all of Apple’s mobile products. The operating system was unveiled at Macworld Conference and Expo in 2007 to support the company’s new venture, the iPhone. Since then, the operating system has grown to incorporate other products, including the iPad and iPod Touch.
2 changes: 1 addition & 1 deletion topics/mysql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ topic: mysql
url: https://www.mysql.com/
wikipedia_url: https://en.wikipedia.org/wiki/MySQL
---
MySQL is an open source relational database management system. Based in Structured Query Language (SQL), MySQL can run on most platforms and is mainly used for web-based applications. It is written in C & C++.
MySQL is an open source relational database management system. Based in Structured Query Language (SQL), MySQL can run on most platforms and is mainly used for web-based applications. It is written in C and C++.
2 changes: 1 addition & 1 deletion topics/react-native/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ topic: react-native
url: http://reactnative.com/
wikipedia_url: https://en.wikipedia.org/wiki/React_(JavaScript_library)#React_Native
---
React Native is a JavaScript mobile framework developed by Facebook. It allows developers to build Android & iOS mobile apps using JavaScript and reuse code across web & mobile applications.
React Native is a JavaScript mobile framework developed by Facebook. It allows developers to build Android and iOS mobile apps using JavaScript and reuse code across web and mobile applications.
2 changes: 1 addition & 1 deletion topics/redux/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ topic: redux
url: http://redux.js.org/
wikipedia_url: https://en.wikipedia.org/wiki/Redux_(JavaScript_library)
---
Redux is an open-source JavaScript library, designed to allow for state management of JavaScript applications. Inspired by Elm, Redux is a debugging tool and supports robust application data-flow architecture. Redux is frequently used in combination with React.
Redux is an open source JavaScript library, designed to allow for state management of JavaScript applications. Inspired by Elm, Redux is a debugging tool and supports robust application data-flow architecture. Redux is frequently used in combination with React.