Add tests for Dr. Drang’s JSON Feed.

This commit is contained in:
Brent Simmons committed 2017-11-30 13:19:22 -08:00
1 parent b817213393
commit efcc4fedaa
4 files changed
+21 -1

No files matched your search

@@ -63,6 +63,7 @@
845213251FCB3C76003B6E93 /* coco.html in Resources */ = {isa = PBXBuildFile; fileRef = 845213241FCB3C75003B6E93 /* coco.html */; };
845213281FCB4042003B6E93 /* RSHTMLTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 845213261FCB4042003B6E93 /* RSHTMLTag.h */; settings = {ATTRIBUTES = (Public, ); }; };
845213291FCB4042003B6E93 /* RSHTMLTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 845213271FCB4042003B6E93 /* RSHTMLTag.m */; };
84566D941FD0ABFB00103322 /* allthis.json in Resources */ = {isa = PBXBuildFile; fileRef = 84566D931FD0ABFB00103322 /* allthis.json */; };
84628AAD1FCA10AE00566A9B /* allthis.atom in Resources */ = {isa = PBXBuildFile; fileRef = 84628AAC1FCA10AE00566A9B /* allthis.atom */; };
848674D21FCE7BF600802D1F /* macworld.rss in Resources */ = {isa = PBXBuildFile; fileRef = 848674D11FCE7BF500802D1F /* macworld.rss */; };
849A03D01F0081EA00122600 /* DaringFireball.html in Resources */ = {isa = PBXBuildFile; fileRef = 849A03C51F0081EA00122600 /* DaringFireball.html */; };
@@ -164,6 +165,7 @@
845213241FCB3C75003B6E93 /* coco.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = coco.html; sourceTree = "<group>"; };
845213261FCB4042003B6E93 /* RSHTMLTag.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RSHTMLTag.h; sourceTree = "<group>"; };
845213271FCB4042003B6E93 /* RSHTMLTag.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RSHTMLTag.m; sourceTree = "<group>"; };
84566D931FD0ABFB00103322 /* allthis.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = allthis.json; sourceTree = "<group>"; };
84628AAC1FCA10AE00566A9B /* allthis.atom */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = allthis.atom; sourceTree = "<group>"; };
848674D11FCE7BF500802D1F /* macworld.rss */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = macworld.rss; sourceTree = "<group>"; };
849A03C51F0081EA00122600 /* DaringFireball.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = DaringFireball.html; sourceTree = "<group>"; };
@@ -362,6 +364,7 @@
845213241FCB3C75003B6E93 /* coco.html */,
849A03CE1F0081EA00122600 /* sixcolors.html */,
84628AAC1FCA10AE00566A9B /* allthis.atom */,
84566D931FD0ABFB00103322 /* allthis.json */,
849A03CF1F0081EA00122600 /* Subs.opml */,
);
path = Resources;
@@ -544,6 +547,7 @@
849A03D61F0081EA00122600 /* manton.rss in Resources */,
849A03D11F0081EA00122600 /* DaringFireball.rss in Resources */,
849A03D01F0081EA00122600 /* DaringFireball.html in Resources */,
84566D941FD0ABFB00103322 /* allthis.json in Resources */,
84628AAD1FCA10AE00566A9B /* allthis.atom in Resources */,
848674D21FCE7BF600802D1F /* macworld.rss in Resources */,
849A03EA1F01F92B00122600 /* inessential.json in Resources */,
@@ -119,7 +119,14 @@ class FeedParserTypeTests: XCTestCase {
let type = feedType(d)
XCTAssertTrue(type == .jsonFeed)
}
func testAllThisJSONFeedType() {
let d = parserData("allthis", "json", "http://leancrew.com/allthis/")
let type = feedType(d)
XCTAssertTrue(type == .jsonFeed)
}
// MARK: Performance
func testFeedTypePerformance() {
@@ -58,4 +58,12 @@ class JSONFeedParserTests: XCTestCase {
XCTAssert(parsedFeed.faviconURL == "https://daringfireball.net/graphics/favicon-64.png")
XCTAssert(parsedFeed.iconURL == "https://daringfireball.net/graphics/apple-touch-icon.png")
}
func testAllThis() {
let d = parserData("allthis", "json", "http://leancrew.com/allthis/")
let parsedFeed = try! FeedParser.parse(d)!
XCTAssertEqual(parsedFeed.items.count, 12)
}
}
@@ -0,0 +1 @@
{"description": "I just said what I said and it was wrong. Or was taken wrong.", "feed_url": "http://leancrew.com/all-this/feed.json", "title": "And now it’s all this", "items": [{"title": "Last thoughts on modifier keys", "url": "http://leancrew.com/all-this/2017/11/last-thoughts-on-modifier-keys/", "author": {"name": "Dr. Drang"}, "summary": "The first shall be last.", "date_published": "2017-11-23T21:08:29+00:00", "id": "http://leancrew.com/all-this/2017/11/last-thoughts-on-modifier-keys/", "content_html": "<p>When I wrote the post about <a href=\"http://leancrew.com/all-this/2017/11/modifier-key-order/\">ordering Mac modifier keys</a> a few days ago, I was thinking primarily about the proper order of the <em>symbols</em> when writing about a keyboard shortcut, like ⌃⌥⌘P.<sup id=\"fnref:preview\"><a href=\"#fn:preview\" rel=\"footnote\">1</a></sup>. I mentioned parenthetically that this order isn’t always observed when people speak about keyboard shortcuts or when they write the names of the keys out fully, as in “Command-Shift-3 takes a screenshot.”</p>\n<p>Jason Snell, in both <a href=\"https://sixcolors.com/link/2017/11/the-order-of-modifier-keys-on-the-mac/\">a post at Six Colors</a> and in conversation with John Siracusa on <a href=\"https://www.relay.fm/upgrade/168\">the lastest episode of Upgrade</a>, took a stand against Apple’s ordering:<sup id=\"fnref:hig\"><a href=\"#fn:hig\" rel=\"footnote\">2</a></sup></p>\n<blockquote>\n<p>Command is the commander! Command is the monarch of all keys! Command always comes first, in my book.</p>\n</blockquote>\n<p>Siracusa agreed, and so do I. The ⌘ key is, and has always been, the key that signals a keyboard shortcut. While other modifier keys are sometimes used without ⌘—in cursor control and text selection, for example—I can’t think of any Apple applications that don’t use ⌘ to signal a keyboard shortcut for a menu item. And that primacy in shortcuts to menu items is, I think, why Apple puts it last rather than first.</p>\n<p>Keyboard shortcuts are always presented right-justified along the right edge of the menu. The most common shortcuts are just ⌘ and a letter, like ⌘N to start a new document, for example. It’s typically the variations on the basic command that get additional modifier keys, like ⌥⌘N to start a new project. If that were presented in a menu as ⌘⌥N, the menu would look wrong because the ⌘ symbols wouldn’t line up.</p>\n<p>Here’s the <span class=\"menu\">File</span> menu in Safari:</p>\n<p><img alt=\"Safari File menu\" class=\"ss\" src=\"http://leancrew.com/all-this/images2017/20171123-Safari%20File%20menu.png\" title=\"Safari File menu\"/></p>\n<p>There are two different <span class=\"menu\">New</span> commands and three different <span class=\"menu\">Close</span> commands. This, in Apple’s opinion (and mine), wouldn’t be right:</p>\n<p><img alt=\"Altered Safari File menu\" class=\"ss\" src=\"http://leancrew.com/all-this/images2017/20171123-Altered%20Safari%20File%20menu.png\" title=\"Altered Safari File menu\"/></p>\n<p>It’s not just having the ⌘ symbols aligned. The additional modifier symbols go in front <em>because</em> ⌘ is king and must sit next to the N or the W. The importance of the modifier decreases as you move away from the letter.</p>\n<p>It should go without saying—but I’ll say it anyway—that the letter (or number or whatever) key is the most important because <em>nothing</em> happens until it’s pressed.</p>\n<p>Having said all this, and despite agreeing with Apple’s symbol ordering, my ear for shortcut ordering works just like Jason’s and John’s. The main reason I use keyboard shortcut symbols in my posts instead of words is that I can read ⌥⇧⌘W and not be bothered because I don’t “hear” it as I read the symbols. “Option-Shift-Command-W,” on the other hand, gets sounded out in my head, and it sounds wrong.</p>\n<p>I suspect that’s why Apple’s own documentation sometimes gets the order wrong when the modifiers get written out as words. In speaking out the keys, “Command” is natural to put first because it announces that what’s coming is a keyboard shortcut.</p>\n<div class=\"footnotes\">\n<hr/>\n<ol>\n<li id=\"fn:preview\">\n<p>Which happens to be the shortcut I use for previewing a blog post locally before publishing it. <a href=\"#fnref:preview\" rev=\"footnote\">↩︎</a></p>\n</li>\n<li id=\"fn:hig\">\n<p>In the original post, I said I didn’t know where the order was documented. A few people pointed me to both the <a href=\"https://developer.apple.com/macos/human-interface-guidelines/user-interaction/keyboard/\">Human Interface Guidelines</a> and the <a href=\"https://itunes.apple.com/us/book/apple-style-guide/id1161855204?mt=11\">Style Guide</a>, where Apple gives the proper order explicitly. <a href=\"#fnref:hig\" rev=\"footnote\">↩︎</a></p>\n</li>\n</ol>\n</div><br />\n<p>[If the formatting looks odd in your feLine truncated