/Testing/GBCommentsProcessor-PreprocessingTesting.m

https://github.com/groue/appledoc · Objective C · 688 lines · 516 code · 60 blank · 112 comment · 0 complexity · 8f0452bf484eb10b85c4f79cb12807c9 MD5 · raw file

  1. //
  2. // GBCommentsProcessor-PreprocessingTesting.m
  3. // appledoc
  4. //
  5. // Created by Tomaz Kragelj on 14.2.11.
  6. // Copyright (C) 2011 Gentle Bytes. All rights reserved.
  7. //
  8. #import "GBApplicationSettingsProvider.h"
  9. #import "GBDataObjects.h"
  10. #import "GBStore.h"
  11. #import "GBCommentsProcessor.h"
  12. @interface GBCommentsProcessor (PrivateAPI)
  13. - (NSString *)stringByPreprocessingString:(NSString *)string withFlags:(NSUInteger)flags;
  14. - (NSString *)stringByConvertingCrossReferencesInString:(NSString *)string withFlags:(NSUInteger)flags;
  15. @end
  16. #pragma mark -
  17. @interface GBCommentsProcessorPreprocessingTesting : GBObjectsAssertor
  18. - (GBCommentsProcessor *)defaultProcessor;
  19. - (GBCommentsProcessor *)processorWithStore:(id)store;
  20. - (GBCommentsProcessor *)processorWithStore:(id)store context:(id)context;
  21. @end
  22. #pragma mark -
  23. @implementation GBCommentsProcessorPreprocessingTesting
  24. #pragma mark Formatting markers conversion
  25. - (void)testStringByPreprocessingString_shouldConvertAppledocBoldMarkersToTemporarySyntaxIfRequested {
  26. // setup
  27. id settings = [GBTestObjectsRegistry realSettingsProvider];
  28. [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
  29. [settings setUseSingleStarForBold:YES];
  30. GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:settings];
  31. // execute
  32. NSString *result1 = [processor stringByPreprocessingString:@"*bold1* *bold text* * bolder text *" withFlags:0];
  33. NSString *result2 = [processor stringByPreprocessingString:@"*bold1* Middle *bold text*" withFlags:0];
  34. // verify
  35. assertThat(result1, is(@"**~!$bold1$!~** **~!$bold text$!~** **~!$ bolder text $!~**"));
  36. assertThat(result2, is(@"**~!$bold1$!~** Middle **~!$bold text$!~**"));
  37. }
  38. - (void)testStringByPreprocessingString_shouldNotConvertAppledocBoldMarkersToTemporarySyntaxIfPrevented {
  39. // setup
  40. id settings = [GBTestObjectsRegistry realSettingsProvider];
  41. [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
  42. [settings setUseSingleStarForBold:NO];
  43. GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:settings];
  44. // execute
  45. NSString *result1 = [processor stringByPreprocessingString:@"*bold1* *bold text* * bolder text *" withFlags:0];
  46. NSString *result2 = [processor stringByPreprocessingString:@"*bold1* Middle *bold text*" withFlags:0];
  47. // verify
  48. assertThat(result1, is(@"*bold1* *bold text* * bolder text *"));
  49. assertThat(result2, is(@"*bold1* Middle *bold text*"));
  50. }
  51. - (void)testStringByPreprocessingString_shouldLeaveItalicsMarkers {
  52. // setup
  53. GBCommentsProcessor *processor = [self defaultProcessor];
  54. // execute
  55. NSString *result1 = [processor stringByPreprocessingString:@"_bold1_ _bold text_ _ bolder text _" withFlags:0];
  56. NSString *result2 = [processor stringByPreprocessingString:@"_bold1_ Middle _bold text_" withFlags:0];
  57. // verify
  58. assertThat(result1, is(@"_bold1_ _bold text_ _ bolder text _"));
  59. assertThat(result2, is(@"_bold1_ Middle _bold text_"));
  60. }
  61. - (void)testStringByPreprocessingString_shouldLeaveBoldItalicsMarkers {
  62. // setup
  63. GBCommentsProcessor *processor = [self defaultProcessor];
  64. // execute
  65. NSString *result = [processor stringByPreprocessingString:@"_*text1*_ *_marked text_* _* text2 *_" withFlags:0];
  66. // verify
  67. assertThat(result, is(@"_*text1*_ *_marked text_* _* text2 *_"));
  68. }
  69. - (void)testStringByPreprocessingString_shouldHandleMonospaceMarkers {
  70. // setup
  71. GBCommentsProcessor *processor = [self defaultProcessor];
  72. // execute
  73. NSString *result = [processor stringByPreprocessingString:@"`mono` ` monoer `" withFlags:0];
  74. // verify
  75. assertThat(result, is(@"`mono` ` monoer `"));
  76. }
  77. - (void)testStringByPreprocessingString_shouldHandleMarkdownBoldMarkers {
  78. // setup
  79. GBCommentsProcessor *processor = [self defaultProcessor];
  80. // execute
  81. NSString *result1 = [processor stringByPreprocessingString:@"__text1__ __ marked __" withFlags:0];
  82. NSString *result2 = [processor stringByPreprocessingString:@"**text1** ** marked **" withFlags:0];
  83. // verify
  84. assertThat(result1, is(@"__text1__ __ marked __"));
  85. assertThat(result2, is(@"**text1** ** marked **"));
  86. }
  87. - (void)testStringByPreprocessingString_shouldLeaveMarkdownBoldItalicsMarkers {
  88. // setup
  89. GBCommentsProcessor *processor = [self defaultProcessor];
  90. // execute
  91. NSString *result1 = [processor stringByPreprocessingString:@"__*text1*__ __* marked *__" withFlags:0];
  92. NSString *result2 = [processor stringByPreprocessingString:@"_**text1**_ _** marked **_" withFlags:0];
  93. NSString *result3 = [processor stringByPreprocessingString:@"*__text1__* *__ marked __*" withFlags:0];
  94. NSString *result4 = [processor stringByPreprocessingString:@"**_text1_** **_ marked _**" withFlags:0];
  95. NSString *result5 = [processor stringByPreprocessingString:@"___text1___ ___ marked ___" withFlags:0];
  96. NSString *result6 = [processor stringByPreprocessingString:@"***text1*** *** marked ***" withFlags:0];
  97. // verify
  98. assertThat(result1, is(@"__*text1*__ __* marked *__"));
  99. assertThat(result2, is(@"_**text1**_ _** marked **_"));
  100. assertThat(result3, is(@"*__text1__* *__ marked __*"));
  101. assertThat(result4, is(@"**_text1_** **_ marked _**"));
  102. assertThat(result5, is(@"___text1___ ___ marked ___"));
  103. assertThat(result6, is(@"***text1*** *** marked ***"));
  104. }
  105. #pragma mark Class, category and protocol cross references detection
  106. - (void)testStringByConvertingCrossReferencesInString_shouldConvertClass {
  107. // setup
  108. GBStore *store = [GBTestObjectsRegistry storeWithObjects:[GBClassData classDataWithName:@"Class"], nil];
  109. GBCommentsProcessor *processor = [self processorWithStore:store];
  110. // execute
  111. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class" withFlags:0];
  112. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Class>" withFlags:0];
  113. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Unknown" withFlags:0];
  114. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<Unknown>" withFlags:0];
  115. // verify
  116. assertThat(result1, is(@"[Class](Classes/Class.html)"));
  117. assertThat(result2, is(@"[Class](Classes/Class.html)"));
  118. assertThat(result3, is(@"Unknown"));
  119. assertThat(result4, is(@"<Unknown>"));
  120. }
  121. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategory {
  122. // setup
  123. GBStore *store = [GBTestObjectsRegistry storeWithObjects:[GBCategoryData categoryDataWithName:@"Category" className:@"Class"], nil];
  124. GBCommentsProcessor *processor = [self processorWithStore:store];
  125. // execute
  126. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class(Category)" withFlags:0];
  127. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Class(Category)>" withFlags:0];
  128. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Class(Unknown)" withFlags:0];
  129. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<Class(Unknown)>" withFlags:0];
  130. // verify
  131. assertThat(result1, is(@"[Class(Category)](Categories/Class+Category.html)"));
  132. assertThat(result2, is(@"[Class(Category)](Categories/Class+Category.html)"));
  133. assertThat(result3, is(@"Class(Unknown)"));
  134. assertThat(result4, is(@"<Class(Unknown)>"));
  135. }
  136. - (void)testStringByConvertingCrossReferencesInString_shouldConvertProtocol {
  137. // setup
  138. GBStore *store = [GBTestObjectsRegistry storeWithObjects:[GBProtocolData protocolDataWithName:@"Protocol"], nil];
  139. GBCommentsProcessor *processor = [self processorWithStore:store];
  140. // execute
  141. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Protocol" withFlags:0];
  142. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Protocol>" withFlags:0];
  143. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Unknown" withFlags:0];
  144. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<Unknown>" withFlags:0];
  145. // verify
  146. assertThat(result1, is(@"[Protocol](Protocols/Protocol.html)"));
  147. assertThat(result2, is(@"[Protocol](Protocols/Protocol.html)"));
  148. assertThat(result3, is(@"Unknown"));
  149. assertThat(result4, is(@"<Unknown>"));
  150. }
  151. #pragma mark Local members cross references detection
  152. - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassLocalInstanceMethod {
  153. // setup
  154. GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
  155. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
  156. GBCommentsProcessor *processor = [self processorWithStore:store context:class];
  157. // execute
  158. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
  159. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<method:>" withFlags:0];
  160. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-method:" withFlags:0];
  161. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-method:>" withFlags:0];
  162. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"another:" withFlags:0];
  163. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"<another:>" withFlags:0];
  164. // verify
  165. assertThat(result1, is(@"[method:](#//api/name/method:)"));
  166. assertThat(result2, is(@"[method:](#//api/name/method:)"));
  167. assertThat(result3, is(@"[method:](#//api/name/method:)"));
  168. assertThat(result4, is(@"[method:](#//api/name/method:)"));
  169. assertThat(result5, is(@"another:"));
  170. assertThat(result6, is(@"<another:>"));
  171. }
  172. - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassLocalClassMethod {
  173. // setup
  174. GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry classMethodWithNames:@"method", nil], nil];
  175. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
  176. GBCommentsProcessor *processor = [self processorWithStore:store context:class];
  177. // execute
  178. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
  179. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<method:>" withFlags:0];
  180. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"+method:" withFlags:0];
  181. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<+method:>" withFlags:0];
  182. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"another:" withFlags:0];
  183. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"<another:>" withFlags:0];
  184. // verify
  185. assertThat(result1, is(@"[method:](#//api/name/method:)"));
  186. assertThat(result2, is(@"[method:](#//api/name/method:)"));
  187. assertThat(result3, is(@"[method:](#//api/name/method:)"));
  188. assertThat(result4, is(@"[method:](#//api/name/method:)"));
  189. assertThat(result5, is(@"another:"));
  190. assertThat(result6, is(@"<another:>"));
  191. }
  192. - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassLocalProperty {
  193. // setup
  194. GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:[GBTestObjectsRegistry propertyMethodWithArgument:@"method"], nil];
  195. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
  196. GBCommentsProcessor *processor = [self processorWithStore:store context:class];
  197. // execute
  198. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"method" withFlags:0];
  199. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<method>" withFlags:0];
  200. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
  201. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<method:>" withFlags:0];
  202. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"another" withFlags:0];
  203. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"<another>" withFlags:0];
  204. // verify
  205. assertThat(result1, is(@"[method](#//api/name/method)"));
  206. assertThat(result2, is(@"[method](#//api/name/method)"));
  207. assertThat(result3, is(@"method:"));
  208. assertThat(result4, is(@"<method:>"));
  209. assertThat(result5, is(@"another"));
  210. assertThat(result6, is(@"<another>"));
  211. }
  212. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocolLocalInstanceMethod {
  213. // setup
  214. id method1 = [GBTestObjectsRegistry instanceMethodWithNames:@"method1", nil];
  215. id method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"method2", nil];
  216. GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, nil];
  217. GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method2, nil];
  218. GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
  219. GBCommentsProcessor *processor1 = [self processorWithStore:store context:category];
  220. GBCommentsProcessor *processor2 = [self processorWithStore:store context:protocol];
  221. // execute
  222. NSString *result1 = [processor1 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
  223. NSString *result2 = [processor1 stringByConvertingCrossReferencesInString:@"<method1:>" withFlags:0];
  224. NSString *result3 = [processor1 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
  225. NSString *result4 = [processor2 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
  226. NSString *result5 = [processor2 stringByConvertingCrossReferencesInString:@"<method2:>" withFlags:0];
  227. NSString *result6 = [processor2 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
  228. // verify
  229. assertThat(result1, is(@"[method1:](#//api/name/method1:)"));
  230. assertThat(result2, is(@"[method1:](#//api/name/method1:)"));
  231. assertThat(result3, is(@"method2:"));
  232. assertThat(result4, is(@"[method2:](#//api/name/method2:)"));
  233. assertThat(result5, is(@"[method2:](#//api/name/method2:)"));
  234. assertThat(result6, is(@"method1:"));
  235. }
  236. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocolLocalClassMethod {
  237. // setup
  238. id method1 = [GBTestObjectsRegistry classMethodWithNames:@"method1", nil];
  239. id method2 = [GBTestObjectsRegistry classMethodWithNames:@"method2", nil];
  240. GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, nil];
  241. GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method2, nil];
  242. GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
  243. GBCommentsProcessor *processor1 = [self processorWithStore:store context:category];
  244. GBCommentsProcessor *processor2 = [self processorWithStore:store context:protocol];
  245. // execute
  246. NSString *result1 = [processor1 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
  247. NSString *result2 = [processor1 stringByConvertingCrossReferencesInString:@"<method1:>" withFlags:0];
  248. NSString *result3 = [processor1 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
  249. NSString *result4 = [processor2 stringByConvertingCrossReferencesInString:@"method2:" withFlags:0];
  250. NSString *result5 = [processor2 stringByConvertingCrossReferencesInString:@"<method2:>" withFlags:0];
  251. NSString *result6 = [processor2 stringByConvertingCrossReferencesInString:@"method1:" withFlags:0];
  252. // verify
  253. assertThat(result1, is(@"[method1:](#//api/name/method1:)"));
  254. assertThat(result2, is(@"[method1:](#//api/name/method1:)"));
  255. assertThat(result3, is(@"method2:"));
  256. assertThat(result4, is(@"[method2:](#//api/name/method2:)"));
  257. assertThat(result5, is(@"[method2:](#//api/name/method2:)"));
  258. assertThat(result6, is(@"method1:"));
  259. }
  260. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocolLocalProperty {
  261. // setup
  262. id method1 = [GBTestObjectsRegistry propertyMethodWithArgument:@"method1"];
  263. id method2 = [GBTestObjectsRegistry propertyMethodWithArgument:@"method2"];
  264. GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, nil];
  265. GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method2, nil];
  266. GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
  267. GBCommentsProcessor *processor1 = [self processorWithStore:store context:category];
  268. GBCommentsProcessor *processor2 = [self processorWithStore:store context:protocol];
  269. // execute
  270. NSString *result1 = [processor1 stringByConvertingCrossReferencesInString:@"method1" withFlags:0];
  271. NSString *result2 = [processor1 stringByConvertingCrossReferencesInString:@"<method1>" withFlags:0];
  272. NSString *result3 = [processor1 stringByConvertingCrossReferencesInString:@"method2" withFlags:0];
  273. NSString *result4 = [processor2 stringByConvertingCrossReferencesInString:@"method2" withFlags:0];
  274. NSString *result5 = [processor2 stringByConvertingCrossReferencesInString:@"<method2>" withFlags:0];
  275. NSString *result6 = [processor2 stringByConvertingCrossReferencesInString:@"method1" withFlags:0];
  276. // verify
  277. assertThat(result1, is(@"[method1](#//api/name/method1)"));
  278. assertThat(result2, is(@"[method1](#//api/name/method1)"));
  279. assertThat(result3, is(@"method2"));
  280. assertThat(result4, is(@"[method2](#//api/name/method2)"));
  281. assertThat(result5, is(@"[method2](#//api/name/method2)"));
  282. assertThat(result6, is(@"method1"));
  283. }
  284. #pragma mark Remote members cross references detection
  285. - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassRemoteInstanceMethod {
  286. // setup
  287. GBClassData *class1 = [GBTestObjectsRegistry classWithName:@"Class1" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
  288. GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
  289. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class1, class2, nil];
  290. GBCommentsProcessor *processor = [self processorWithStore:store context:class2];
  291. // execute
  292. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Class1 method:]" withFlags:0];
  293. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<[Class1 method:]>" withFlags:0];
  294. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-[Class1 method:]" withFlags:0];
  295. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-[Class1 method:]>" withFlags:0];
  296. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Unknown method:]" withFlags:0];
  297. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
  298. // verify
  299. assertThat(result1, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
  300. assertThat(result2, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
  301. assertThat(result3, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
  302. assertThat(result4, is(@"[[Class1 method:]](../Classes/Class1.html#//api/name/method:)"));
  303. assertThat(result5, is(@"[Unknown method:]"));
  304. assertThat(result6, is(@"method:"));
  305. }
  306. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryRemoteInstanceMethod {
  307. // setup
  308. GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
  309. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  310. GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, class, nil];
  311. GBCommentsProcessor *processor = [self processorWithStore:store context:class];
  312. // execute
  313. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Class(Category) method:]" withFlags:0];
  314. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<[Class(Category) method:]>" withFlags:0];
  315. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-[Class(Category) method:]" withFlags:0];
  316. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-[Class(Category) method:]>" withFlags:0];
  317. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Class(Unknown) method:]" withFlags:0];
  318. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[Unknown(Category) method:]" withFlags:0];
  319. // verify
  320. assertThat(result1, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
  321. assertThat(result2, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
  322. assertThat(result3, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
  323. assertThat(result4, is(@"[[Class(Category) method:]](../Categories/Class+Category.html#//api/name/method:)"));
  324. assertThat(result5, is(@"[Class(Unknown) method:]"));
  325. assertThat(result6, is(@"[Unknown(Category) method:]"));
  326. }
  327. - (void)testStringByConvertingCrossReferencesInString_shouldConvertProtocolRemoteInstanceMethod {
  328. // setup
  329. GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
  330. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  331. GBStore *store = [GBTestObjectsRegistry storeWithObjects:protocol, class, nil];
  332. GBCommentsProcessor *processor = [self processorWithStore:store context:class];
  333. // execute
  334. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[Protocol method:]" withFlags:0];
  335. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<[Protocol method:]>" withFlags:0];
  336. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"-[Protocol method:]" withFlags:0];
  337. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<-[Protocol method:]>" withFlags:0];
  338. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Unknown method:]" withFlags:0];
  339. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"method:" withFlags:0];
  340. // verify
  341. assertThat(result1, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
  342. assertThat(result2, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
  343. assertThat(result3, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
  344. assertThat(result4, is(@"[[Protocol method:]](../Protocols/Protocol.html#//api/name/method:)"));
  345. assertThat(result5, is(@"[Unknown method:]"));
  346. assertThat(result6, is(@"method:"));
  347. }
  348. - (void)testStringByConvertingCrossReferencesInString_shouldKeepUnknownRemoteMemberEvenIfObjectIsKnown {
  349. // setup
  350. GBClassData *class1 = [GBTestObjectsRegistry classWithName:@"Class1" methods:[GBTestObjectsRegistry instanceMethodWithNames:@"method", nil], nil];
  351. GBClassData *class2 = [GBClassData classDataWithName:@"Class2"];
  352. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class1, class2, nil];
  353. GBCommentsProcessor *processor = [self processorWithStore:store context:class2];
  354. // execute
  355. NSString *result = [processor stringByConvertingCrossReferencesInString:@"[Class1 unknown:]" withFlags:0];
  356. // verify
  357. assertThat(result, is(@"[Class1 unknown:]"));
  358. }
  359. #pragma mark Document references detection
  360. - (void)testStringByConvertingCrossReferencesInString_shouldConvertDocument {
  361. // setup
  362. GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"Document1.html"];
  363. GBStore *store = [GBTestObjectsRegistry storeWithObjects:document, nil];
  364. GBCommentsProcessor *processor = [self processorWithStore:store context:nil];
  365. // execute
  366. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Document1" withFlags:0];
  367. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<Document1>" withFlags:0];
  368. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"Document12" withFlags:0];
  369. // verify
  370. assertThat(result1, is(@"[Document1](docs/Document1.html)"));
  371. assertThat(result2, is(@"[Document1](docs/Document1.html)"));
  372. assertThat(result3, is(@"Document12"));
  373. }
  374. #pragma mark URL cross references detection
  375. - (void)testStringByConvertingCrossReferencesInString_shouldConvertHTML {
  376. // setup
  377. GBCommentsProcessor *processor = [self defaultProcessor];
  378. // execute
  379. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"http://gentlebytes.com" withFlags:0];
  380. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"https://gentlebytes.com" withFlags:0];
  381. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"<http://gentlebytes.com>" withFlags:0];
  382. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<https://gentlebytes.com>" withFlags:0];
  383. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"http://gentlebytes.com https://gentlebytes.com" withFlags:0];
  384. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"https://gentlebytes.com http://gentlebytes.com" withFlags:0];
  385. // verify
  386. assertThat(result1, is(@"[http://gentlebytes.com](http://gentlebytes.com)"));
  387. assertThat(result2, is(@"[https://gentlebytes.com](https://gentlebytes.com)"));
  388. assertThat(result3, is(@"[http://gentlebytes.com](http://gentlebytes.com)"));
  389. assertThat(result4, is(@"[https://gentlebytes.com](https://gentlebytes.com)"));
  390. assertThat(result5, is(@"[http://gentlebytes.com](http://gentlebytes.com) [https://gentlebytes.com](https://gentlebytes.com)"));
  391. assertThat(result6, is(@"[https://gentlebytes.com](https://gentlebytes.com) [http://gentlebytes.com](http://gentlebytes.com)"));
  392. }
  393. - (void)testStringByConvertingCrossReferencesInString_shouldConvertFTP {
  394. // setup
  395. GBCommentsProcessor *processor = [self defaultProcessor];
  396. // execute
  397. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"ftp://gentlebytes.com" withFlags:0];
  398. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"ftps://gentlebytes.com" withFlags:0];
  399. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"<ftp://gentlebytes.com>" withFlags:0];
  400. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<ftps://gentlebytes.com>" withFlags:0];
  401. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"ftp://gentlebytes.com ftps://gentlebytes.com" withFlags:0];
  402. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"ftps://gentlebytes.com ftp://gentlebytes.com" withFlags:0];
  403. // verify
  404. assertThat(result1, is(@"[ftp://gentlebytes.com](ftp://gentlebytes.com)"));
  405. assertThat(result2, is(@"[ftps://gentlebytes.com](ftps://gentlebytes.com)"));
  406. assertThat(result3, is(@"[ftp://gentlebytes.com](ftp://gentlebytes.com)"));
  407. assertThat(result4, is(@"[ftps://gentlebytes.com](ftps://gentlebytes.com)"));
  408. assertThat(result5, is(@"[ftp://gentlebytes.com](ftp://gentlebytes.com) [ftps://gentlebytes.com](ftps://gentlebytes.com)"));
  409. assertThat(result6, is(@"[ftps://gentlebytes.com](ftps://gentlebytes.com) [ftp://gentlebytes.com](ftp://gentlebytes.com)"));
  410. }
  411. - (void)testStringByConvertingCrossReferencesInString_shouldConvertNewsAndRSS {
  412. // setup
  413. GBCommentsProcessor *processor = [self defaultProcessor];
  414. // execute
  415. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"news://gentlebytes.com" withFlags:0];
  416. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"rss://gentlebytes.com" withFlags:0];
  417. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"<news://gentlebytes.com>" withFlags:0];
  418. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"<rss://gentlebytes.com>" withFlags:0];
  419. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"rss://gentlebytes.com news://gentlebytes.com" withFlags:0];
  420. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"news://gentlebytes.com rss://gentlebytes.com" withFlags:0];
  421. // verify
  422. assertThat(result1, is(@"[news://gentlebytes.com](news://gentlebytes.com)"));
  423. assertThat(result2, is(@"[rss://gentlebytes.com](rss://gentlebytes.com)"));
  424. assertThat(result3, is(@"[news://gentlebytes.com](news://gentlebytes.com)"));
  425. assertThat(result4, is(@"[rss://gentlebytes.com](rss://gentlebytes.com)"));
  426. assertThat(result5, is(@"[rss://gentlebytes.com](rss://gentlebytes.com) [news://gentlebytes.com](news://gentlebytes.com)"));
  427. assertThat(result6, is(@"[news://gentlebytes.com](news://gentlebytes.com) [rss://gentlebytes.com](rss://gentlebytes.com)"));
  428. }
  429. - (void)testStringByConvertingCrossReferencesInString_shouldConvertFile {
  430. // setup
  431. GBCommentsProcessor *processor = [self defaultProcessor];
  432. // execute
  433. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"file://gentlebytes.com" withFlags:0];
  434. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<file://gentlebytes.com>" withFlags:0];
  435. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"file://first file://second" withFlags:0];
  436. // verify
  437. assertThat(result1, is(@"[file://gentlebytes.com](file://gentlebytes.com)"));
  438. assertThat(result2, is(@"[file://gentlebytes.com](file://gentlebytes.com)"));
  439. assertThat(result3, is(@"[file://first](file://first) [file://second](file://second)"));
  440. }
  441. - (void)testStringByConvertingCrossReferencesInString_shouldConvertMailto {
  442. // setup
  443. GBCommentsProcessor *processor = [self defaultProcessor];
  444. // execute
  445. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"mailto:appledoc@gentlebytes.com" withFlags:0];
  446. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"<mailto:appledoc@gentlebytes.com>" withFlags:0];
  447. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"mailto:a@b.com mailto:c@d.com" withFlags:0];
  448. // verify
  449. assertThat(result1, is(@"[appledoc@gentlebytes.com](mailto:appledoc@gentlebytes.com)"));
  450. assertThat(result2, is(@"[appledoc@gentlebytes.com](mailto:appledoc@gentlebytes.com)"));
  451. assertThat(result3, is(@"[a@b.com](mailto:a@b.com) [c@d.com](mailto:c@d.com)"));
  452. }
  453. #pragma mark Combinations detection testing
  454. - (void)testStringByConvertingCrossReferencesInString_shouldConvertClassAndProtocol {
  455. // setup
  456. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  457. GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
  458. GBStore *store = [GBTestObjectsRegistry storeWithObjects:protocol, class, nil];
  459. GBCommentsProcessor *processor = [self processorWithStore:store];
  460. // execute
  461. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class Protocol" withFlags:0];
  462. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"Protocol Class" withFlags:0];
  463. // verify
  464. assertThat(result1, is(@"[Class](Classes/Class.html) [Protocol](Protocols/Protocol.html)"));
  465. assertThat(result2, is(@"[Protocol](Protocols/Protocol.html) [Class](Classes/Class.html)"));
  466. }
  467. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndClass {
  468. // setup
  469. GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
  470. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  471. GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, class, nil];
  472. GBCommentsProcessor *processor = [self processorWithStore:store];
  473. // execute
  474. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Class(Category) Class" withFlags:0];
  475. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"Class Class(Category)" withFlags:0];
  476. // verify
  477. assertThat(result1, is(@"[Class(Category)](Categories/Class+Category.html) [Class](Classes/Class.html)"));
  478. assertThat(result2, is(@"[Class](Classes/Class.html) [Class(Category)](Categories/Class+Category.html)"));
  479. }
  480. - (void)testStringByConvertingCrossReferencesInString_shouldConvertCategoryAndProtocol {
  481. // setup - although it's not possible to do categories on protocols, we still test to properly cover these...
  482. GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Protocol"];
  483. GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
  484. GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, protocol, nil];
  485. GBCommentsProcessor *processor = [self processorWithStore:store];
  486. // execute
  487. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"Protocol(Category) Protocol" withFlags:0];
  488. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"Protocol Protocol(Category)" withFlags:0];
  489. // verify
  490. assertThat(result1, is(@"[Protocol(Category)](Categories/Protocol+Category.html) [Protocol](Protocols/Protocol.html)"));
  491. assertThat(result2, is(@"[Protocol](Protocols/Protocol.html) [Protocol(Category)](Categories/Protocol+Category.html)"));
  492. }
  493. #pragma mark Manual links detection testing
  494. - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualLinks {
  495. // setup
  496. GBCommentsProcessor *processor = [self processorWithStore:nil];
  497. // execute
  498. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](something)" withFlags:0];
  499. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[multi word](more words)" withFlags:0];
  500. // verify
  501. assertThat(result1, is(@"[text](something)"));
  502. assertThat(result2, is(@"[multi word](more words)"));
  503. }
  504. - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualURLLinks {
  505. // setup
  506. GBCommentsProcessor *processor = [self processorWithStore:nil];
  507. // execute
  508. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](http://ab.com)" withFlags:0];
  509. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text](https://ab.com)" withFlags:0];
  510. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](ftp://ab.com)" withFlags:0];
  511. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text](ftps://ab.com)" withFlags:0];
  512. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[text](news://ab.com)" withFlags:0];
  513. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[text](rss://ab.com)" withFlags:0];
  514. NSString *result7 = [processor stringByConvertingCrossReferencesInString:@"[text](mailto:a@b.com)" withFlags:0];
  515. // verify
  516. assertThat(result1, is(@"[text](http://ab.com)"));
  517. assertThat(result2, is(@"[text](https://ab.com)"));
  518. assertThat(result3, is(@"[text](ftp://ab.com)"));
  519. assertThat(result4, is(@"[text](ftps://ab.com)"));
  520. assertThat(result5, is(@"[text](news://ab.com)"));
  521. assertThat(result6, is(@"[text](rss://ab.com)"));
  522. assertThat(result7, is(@"[text](mailto:a@b.com)"));
  523. }
  524. - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualObjectLinksAndUpdateAddress {
  525. // setup
  526. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  527. GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
  528. GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
  529. GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"document.ext"];
  530. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, category, protocol, document, nil];
  531. GBCommentsProcessor *processor = [self processorWithStore:store];
  532. // setup
  533. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](Class)" withFlags:0];
  534. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text](Class(Category))" withFlags:0];
  535. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](Protocol)" withFlags:0];
  536. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text](document)" withFlags:0];
  537. // verify
  538. assertThat(result1, is(@"[text](Classes/Class.html)"));
  539. assertThat(result2, is(@"[text](Categories/Class+Category.html)"));
  540. assertThat(result3, is(@"[text](Protocols/Protocol.html)"));
  541. assertThat(result4, is(@"[text](docs/document.html)"));
  542. }
  543. - (void)testStringByConvertingCrossReferencesInString_shouldKeepManualObjectMethodLinksAndUpdateAddress {
  544. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  545. GBCategoryData *category = [GBCategoryData categoryDataWithName:@"Category" className:@"Class"];
  546. GBProtocolData *protocol = [GBProtocolData protocolDataWithName:@"Protocol"];
  547. GBDocumentData *document = [GBDocumentData documentDataWithContents:@"c" path:@"document.ext"];
  548. GBMethodArgument *argument = [GBMethodArgument methodArgumentWithName:@"method"];
  549. GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithArguments:argument, nil];
  550. GBMethodData *method2 = [GBTestObjectsRegistry instanceMethodWithNames:@"doSomething", @"withVars", nil];
  551. GBMethodData *property = [GBTestObjectsRegistry propertyMethodWithArgument:@"value"];
  552. [class.methods registerMethod:method1];
  553. [class.methods registerMethod:method2];
  554. [class.methods registerMethod:property];
  555. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, category, protocol, document, nil];
  556. GBCommentsProcessor *processor = [self processorWithStore:store];
  557. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[text](+[Class method])" withFlags:0];
  558. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[text]([Class doSomething:withVars:])" withFlags:0];
  559. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[text](-[Class value])" withFlags:0];
  560. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[text with space](+[Class method])" withFlags:0];
  561. NSString *result4b = [processor stringByConvertingCrossReferencesInString:@"[text onlyOneSpace]([Class method])" withFlags:0];
  562. NSString *result4c = [processor stringByConvertingCrossReferencesInString:@"[text](+[Class method]), [text onlyOneSpace]([Class method])" withFlags:0];
  563. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:])" withFlags:0];
  564. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:]), [text]([Class method])" withFlags:0];
  565. NSString *result7 = [processor stringByConvertingCrossReferencesInString:@"[doSomething:withVars:]([Class doSomething:withVars:]), [text with space]([Class method])" withFlags:0];
  566. NSString *result8 = [processor stringByConvertingCrossReferencesInString:@"[text](<-[Class value]>)" withFlags:0];
  567. assertThat(result1, is(@"[text](Classes/Class.html#//api/name/method)"));
  568. assertThat(result2, is(@"[text](Classes/Class.html#//api/name/doSomething:withVars:)"));
  569. assertThat(result3, is(@"[text](Classes/Class.html#//api/name/value)"));
  570. assertThat(result4, is(@"[text with space](Classes/Class.html#//api/name/method)"));
  571. assertThat(result4b, is(@"[text onlyOneSpace](Classes/Class.html#//api/name/method)"));
  572. assertThat(result4c, is(@"[text](Classes/Class.html#//api/name/method), [text onlyOneSpace](Classes/Class.html#//api/name/method)"));
  573. assertThat(result5, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:)"));
  574. assertThat(result6, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:), [text](Classes/Class.html#//api/name/method)"));
  575. assertThat(result7, is(@"[doSomething:withVars:](Classes/Class.html#//api/name/doSomething:withVars:), [text with space](Classes/Class.html#//api/name/method)"));
  576. assertThat(result8, is(@"[text](Classes/Class.html#//api/name/value)"));
  577. }
  578. - (void)testStringByConvertingCrossReferencesInString_shouldIgnoreKnownObjectsInManualLinkDescriptionOrTitle {
  579. // setup
  580. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  581. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
  582. GBCommentsProcessor *processor = [self processorWithStore:store];
  583. // setup
  584. NSString *result = [processor stringByConvertingCrossReferencesInString:@"[Class](Class \"Class\")" withFlags:0];
  585. // verify
  586. assertThat(result, is(@"[Class](Classes/Class.html \"Class\")"));
  587. }
  588. - (void)testStringByConvertingCrossReferencesInString_shouldHandleMarkdownLinkReferences {
  589. // setup
  590. GBClassData *class = [GBClassData classDataWithName:@"Class"];
  591. GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
  592. GBCommentsProcessor *processor = [self processorWithStore:store];
  593. // setup
  594. NSString *result1 = [processor stringByConvertingCrossReferencesInString:@"[1]: http://ab.com" withFlags:0];
  595. NSString *result2 = [processor stringByConvertingCrossReferencesInString:@"[1]: http://ab.com \"title\"" withFlags:0];
  596. NSString *result3 = [processor stringByConvertingCrossReferencesInString:@"[1]: Class" withFlags:0];
  597. NSString *result4 = [processor stringByConvertingCrossReferencesInString:@"[1]: Class \"title\"" withFlags:0];
  598. NSString *result5 = [processor stringByConvertingCrossReferencesInString:@"[Class]: something" withFlags:0];
  599. NSString *result6 = [processor stringByConvertingCrossReferencesInString:@"[1]: something \"Class\"" withFlags:0];
  600. // verify
  601. assertThat(result1, is(@"[1]: http://ab.com"));
  602. assertThat(result2, is(@"[1]: http://ab.com \"title\""));
  603. assertThat(result3, is(@"[1]: Classes/Class.html"));
  604. assertThat(result4, is(@"[1]: Classes/Class.html \"title\""));
  605. assertThat(result5, is(@"[Class]: something"));
  606. assertThat(result6, is(@"[1]: something \"Class\""));
  607. }
  608. #pragma mark Creation methods
  609. - (GBCommentsProcessor *)defaultProcessor {
  610. // Creates a new GBCommentsProcessor using real settings. Note that we disable embedding cross references to make test strings more readable.
  611. id settings = [GBTestObjectsRegistry realSettingsProvider];
  612. [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
  613. return [GBCommentsProcessor processorWithSettingsProvider:settings];
  614. }
  615. - (GBCommentsProcessor *)processorWithStore:(id)store {
  616. // Creates a new GBCommentsProcessor using real settings and the given store.
  617. return [self processorWithStore:store context:nil];
  618. }
  619. - (GBCommentsProcessor *)processorWithStore:(id)store context:(id)context {
  620. // Creates a new GBCommentsProcessor using real settings and the given store and context. Note that we disable embedding cross references to make test strings more readable.
  621. id settings = [GBTestObjectsRegistry realSettingsProvider];
  622. [settings setEmbedCrossReferencesWhenProcessingMarkdown:NO];
  623. GBCommentsProcessor *result = [self defaultProcessor];
  624. [result setValue:store forKey:@"store"];
  625. [result setValue:context forKey:@"currentContext"];
  626. return result;
  627. }
  628. @end