Fixed test errors, added dynamic resource folder and feed download script
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
+ (RSXMLData *)xmlData:(NSString *)title urlString:(NSString *)urlString {
|
||||
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:title ofType:@"html"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:title ofType:@"html" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
return [[RSXMLData alloc] initWithData:d urlString:urlString];
|
||||
}
|
||||
@@ -137,7 +137,7 @@
|
||||
XCTAssertEqualObjects(feedLink.type, @"application/rss+xml");
|
||||
XCTAssertEqualObjects(feedLink.urlString, @"http://inessential.com/xml/rss.xml");
|
||||
|
||||
XCTAssertEqual(metadata.appleTouchIcons.count, 0);
|
||||
XCTAssertEqual(metadata.appleTouchIcons.count, 0u);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
XCTAssertEqualObjects(feedLink.type, @"application/rss+xml");
|
||||
XCTAssertEqualObjects(feedLink.urlString, @"http://feedpress.me/sixcolors");
|
||||
|
||||
XCTAssertEqual(metadata.appleTouchIcons.count, 6);
|
||||
XCTAssertEqual(metadata.appleTouchIcons.count, 6u);
|
||||
RSHTMLMetadataAppleTouchIcon *icon = metadata.appleTouchIcons[3];
|
||||
XCTAssertEqualObjects(icon.rel, @"apple-touch-icon");
|
||||
XCTAssertEqualObjects(icon.sizes, @"120x120");
|
||||
@@ -201,7 +201,7 @@
|
||||
}
|
||||
|
||||
XCTAssertTrue(found, @"Expected link should have been found.");
|
||||
XCTAssertEqual(links.count, 131, @"Expected 131 links.");
|
||||
XCTAssertEqual(links.count, 131u, @"Expected 131 links.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"Subs" ofType:@"opml"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"Subs" ofType:@"opml" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://example.org/"];
|
||||
});
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
- (void)testNotOPML {
|
||||
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"DaringFireball" ofType:@"rss"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"DaringFireball" ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
RSXMLData *xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://example.org/"];
|
||||
RSOPMLParser *parser = [[RSOPMLParser alloc] initWithXMLData:xmlData];
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"OneFootTsunami" ofType:@"atom"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"OneFootTsunami" ofType:@"atom" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://onefoottsunami.com/"];
|
||||
});
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"scriptingNews" ofType:@"rss"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"scriptingNews" ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://scripting.com/"];
|
||||
});
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"manton" ofType:@"rss"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"manton" ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://manton.org/"];
|
||||
});
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"DaringFireball" ofType:@"rss"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"DaringFireball" ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://daringfireball.net/"];
|
||||
});
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"KatieFloyd" ofType:@"rss"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"KatieFloyd" ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"http://katiefloyd.com/"];
|
||||
});
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"EMarley" ofType:@"rss"];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:@"EMarley" ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
xmlData = [[RSXMLData alloc] initWithData:d urlString:@"https://medium.com/@emarley"];
|
||||
});
|
||||
@@ -158,7 +158,7 @@
|
||||
RSXMLData *xmlData = [[self class] eMarleyData];
|
||||
RSParsedFeed *parsedFeed = RSParseFeedSync(xmlData, &error);
|
||||
XCTAssertEqualObjects(parsedFeed.title, @"Stories by Liz Marley on Medium");
|
||||
XCTAssertEqual(parsedFeed.articles.count, 10);
|
||||
XCTAssertEqual(parsedFeed.articles.count, 10u);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,4 +208,33 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testDownloadedFeeds {
|
||||
NSError *error = nil;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
++i;
|
||||
NSString *pth = [NSString stringWithFormat:@"feed_%d", i];
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:pth ofType:@"rss" inDirectory:@"Resources"];
|
||||
if (s == nil) {
|
||||
break;
|
||||
}
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
RSXMLData *xmlData = [[RSXMLData alloc] initWithData:d urlString:pth];
|
||||
RSParsedFeed *parsedFeed = RSParseFeedSync(xmlData, &error);
|
||||
printf("\n\nparsing: %s\n%s\n", pth.UTF8String, parsedFeed.description.UTF8String);
|
||||
XCTAssertNil(error);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testSingle {
|
||||
NSError *error = nil;
|
||||
NSString *filename = @"feed_1";
|
||||
NSString *s = [[NSBundle bundleForClass:[self class]] pathForResource:filename ofType:@"rss" inDirectory:@"Resources"];
|
||||
NSData *d = [[NSData alloc] initWithContentsOfFile:s];
|
||||
RSXMLData *xmlData = [[RSXMLData alloc] initWithData:d urlString:@"single-feed"];
|
||||
RSParsedFeed *parsedFeed = RSParseFeedSync(xmlData, &error);
|
||||
printf("\n\nparsing: %s\n%s\n", filename.UTF8String, parsedFeed.description.UTF8String);
|
||||
XCTAssertNil(error);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
16
RSXMLTests/download_feeds.sh
Executable file
16
RSXMLTests/download_feeds.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
counter=0
|
||||
|
||||
function processLine() {
|
||||
if [ "$1" ] && [[ ! ${1:0:1} == "#" ]]; then # blank lines & comments ignored
|
||||
((counter++))
|
||||
echo "Download (feed_$counter.rss): $1"
|
||||
curl -s -o "Resources/feed_$counter.rss" "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
while read -r line; do
|
||||
processLine "$line";
|
||||
done < "download_list.txt";
|
||||
processLine "$line"
|
||||
5
RSXMLTests/download_list.txt
Normal file
5
RSXMLTests/download_list.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
# Sample feed
|
||||
http://feeds.feedburner.com/simpledesktops
|
||||
|
||||
# Add more for automatic download
|
||||
# you can group and comment as needed
|
||||
Reference in New Issue
Block a user