docks_app 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. data/.editorconfig +8 -0
  2. data/.gitignore +22 -0
  3. data/.rubocop.yml +20 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +35 -0
  8. data/Rakefile +3 -0
  9. data/bin/docks +5 -0
  10. data/config/json/docks_config.json +71 -0
  11. data/config/ruby/docks_config.rb +127 -0
  12. data/config/yaml/docks_config.yml +70 -0
  13. data/docks.gemspec +38 -0
  14. data/lib/docks/build.rb +300 -0
  15. data/lib/docks/cache.rb +143 -0
  16. data/lib/docks/command_line.rb +65 -0
  17. data/lib/docks/configuration.rb +217 -0
  18. data/lib/docks/containers/base_container.rb +103 -0
  19. data/lib/docks/containers/class_container.rb +39 -0
  20. data/lib/docks/containers/component_container.rb +92 -0
  21. data/lib/docks/containers/demo_container.rb +105 -0
  22. data/lib/docks/containers/factory_container.rb +12 -0
  23. data/lib/docks/containers/function_container.rb +46 -0
  24. data/lib/docks/containers/mixin_container.rb +19 -0
  25. data/lib/docks/containers/pattern_container.rb +168 -0
  26. data/lib/docks/containers/pattern_library_container.rb +77 -0
  27. data/lib/docks/containers/state_container.rb +9 -0
  28. data/lib/docks/containers/symbol_container.rb +77 -0
  29. data/lib/docks/containers/variable_container.rb +47 -0
  30. data/lib/docks/containers/variant_container.rb +9 -0
  31. data/lib/docks/containers/variation_container.rb +38 -0
  32. data/lib/docks/containers.rb +25 -0
  33. data/lib/docks/descriptor.rb +60 -0
  34. data/lib/docks/errors.rb +5 -0
  35. data/lib/docks/group.rb +66 -0
  36. data/lib/docks/helpers/github_helper.rb +29 -0
  37. data/lib/docks/helpers/path_helper.rb +94 -0
  38. data/lib/docks/helpers/render_helper.rb +87 -0
  39. data/lib/docks/helpers.rb +19 -0
  40. data/lib/docks/languages/base_language.rb +17 -0
  41. data/lib/docks/languages/coffeescript_language.rb +30 -0
  42. data/lib/docks/languages/common_types/markup_language.rb +71 -0
  43. data/lib/docks/languages/css_language.rb +13 -0
  44. data/lib/docks/languages/erb_language.rb +21 -0
  45. data/lib/docks/languages/haml_language.rb +21 -0
  46. data/lib/docks/languages/html_language.rb +10 -0
  47. data/lib/docks/languages/javascript_language.rb +42 -0
  48. data/lib/docks/languages/json_language.rb +18 -0
  49. data/lib/docks/languages/less_language.rb +33 -0
  50. data/lib/docks/languages/markdown_language.rb +10 -0
  51. data/lib/docks/languages/sass_language.rb +36 -0
  52. data/lib/docks/languages/slim_language.rb +21 -0
  53. data/lib/docks/languages/stylus_language.rb +26 -0
  54. data/lib/docks/languages/yaml_language.rb +18 -0
  55. data/lib/docks/languages.rb +103 -0
  56. data/lib/docks/markdown.rb +18 -0
  57. data/lib/docks/messenger.rb +69 -0
  58. data/lib/docks/naming_conventions/base_naming_convention.rb +9 -0
  59. data/lib/docks/naming_conventions/bem_naming_convention.rb +45 -0
  60. data/lib/docks/naming_conventions/suit_naming_convention.rb +45 -0
  61. data/lib/docks/naming_conventions.rb +21 -0
  62. data/lib/docks/ostruct.rb +17 -0
  63. data/lib/docks/parser.rb +86 -0
  64. data/lib/docks/parsers/base_parser.rb +128 -0
  65. data/lib/docks/parsers/coffeescript_parser.rb +30 -0
  66. data/lib/docks/parsers/css_parser.rb +27 -0
  67. data/lib/docks/parsers/javascript_parser.rb +30 -0
  68. data/lib/docks/parsers/less_parser.rb +22 -0
  69. data/lib/docks/parsers/sass_parser.rb +31 -0
  70. data/lib/docks/parsers/stylus_parser.rb +28 -0
  71. data/lib/docks/process.rb +60 -0
  72. data/lib/docks/processors.rb +416 -0
  73. data/lib/docks/renderers/base_renderer.rb +64 -0
  74. data/lib/docks/renderers/common_features/capturable.rb +69 -0
  75. data/lib/docks/renderers/common_features/helperable.rb +23 -0
  76. data/lib/docks/renderers/erb_renderer.rb +68 -0
  77. data/lib/docks/renderers/haml_renderer.rb +37 -0
  78. data/lib/docks/renderers/slim_renderer.rb +33 -0
  79. data/lib/docks/symbol_sources/base_symbol_source.rb +12 -0
  80. data/lib/docks/symbol_sources/jquery_symbol_source.rb +17 -0
  81. data/lib/docks/symbol_sources/mdn_symbol_source.rb +35 -0
  82. data/lib/docks/symbol_sources/sass_symbol_source.rb +27 -0
  83. data/lib/docks/symbol_sources.rb +28 -0
  84. data/lib/docks/tags/access_tag.rb +27 -0
  85. data/lib/docks/tags/activate_with_tag.rb +17 -0
  86. data/lib/docks/tags/active_tag.rb +14 -0
  87. data/lib/docks/tags/alias_tag.rb +17 -0
  88. data/lib/docks/tags/author_tag.rb +19 -0
  89. data/lib/docks/tags/base_tag.rb +52 -0
  90. data/lib/docks/tags/beta_tag.rb +26 -0
  91. data/lib/docks/tags/class_tag.rb +16 -0
  92. data/lib/docks/tags/compatibility_tag.rb +19 -0
  93. data/lib/docks/tags/demo_type_tag.rb +14 -0
  94. data/lib/docks/tags/deprecated_tag.rb +26 -0
  95. data/lib/docks/tags/description_tag.rb +99 -0
  96. data/lib/docks/tags/example_tag.rb +20 -0
  97. data/lib/docks/tags/factory_tag.rb +16 -0
  98. data/lib/docks/tags/for_tag.rb +23 -0
  99. data/lib/docks/tags/group_tag.rb +10 -0
  100. data/lib/docks/tags/helper_tag.rb +13 -0
  101. data/lib/docks/tags/include_with_tag.rb +57 -0
  102. data/lib/docks/tags/javascript_action_tag.rb +10 -0
  103. data/lib/docks/tags/link_tag.rb +18 -0
  104. data/lib/docks/tags/markup_tag.rb +106 -0
  105. data/lib/docks/tags/member_tag.rb +37 -0
  106. data/lib/docks/tags/method_tag.rb +18 -0
  107. data/lib/docks/tags/name_tag.rb +10 -0
  108. data/lib/docks/tags/object_tag.rb +15 -0
  109. data/lib/docks/tags/param_tag.rb +94 -0
  110. data/lib/docks/tags/pattern_tag.rb +21 -0
  111. data/lib/docks/tags/preclude_tag.rb +17 -0
  112. data/lib/docks/tags/private_tag.rb +15 -0
  113. data/lib/docks/tags/property_tag.rb +18 -0
  114. data/lib/docks/tags/public_tag.rb +15 -0
  115. data/lib/docks/tags/require_tag.rb +47 -0
  116. data/lib/docks/tags/returns_tag.rb +31 -0
  117. data/lib/docks/tags/set_by_tag.rb +18 -0
  118. data/lib/docks/tags/signature_tag.rb +35 -0
  119. data/lib/docks/tags/since_tag.rb +26 -0
  120. data/lib/docks/tags/source_tag.rb +12 -0
  121. data/lib/docks/tags/state_tag.rb +21 -0
  122. data/lib/docks/tags/static_tag.rb +14 -0
  123. data/lib/docks/tags/subcomponent_tag.rb +68 -0
  124. data/lib/docks/tags/subtitle_tag.rb +11 -0
  125. data/lib/docks/tags/symbol_type_tag.rb +10 -0
  126. data/lib/docks/tags/throws_tag.rb +30 -0
  127. data/lib/docks/tags/title_tag.rb +10 -0
  128. data/lib/docks/tags/type_tag.rb +10 -0
  129. data/lib/docks/tags/value_tag.rb +10 -0
  130. data/lib/docks/tags/variant_tag.rb +21 -0
  131. data/lib/docks/tags/variation_tag.rb +136 -0
  132. data/lib/docks/tags.rb +103 -0
  133. data/lib/docks/templates.rb +122 -0
  134. data/lib/docks/themes.rb +19 -0
  135. data/lib/docks/types.rb +26 -0
  136. data/lib/docks/version.rb +3 -0
  137. data/lib/docks.rb +37 -0
  138. data/spec/fixtures/build/scripts/bar/bar_2.js +1 -0
  139. data/spec/fixtures/build/scripts/bar.js +1 -0
  140. data/spec/fixtures/build/styles/foo/foo-2.css +1 -0
  141. data/spec/fixtures/build/styles/foo.css +1 -0
  142. data/spec/fixtures/build/templates/baz/baz_2.erb +1 -0
  143. data/spec/fixtures/build/templates/baz.erb +1 -0
  144. data/spec/fixtures/grouper/components/button/button.coffee +0 -0
  145. data/spec/fixtures/grouper/components/button/button.haml +0 -0
  146. data/spec/fixtures/grouper/components/button/button.scss +0 -0
  147. data/spec/fixtures/grouper/components/checkbox/_checkbox.haml +0 -0
  148. data/spec/fixtures/grouper/components/checkbox/_checkbox.scss +0 -0
  149. data/spec/fixtures/grouper/components/checkbox/checkbox.coffee +0 -0
  150. data/spec/fixtures/grouper/components/form/form.coffee +0 -0
  151. data/spec/fixtures/grouper/components/form/form.m +0 -0
  152. data/spec/fixtures/grouper/components/form/form.scss +0 -0
  153. data/spec/fixtures/grouper/components/next-expanding-textarea/_next-expanding-textarea.scss +0 -0
  154. data/spec/fixtures/grouper/components/next-expanding-textarea/_next_expanding_textarea.coffee +0 -0
  155. data/spec/fixtures/grouper/components/next-expanding-textarea/next-expanding-textarea.haml +0 -0
  156. data/spec/fixtures/grouper/components/next-tab/next-tab.coffee +0 -0
  157. data/spec/fixtures/grouper/components/next-tab/next-tab.haml +0 -0
  158. data/spec/fixtures/grouper/components/next-tab/next-tab.scss +0 -0
  159. data/spec/fixtures/grouper/components/segmented control/segmented control.coffee +0 -0
  160. data/spec/fixtures/grouper/components/segmented control/segmented control.haml +0 -0
  161. data/spec/fixtures/grouper/components/segmented control/segmented control.min.html +0 -0
  162. data/spec/fixtures/grouper/components/segmented control/segmented control.scss +0 -0
  163. data/spec/fixtures/grouper/markup/list-view.haml +0 -0
  164. data/spec/fixtures/grouper/markup/resizable/resizable.haml +0 -0
  165. data/spec/fixtures/grouper/markup/toggle.haml +0 -0
  166. data/spec/fixtures/grouper/scripts/resizable/resizable.coffee +0 -0
  167. data/spec/fixtures/grouper/scripts/toggle.coffee +0 -0
  168. data/spec/fixtures/grouper/style/_list-view.scss +0 -0
  169. data/spec/fixtures/grouper/style/_toggle.scss +0 -0
  170. data/spec/fixtures/languages/stub.json +3 -0
  171. data/spec/fixtures/languages/stub.yml +2 -0
  172. data/spec/fixtures/parsers/coffeescript_parser_fixture_basic.coffee +20 -0
  173. data/spec/fixtures/parsers/coffeescript_parser_fixture_complex.coffee +80 -0
  174. data/spec/fixtures/parsers/css_parser_fixture_basic.css +44 -0
  175. data/spec/fixtures/parsers/css_parser_fixture_complex.css +120 -0
  176. data/spec/fixtures/parsers/javascript_parser_fixture_basic.js +27 -0
  177. data/spec/fixtures/parsers/javascript_parser_fixture_complex.js +85 -0
  178. data/spec/fixtures/parsers/sass_parser_fixture_basic.scss +39 -0
  179. data/spec/fixtures/parsers/sass_parser_fixture_complex.scss +149 -0
  180. data/spec/fixtures/parsers/stylus_parser_fixture_basic.styl +34 -0
  181. data/spec/fixtures/parsers/stylus_parser_fixture_complex.styl +113 -0
  182. data/spec/fixtures/processors/join_with_smart_line_breaks/code_blocks.txt +10 -0
  183. data/spec/fixtures/processors/join_with_smart_line_breaks/headings.txt +15 -0
  184. data/spec/fixtures/processors/join_with_smart_line_breaks/lists.txt +21 -0
  185. data/spec/fixtures/processors/join_with_smart_line_breaks/lists_with_nesting.txt +13 -0
  186. data/spec/fixtures/processors/join_with_smart_line_breaks/multiple_paragraphs.txt +11 -0
  187. data/spec/fixtures/renderers/helpers.rb +37 -0
  188. data/spec/fixtures/renderers/html_output.html +7 -0
  189. data/spec/fixtures/renderers/templates/layouts/application.html.erb +0 -0
  190. data/spec/fixtures/renderers/templates/layouts/more/subdirectory.html.erb +0 -0
  191. data/spec/fixtures/renderers/templates/partials/_leading_underscore.html.erb +1 -0
  192. data/spec/fixtures/renderers/templates/partials/more/_subdirectory.html.erb +1 -0
  193. data/spec/fixtures/renderers/templates/partials/partial.html.erb +0 -0
  194. data/spec/fixtures/renderers/templates/partials/template.html.erb +1 -0
  195. data/spec/fixtures/renderers/templates/template.html.erb +1 -0
  196. data/spec/fixtures/tags/description/button.md +24 -0
  197. data/spec/fixtures/tags/description/class.md +27 -0
  198. data/spec/fixtures/tags/description/component.md +23 -0
  199. data/spec/fixtures/tags/description/function.md +30 -0
  200. data/spec/lib/build_spec.rb +467 -0
  201. data/spec/lib/cache_spec.rb +175 -0
  202. data/spec/lib/command_line_spec.rb +77 -0
  203. data/spec/lib/configuration_spec.rb +180 -0
  204. data/spec/lib/containers/base_container_spec.rb +214 -0
  205. data/spec/lib/containers/class_container_spec.rb +209 -0
  206. data/spec/lib/containers/component_container_spec.rb +158 -0
  207. data/spec/lib/containers/demo_container_spec.rb +113 -0
  208. data/spec/lib/containers/function_container_spec.rb +116 -0
  209. data/spec/lib/containers/mixin_container_spec.rb +4 -0
  210. data/spec/lib/containers/pattern_container_spec.rb +291 -0
  211. data/spec/lib/containers/pattern_library_container_spec.rb +130 -0
  212. data/spec/lib/containers/symbol_container_spec.rb +216 -0
  213. data/spec/lib/containers/variable_container_spec.rb +116 -0
  214. data/spec/lib/containers/variation_container_spec.rb +52 -0
  215. data/spec/lib/containers_spec.rb +22 -0
  216. data/spec/lib/descriptor_spec.rb +73 -0
  217. data/spec/lib/group_spec.rb +151 -0
  218. data/spec/lib/helpers/path_helper_spec.rb +202 -0
  219. data/spec/lib/helpers/render_helper_spec.rb +159 -0
  220. data/spec/lib/helpers_spec.rb +35 -0
  221. data/spec/lib/languages/base_language_spec.rb +32 -0
  222. data/spec/lib/languages/coffeescript_language_spec.rb +52 -0
  223. data/spec/lib/languages/css_language_spec.rb +13 -0
  224. data/spec/lib/languages/erb_language_spec.rb +33 -0
  225. data/spec/lib/languages/haml_language_spec.rb +32 -0
  226. data/spec/lib/languages/javascript_language_spec.rb +54 -0
  227. data/spec/lib/languages/json_language_spec.rb +24 -0
  228. data/spec/lib/languages/less_language_spec.rb +39 -0
  229. data/spec/lib/languages/markup_language_spec.rb +95 -0
  230. data/spec/lib/languages/sass_language_spec.rb +53 -0
  231. data/spec/lib/languages/slim_language_spec.rb +32 -0
  232. data/spec/lib/languages/stylus_language_spec.rb +34 -0
  233. data/spec/lib/languages/yaml_language_spec.rb +24 -0
  234. data/spec/lib/languages_spec.rb +127 -0
  235. data/spec/lib/markdown_spec.rb +63 -0
  236. data/spec/lib/messenger_spec.rb +1 -0
  237. data/spec/lib/naming_conventions/bem_naming_convention_spec.rb +112 -0
  238. data/spec/lib/naming_conventions/suit_naming_convention_spec.rb +107 -0
  239. data/spec/lib/naming_conventions_spec.rb +28 -0
  240. data/spec/lib/ostruct_spec.rb +15 -0
  241. data/spec/lib/parser_spec.rb +93 -0
  242. data/spec/lib/parsers/base_parser_spec.rb +128 -0
  243. data/spec/lib/parsers/coffeescript_parser_spec.rb +184 -0
  244. data/spec/lib/parsers/css_parser_spec.rb +136 -0
  245. data/spec/lib/parsers/javascript_parser_spec.rb +216 -0
  246. data/spec/lib/parsers/less_parser_spec.rb +111 -0
  247. data/spec/lib/parsers/sass_parser_spec.rb +233 -0
  248. data/spec/lib/parsers/stylus_parser_spec.rb +212 -0
  249. data/spec/lib/process_spec.rb +96 -0
  250. data/spec/lib/processors_spec.rb +555 -0
  251. data/spec/lib/renderers/base_renderer_spec.rb +122 -0
  252. data/spec/lib/renderers/common_features/helperable_spec.rb +30 -0
  253. data/spec/lib/renderers/erb_renderer_spec.rb +119 -0
  254. data/spec/lib/renderers/haml_renderer_spec.rb +103 -0
  255. data/spec/lib/renderers/slim_renderer_spec.rb +103 -0
  256. data/spec/lib/symbol_sources/jquery_symbol_source_spec.rb +25 -0
  257. data/spec/lib/symbol_sources/mdn_symbol_source_spec.rb +40 -0
  258. data/spec/lib/symbol_sources/sass_symbol_source_spec.rb +39 -0
  259. data/spec/lib/symbol_sources_spec.rb +19 -0
  260. data/spec/lib/tags/access_tag_spec.rb +32 -0
  261. data/spec/lib/tags/activate_with_tag_spec.rb +31 -0
  262. data/spec/lib/tags/active_tag_spec.rb +24 -0
  263. data/spec/lib/tags/alias_tag_spec.rb +31 -0
  264. data/spec/lib/tags/author_tag_spec.rb +172 -0
  265. data/spec/lib/tags/base_tag_spec.rb +21 -0
  266. data/spec/lib/tags/beta_tag_spec.rb +52 -0
  267. data/spec/lib/tags/class_tag_spec.rb +29 -0
  268. data/spec/lib/tags/compatibility_tag_spec.rb +159 -0
  269. data/spec/lib/tags/demo_type_tag_spec.rb +24 -0
  270. data/spec/lib/tags/deprecated_tag_spec.rb +50 -0
  271. data/spec/lib/tags/description_tag_spec.rb +242 -0
  272. data/spec/lib/tags/example_tag_spec.rb +37 -0
  273. data/spec/lib/tags/factory_tag_spec.rb +29 -0
  274. data/spec/lib/tags/for_tag_spec.rb +45 -0
  275. data/spec/lib/tags/group_tag_spec.rb +20 -0
  276. data/spec/lib/tags/helper_tag_spec.rb +22 -0
  277. data/spec/lib/tags/include_with_tag_spec.rb +74 -0
  278. data/spec/lib/tags/javascript_action_tag_spec.rb +20 -0
  279. data/spec/lib/tags/link_tag_spec.rb +49 -0
  280. data/spec/lib/tags/markup_tag_spec.rb +255 -0
  281. data/spec/lib/tags/member_tag_spec.rb +167 -0
  282. data/spec/lib/tags/method_tag_spec.rb +27 -0
  283. data/spec/lib/tags/name_tag_spec.rb +20 -0
  284. data/spec/lib/tags/object_tag_spec.rb +24 -0
  285. data/spec/lib/tags/param_tag_spec.rb +261 -0
  286. data/spec/lib/tags/pattern_tag_spec.rb +49 -0
  287. data/spec/lib/tags/preclude_tag_spec.rb +31 -0
  288. data/spec/lib/tags/private_tag_spec.rb +31 -0
  289. data/spec/lib/tags/property_tag_spec.rb +27 -0
  290. data/spec/lib/tags/public_tag_spec.rb +29 -0
  291. data/spec/lib/tags/require_tag_spec.rb +133 -0
  292. data/spec/lib/tags/returns_tag_spec.rb +85 -0
  293. data/spec/lib/tags/set_by_tag_spec.rb +92 -0
  294. data/spec/lib/tags/signature_tag_spec.rb +125 -0
  295. data/spec/lib/tags/since_tag_spec.rb +48 -0
  296. data/spec/lib/tags/state_tag_spec.rb +199 -0
  297. data/spec/lib/tags/static_tag_spec.rb +27 -0
  298. data/spec/lib/tags/subcomponent_tag_spec.rb +78 -0
  299. data/spec/lib/tags/subtitle_tag_spec.rb +13 -0
  300. data/spec/lib/tags/symbol_type_tag_spec.rb +20 -0
  301. data/spec/lib/tags/throws_tag_spec.rb +49 -0
  302. data/spec/lib/tags/title_tag_spec.rb +20 -0
  303. data/spec/lib/tags/type_tag_spec.rb +20 -0
  304. data/spec/lib/tags/value_tag_spec.rb +20 -0
  305. data/spec/lib/tags/variant_tag_spec.rb +13 -0
  306. data/spec/lib/tags/variation_tag_spec.rb +154 -0
  307. data/spec/lib/tags_spec.rb +264 -0
  308. data/spec/lib/templates_spec.rb +185 -0
  309. data/spec/lib/themes_spec.rb +32 -0
  310. data/spec/spec_helper.rb +34 -0
  311. data/tasks/rspec.rake +7 -0
  312. data/tasks/rubocop.rake +8 -0
  313. metadata +740 -0
@@ -0,0 +1,151 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks do
4
+ subject { described_class }
5
+
6
+ describe ".pattern_id" do
7
+ it "returns a nil identifier when a non-string is passed" do
8
+ expect(subject.pattern_id(:nothing_to_see_here)).to be nil
9
+ end
10
+
11
+ it "uses only the extension-less, base file name" do
12
+ expect(subject.pattern_id("foo/bar/baz/button.min.css")).to eq subject.pattern_id("button")
13
+ end
14
+
15
+ it "strips leading underscores" do
16
+ expect(subject.pattern_id("_checkbox.html.erb")).to eq "checkbox"
17
+ end
18
+
19
+ it "normalizes dashes and underscores" do
20
+ expect(subject.pattern_id("foo_bar_baz")).to eq subject.pattern_id("foo-bar-baz")
21
+ end
22
+ end
23
+
24
+ describe ".pattern_id=" do
25
+ it "allows the pattern identification method to be redefined" do
26
+ built_in_identifier = subject.instance_variable_get(:@pattern_id)
27
+ subject.pattern_id = lambda { |filename| "foo" }
28
+ expect(subject.pattern_id("bar")).to eq "foo"
29
+ subject.pattern_id = built_in_identifier
30
+ end
31
+
32
+ it "does not reassign the pattern identifier unless it returns a result for a valid input" do
33
+ expect { subject.pattern_id = lambda { |file| } }.not_to change { subject.pattern_id("foo") }
34
+ end
35
+ end
36
+ end
37
+
38
+ describe Docks::Grouper do
39
+ subject { Docks::Grouper }
40
+
41
+ before :each do
42
+ Docks::Languages.register_bundled_languages
43
+ end
44
+
45
+ describe ".group" do
46
+ it "returns an empty Hash when no paths are provided" do
47
+ expect(subject.group([])).to eq Hash.new
48
+ end
49
+
50
+ it "returns an empty Hash when the passed glob does not match any files" do
51
+ pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/non-existent-thing/*")
52
+ expect(subject.group(pattern)).to eq Hash.new
53
+ end
54
+
55
+ it "groups together files of the same name that match the passed globbing patterns in an Array" do
56
+ pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/button/*")
57
+ files = Dir.glob(pattern)
58
+
59
+ group_result = subject.group(pattern)
60
+ button_result = group_result[Docks.pattern_id(files.first)]
61
+
62
+ expect(button_result).to eq files
63
+ end
64
+
65
+ it "groups together files of the same name that match the passed globbing patterns with multiple globbing patterns, some of which do not reference actual files" do
66
+ button_pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/button/*")
67
+ button_files = Dir.glob(button_pattern)
68
+ pattern_non_match = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/non-existent-thing/*")
69
+
70
+ group_result = subject.group([button_pattern, pattern_non_match])
71
+ button_result = group_result[Docks.pattern_id(button_files.first)]
72
+
73
+ expect(button_result).to eq button_files
74
+ end
75
+
76
+ it "groups together files of the same name that match the passed globbing patterns with multiple globbing patterns that match" do
77
+ button_pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/button/*")
78
+ button_files = Dir.glob(button_pattern)
79
+
80
+ tab_pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/next-tab/*")
81
+ tab_files = Dir.glob(tab_pattern)
82
+
83
+ group_result = subject.group([button_pattern, tab_pattern])
84
+ button_result = group_result[Docks.pattern_id(button_files.first)]
85
+ tab_result = group_result[Docks.pattern_id(tab_files.first)]
86
+
87
+ expect(button_result).to eq button_files
88
+ expect(tab_result).to eq tab_files
89
+ end
90
+
91
+ context "when components are spread across folders" do
92
+ let(:globs) do
93
+ [
94
+ File.join(File.dirname(__FILE__), "../fixtures/grouper/markup/**/*.haml"),
95
+ File.join(File.dirname(__FILE__), "../fixtures/grouper/scripts/**/*.coffee"),
96
+ File.join(File.dirname(__FILE__), "../fixtures/grouper/style/**/*.scss")
97
+ ]
98
+ end
99
+
100
+ let(:result) { subject.group(globs) }
101
+ let(:expected_results) do
102
+ {
103
+ "resizable" => 2,
104
+ "list_view" => 2,
105
+ "toggle" => 3
106
+ }
107
+ end
108
+
109
+ it "groups together files in dedicated scripts/ markup/ style folders" do
110
+ expected_results.each do |group, file_count|
111
+ expect(result[group].length).to eq file_count
112
+ end
113
+ end
114
+
115
+ it "groups together files in dedicated scripts/ markup/ style folders and in component folders" do
116
+ globs << File.join(File.dirname(__FILE__), "../fixtures/grouper/components/button/*")
117
+ globs << File.join(File.dirname(__FILE__), "../fixtures/grouper/components/checkbox/*")
118
+ expected_results["button"] = 3
119
+ expected_results["checkbox"] = 3
120
+
121
+ result = subject.group(globs)
122
+
123
+ expected_results.each do |group, file_count|
124
+ expect(result[group].length).to eq file_count
125
+ end
126
+ end
127
+ end
128
+
129
+ describe "acceptance criteria" do
130
+ it "rejects minified files" do
131
+ pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/segmented control/*")
132
+ files = Dir.glob(pattern).reject! { |filename| filename =~ /\.min\..*$/ }
133
+
134
+ group_result = subject.group(pattern)
135
+ component_result = group_result[Docks.pattern_id(files.first)]
136
+
137
+ expect(component_result).to eq files
138
+ end
139
+
140
+ it "rejects files not recognized by Docks" do
141
+ pattern = File.join(File.dirname(__FILE__), "../fixtures/grouper/components/form/*")
142
+ files = Dir.glob(pattern).select! { |filename| Docks::Languages.extensions.include?(File.extname(filename)[1..-1]) }
143
+
144
+ group_result = subject.group(pattern)
145
+ component_result = group_result[Docks.pattern_id(files.first)]
146
+
147
+ expect(component_result).to eq files
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,202 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Helpers::Path do
4
+ subject do
5
+ Class.new { include Docks::Helpers::Path }.new
6
+ end
7
+
8
+ let(:pattern_library) { Docks::Containers::PatternLibrary.new }
9
+ let(:pattern) { Docks::Containers::Pattern.new(name: "foo") }
10
+
11
+ before(:each) do
12
+ Docks::Languages.register_bundled_languages
13
+ Docks.current_render_destination = Docks.config.destination + "baz/index.html"
14
+ subject.instance_variable_set(:@pattern_library, pattern_library)
15
+ subject.instance_variable_set(:@pattern, pattern)
16
+ end
17
+
18
+ describe "#docks_path" do
19
+ it "returns the anchor for a search that is found in the pattern" do
20
+ result = Docks::Containers::Symbol.new(name: "foo")
21
+ expect(pattern).to receive(:find).with("foo").and_return result
22
+ expect(subject.docks_path("foo")).to eq "##{result.symbol_id}"
23
+ end
24
+
25
+ it "returns the anchor for a search that is found in the pattern library" do
26
+ result = Docks::Containers::Symbol.new(name: "foo")
27
+ expect(pattern_library).to receive(:find).with("bar").and_return OpenStruct.new(pattern: pattern, symbol: result)
28
+ expect(subject.docks_path("bar")).to eq "#{subject.relative_asset_path(subject.pattern_path(pattern))}##{result.symbol_id}"
29
+ end
30
+
31
+ it "returns a path from the registered symbol sources if one exists" do
32
+ expect(subject.docks_path("Object")).to eq Docks::SymbolSources.path_for("Object")
33
+ end
34
+
35
+ context "when there are multiple requests for the same thing" do
36
+ it "caches the result of the same path request" do
37
+ expected = Docks::SymbolSources.path_for("Object")
38
+ expect(Docks::SymbolSources).to receive(:path_for).with("Object", anything).once.and_call_original
39
+ subject.docks_path("Object")
40
+ subject.docks_path("Object")
41
+
42
+ result = Docks::Containers::Symbol.new(name: "foo")
43
+ expect(pattern).to receive(:find).with("foo").once.and_return result
44
+ subject.docks_path("foo")
45
+ subject.docks_path("foo")
46
+ end
47
+
48
+ it "caches the results of requests that have different language options" do
49
+ sass_expected = Docks::SymbolSources.path_for("Map", language: :sass)
50
+ js_expected = Docks::SymbolSources.path_for("Map", language: :js)
51
+
52
+ expect(Docks::SymbolSources).to receive(:path_for).with("Map", language: :sass).once.and_call_original
53
+ expect(Docks::SymbolSources).to receive(:path_for).with("Map", language: :js).once.and_call_original
54
+
55
+ subject.docks_path("Map", language: :sass)
56
+ subject.docks_path("Map", language: :js)
57
+ subject.docks_path("Map", language: :sass)
58
+ subject.docks_path("Map", language: :js)
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#stylesheet_link_tag" do
64
+ let(:expected_path) { subject.relative_asset_path(Docks.config.destination + "styles/style.css").to_s }
65
+
66
+ it "returns a relative path to the stylesheet" do
67
+ output = subject.stylesheet_link_tag("style")
68
+ expect(output).to have_tag :link, with: { rel: "stylesheet", type: "text/css", href: expected_path }
69
+ end
70
+
71
+ it "doesn't duplicate the filename" do
72
+ output = subject.stylesheet_link_tag("style.css")
73
+ expect(output).to have_tag :link, with: { href: expected_path }
74
+ end
75
+
76
+ it "prints absolute paths directly" do
77
+ output = subject.stylesheet_link_tag("/foo/bar.css")
78
+ expect(output).to have_tag :link, with: { rel: "stylesheet", type: "text/css", href: "/foo/bar.css" }
79
+ end
80
+ end
81
+
82
+ describe "#javascript_include_tag" do
83
+ let(:expected_path) { subject.relative_asset_path(Docks.config.destination + "scripts/script.js").to_s }
84
+
85
+ it "returns a relative path to the script" do
86
+ output = subject.javascript_include_tag("script")
87
+ expect(output).to have_tag :script, with: { src: expected_path }
88
+ end
89
+
90
+ it "doesn't duplicate the filename" do
91
+ output = subject.javascript_include_tag("script.js")
92
+ expect(output).to have_tag :script, with: { src: expected_path }
93
+ end
94
+
95
+ it "handles absolute paths" do
96
+ output = subject.javascript_include_tag("/foo/bar.css")
97
+ expect(output).to have_tag :script, with: { src: "/foo/bar.css" }
98
+ end
99
+ end
100
+
101
+ describe "#relative_asset_path" do
102
+ it "returns a path relative to the current render destination" do
103
+ expect(subject.relative_asset_path(Docks.current_render_destination)).to eq Pathname.new(".")
104
+ expect(subject.relative_asset_path(Docks.current_render_destination + "foo/bar.baz")).to eq Pathname.new("foo/bar.baz")
105
+ expect(subject.relative_asset_path(Docks.current_render_destination.dirname)).to eq Pathname.new("..")
106
+ end
107
+ end
108
+
109
+ describe "#pattern_path" do
110
+ let(:expected_path) { Docks.config.destination + File.join(Docks.config.mount_at, pattern.name, "index.html") }
111
+
112
+ it "Gives the full path to a pattern's index file" do
113
+ expect(subject.pattern_path(pattern)).to eq expected_path
114
+ end
115
+
116
+ it "adds an anchor if provided" do
117
+ expect(subject.pattern_path(pattern, anchor: "bar")).to eq Pathname.new("#{expected_path.to_s}#bar")
118
+ end
119
+ end
120
+
121
+ describe "#compiled_style_tags" do
122
+ let(:css_filename) { "foo.css" }
123
+
124
+ it "returns nothing when the compiled assets are empty" do
125
+ expect(subject.compiled_style_tags).to be nil
126
+
127
+ Docks.configure_with(compiled_assets: [])
128
+ expect(subject.compiled_style_tags).to be nil
129
+
130
+ Docks.configure_with(compiled_assets: nil)
131
+ expect(subject.compiled_style_tags).to be nil
132
+ end
133
+
134
+ it "includes CSS assets" do
135
+ Docks.configure_with(compiled_assets: [css_filename, "bar.scss", "baz.js"])
136
+ expected = subject.stylesheet_link_tag(css_filename)
137
+
138
+ expect(subject).to receive(:stylesheet_link_tag).with(css_filename).and_call_original
139
+
140
+ expect(subject).not_to receive(:stylesheet_link_tag).with("bar.scss")
141
+ expect(subject).not_to receive(:stylesheet_link_tag).with("baz.js")
142
+
143
+ expect(subject.compiled_style_tags).to eq expected
144
+ end
145
+ end
146
+
147
+ describe "#compiled_script_tags" do
148
+ let(:js_filename) { "foo.js" }
149
+
150
+ it "returns nothing when the compiled assets are empty" do
151
+ expect(subject.compiled_script_tags).to be nil
152
+
153
+ Docks.configure_with(compiled_assets: [])
154
+ expect(subject.compiled_script_tags).to be nil
155
+
156
+ Docks.configure_with(compiled_assets: nil)
157
+ expect(subject.compiled_script_tags).to be nil
158
+ end
159
+
160
+ it "includes JavaScript assets" do
161
+ Docks.configure_with(compiled_assets: [js_filename, "bar.coffee", "baz.css"])
162
+ expected = subject.javascript_include_tag(js_filename)
163
+
164
+ expect(subject).to receive(:javascript_include_tag).with(js_filename).and_call_original
165
+ expect(subject).not_to receive(:javascript_include_tag).with("bar.scss")
166
+ expect(subject).not_to receive(:javascript_include_tag).with("baz.js")
167
+
168
+ expect(subject.compiled_script_tags).to eq expected
169
+ end
170
+ end
171
+
172
+ describe "#docks_stylesheet" do
173
+ it "returns a stylesheet link to the main stylesheet" do
174
+ expect(subject.docks_stylesheet).to eq subject.stylesheet_link_tag("docks.css")
175
+ end
176
+
177
+ it "returns a stylesheet link with the provided postfix" do
178
+ expect(subject.docks_stylesheet(:demo)).to eq subject.stylesheet_link_tag("docks-demo.css")
179
+ end
180
+
181
+ it "returns nothing when config.use_theme_assets is false" do
182
+ Docks.configure_with(use_theme_assets: false)
183
+ expect(subject.docks_stylesheet).to be nil
184
+ end
185
+ end
186
+
187
+ describe "#docks_javascript" do
188
+ it "returns a script tag to the main javascript file" do
189
+ expect(subject.docks_javascript).to eq subject.javascript_include_tag("docks.js")
190
+ end
191
+
192
+ it "returns a script tag with the provided postfix" do
193
+ expect(subject.docks_javascript(:demo)).to eq subject.javascript_include_tag("docks_demo.js")
194
+ end
195
+
196
+ it "returns nothing when config.use_theme_assets is false" do
197
+ Docks.configure_with(use_theme_assets: false)
198
+ expect(subject.docks_javascript).to be nil
199
+ end
200
+ end
201
+ end
202
+
@@ -0,0 +1,159 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Helpers::Render do
4
+ subject do
5
+ Class.new { include Docks::Helpers::Render }.new
6
+ end
7
+
8
+ describe "#render_everything" do
9
+ let(:pattern) { Docks::Containers::Pattern.new(name: "foo") }
10
+ let(:component) { Docks::Containers::Component.new(name: "foo") }
11
+ before(:each) { subject.instance_variable_set(:@pattern, pattern) }
12
+
13
+ describe "markup" do
14
+ let(:markup) { "<% 5.times do %>foo<% end %>" }
15
+ let(:output) { "foo" * 5 }
16
+ before(:each) { pattern.add(:style, component) }
17
+
18
+ it "does nothing for non-symbols" do
19
+ pattern.param = OpenStruct.new(markup: markup)
20
+ expect(subject).to_not receive(:render)
21
+ subject.render_everything
22
+ end
23
+
24
+ it "does nothing for symbols without helper or markup" do
25
+ expect(subject).to_not receive(:render)
26
+ subject.render_everything
27
+ end
28
+
29
+ it "renders markup on the component" do
30
+ component.markup = markup
31
+ expect(subject).to receive(:render).with(inline: markup, layout: false).and_return(output)
32
+ subject.render_everything
33
+ expect(component.markup).to eq output
34
+ end
35
+
36
+ it "renders helper on the component" do
37
+ component.helper = markup
38
+ expect(subject).to receive(:render).with(inline: markup, layout: false).and_return(output)
39
+ subject.render_everything
40
+ expect(component.markup).to eq output
41
+ end
42
+
43
+ it "renders markup on nested variations" do
44
+ state = Docks::Containers::State.new(name: "foo--bar", markup: markup)
45
+ component.states << state
46
+ expect(subject).to receive(:render).with(inline: markup, layout: false).and_return(output)
47
+ subject.render_everything
48
+ expect(state.markup).to eq output
49
+ end
50
+
51
+ it "renders helpers on nested variations" do
52
+ state = Docks::Containers::State.new(name: "foo--bar", helper: markup)
53
+ component.states << state
54
+ expect(subject).to receive(:render).with(inline: markup, layout: false).and_return(output)
55
+ subject.render_everything
56
+ expect(state.markup).to eq output
57
+ end
58
+ end
59
+
60
+ describe "description" do
61
+ let(:description) { "<% %w(foo bar baz).each do |a| %><%= a %> <% end %>" }
62
+ let(:output) { "foo bar baz" }
63
+
64
+ it "renders the pattern description" do
65
+ pattern.description = description
66
+ expect(subject).to receive(:render).with(inline: description, layout: false).and_return(output)
67
+ subject.render_everything
68
+ expect(pattern.description).to eq output
69
+ end
70
+
71
+ it "renders the description on symbols" do
72
+ component.description = description
73
+ pattern.add(:style, component)
74
+ expect(subject).to receive(:render).with(inline: description, layout: false).and_return(output)
75
+ subject.render_everything
76
+ expect(component.description).to eq output
77
+ end
78
+
79
+ it "renders the description on nested objects" do
80
+ param = Docks::OpenStruct.new(description: description)
81
+ component.params = [param]
82
+ pattern.add(:style, component)
83
+ expect(subject).to receive(:render).with(inline: description, layout: false).and_return(output)
84
+ subject.render_everything
85
+ expect(param.description).to eq output
86
+ end
87
+
88
+ it "doesn't kill the kind of object a nested object originally was" do
89
+ param = Docks::OpenStruct.new(description: description)
90
+ component.params = [param]
91
+ pattern.add(:style, component)
92
+ expect(subject).to receive(:render).with(inline: description, layout: false).and_return(output)
93
+ subject.render_everything
94
+ expect(component.params.first).to be param
95
+ end
96
+
97
+ it "renders @link declarations" do
98
+ allow(subject).to receive(:render) { |opts| opts[:inline] }
99
+ pattern.description = "foo bar <a href='@link Baz'>baz</a>"
100
+ expect(subject).to receive(:docks_path).with("Baz", hash_including(:language)).and_return("/pattern-library/baz")
101
+ subject.render_everything
102
+ expect(pattern.description).to eq "foo bar <a href='/pattern-library/baz'>baz</a>"
103
+ end
104
+
105
+ context "when there is a code block" do
106
+ before(:each) do
107
+ allow(subject).to receive(:render) { |opts| opts[:inline] }
108
+ end
109
+
110
+ let(:code_block) { "<div>\n Foo\n</div>" }
111
+ let(:language) { "html" }
112
+ let(:markdown) { Redcarpet::Markdown.new(Docks::Markdown::Renderer, fenced_code_blocks: true) }
113
+
114
+ it "renders a code block" do
115
+ pattern.description = markdown.render(markdown_code_block)
116
+ expect(subject).to receive(:docks_code_block) do |options|
117
+ expect(options[:hideable?]).to be false
118
+ expect(options[:demo?]).to be false
119
+
120
+ code = options[:code]
121
+ expect(code.length).to be 1
122
+ expect(code.first[:code].strip).to eq code_block
123
+ expect(code.first[:language]).to eq language
124
+ end
125
+
126
+ subject.render_everything
127
+ end
128
+
129
+ it "renders a code block with the a demo" do
130
+ pattern.description = markdown.render(markdown_code_block(with_demo: true))
131
+ expect(subject).to receive(:docks_code_block) do |options|
132
+ expect(options[:hideable?]).to be true
133
+ expect(options[:demo?]).to be true
134
+ end
135
+
136
+ subject.render_everything
137
+ end
138
+
139
+ it "adds a unique ID to each demo" do
140
+ pattern.description = markdown.render(markdown_code_block * 2)
141
+
142
+ ids = []
143
+ expect(subject).to receive(:docks_code_block).twice do |options|
144
+ ids.push(options[:id])
145
+ end
146
+
147
+ subject.render_everything
148
+ expect(ids).to eq ids.uniq
149
+ end
150
+
151
+ private
152
+
153
+ def markdown_code_block(options = {})
154
+ options.fetch(:with_demo, false) ? "```#{language}_demo\n#{code_block}\n```" : "```#{language}\n#{code_block}\n```\n"
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Helpers do
4
+ describe ".add_helpers_to" do
5
+ let(:renderer) { Docks::Renderers::ERB.new }
6
+
7
+ it "adds all bundled helpers" do
8
+ helpers = []
9
+ allow(renderer).to receive(:helpers) do |*args|
10
+ helpers = helpers.concat(args)
11
+ end
12
+
13
+ described_class.add_helpers_to(renderer)
14
+
15
+ described_class.constants.each do |const|
16
+ expect(helpers).to include described_class.const_get(const)
17
+ end
18
+ end
19
+
20
+ it "adds any user-configured helpers" do
21
+ Docks.configure_with helpers: ["foo.txt", "bar.txt"]
22
+
23
+ helpers = []
24
+ allow(renderer).to receive(:helpers) do |*args|
25
+ helpers = helpers.concat(args)
26
+ end
27
+
28
+ described_class.add_helpers_to(renderer)
29
+
30
+ Docks.config.helpers.each do |helper|
31
+ expect(helpers).to include helper
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Languages::Base do
4
+ subject { Docks::Languages::Base.instance }
5
+
6
+ describe "#load_stub" do
7
+ it "doesn't do anything to load a stub file" do
8
+ expect(subject.load_stub("foo.bar")).to be nil
9
+ end
10
+ end
11
+ end
12
+
13
+ describe Docks::Languages do
14
+ subject { Docks::Languages }
15
+
16
+ describe ".bundled_languages" do
17
+ it "has all bundled languages except the base language" do
18
+ bundled_languages = subject.bundled_languages
19
+
20
+ subject.constants.each do |const|
21
+ klass = subject.const_get(const)
22
+ next unless Class === klass && !(klass.eql?(subject::Base))
23
+ expect(bundled_languages).to include klass
24
+ end
25
+ end
26
+
27
+ it "caches the bundled languages for subsequent calls" do
28
+ before = subject.bundled_languages
29
+ expect(subject.bundled_languages).to be before
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,52 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Languages::CoffeeScript do
4
+ subject { Docks::Languages::CoffeeScript.instance }
5
+
6
+ describe ".extensions" do
7
+ let(:extensions) { [subject.class.extensions].flatten }
8
+
9
+ it "includes .coffee as an extension" do
10
+ expect(extensions).to include "coffee"
11
+ end
12
+
13
+ it "includes .coffeescript as an extension" do
14
+ expect(extensions).to include "coffeescript"
15
+ end
16
+ end
17
+
18
+ describe "#signature_for" do
19
+ let(:name) { "foo" }
20
+ let(:function_no_params) { Docks::Containers::Function.new(name: name) }
21
+ let(:function_with_params) { Docks::Containers::Function.new(name: name, params: [OpenStruct.new(name: "bar"), OpenStruct.new(name: "baz", default: "'qux'")]) }
22
+ let(:klass) { Docks::Containers::Klass.new(name: name.capitalize, params: function_with_params.params) }
23
+ let(:something_else) { Docks::Containers::Variable.new(name: "bar") }
24
+
25
+ it "gives a signature to functions with no params" do
26
+ expect(subject.signature_for(function_no_params)).to eq "#{function_no_params.name} = -> # ..."
27
+ end
28
+
29
+ it "gives a signature to functions with params, including default values" do
30
+ expect(subject.signature_for(function_with_params)).to eq "#{function_with_params.name} = (bar, baz = 'qux') -> # ..."
31
+ end
32
+
33
+ it "gives a signature for classes with params, including default values" do
34
+ expect(subject.signature_for(klass)).to eq "class #{klass.name}\n constructor: (bar, baz = 'qux') -> # ..."
35
+ end
36
+
37
+ it "gives a signature to instance methods" do
38
+ klass.add_member(function_with_params)
39
+ expect(subject.signature_for(function_with_params)).to eq "#{function_with_params.name}: (bar, baz = 'qux') -> # ..."
40
+ end
41
+
42
+ it "gives a signature to static methods" do
43
+ function_with_params.static = true
44
+ klass.add_member(function_with_params)
45
+ expect(subject.signature_for(function_with_params)).to eq "#{klass.name}.#{function_with_params.name} = (bar, baz = 'qux') -> # ..."
46
+ end
47
+
48
+ it "doesn't provide a signature for a non-function symbol" do
49
+ expect(subject.signature_for(something_else)).to be nil
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Languages::CSS do
4
+ subject { Docks::Languages::CSS.instance }
5
+
6
+ describe ".extensions" do
7
+ let(:extensions) { [subject.class.extensions].flatten }
8
+
9
+ it "includes .css as an extension" do
10
+ expect(extensions).to include "css"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Languages::ERB do
4
+ subject { Docks::Languages::ERB.instance }
5
+
6
+ describe ".extensions" do
7
+ let(:extensions) { [subject.class.extensions].flatten }
8
+
9
+ it "includes .erb as an extension" do
10
+ expect(extensions).to include "erb"
11
+ end
12
+ end
13
+
14
+ describe "#helper_markup_for" do
15
+ let(:mixed_arguments) { ["hello", 10, false, :goodbye, { bar: "baz", "baz" => :qux }] }
16
+ let(:mixed_arguments_output) { "\"hello\", 10, false, :goodbye, bar: \"baz\",\n#{" " * 38}\"baz\" => :qux" }
17
+ let(:argumentless_hash) { { "baz" => :qux } }
18
+ let(:argumentless_hash_output) { "\"baz\" => :qux" }
19
+
20
+ it "converts an array of arguments into the corresponding function" do
21
+ expect(subject.helper_markup_for("foo", mixed_arguments)).to eq "<%= foo #{mixed_arguments_output} %>"
22
+ end
23
+
24
+ it "converts a hash with an arguments key into the corresponding function" do
25
+ expect(subject.helper_markup_for("foo", arguments: mixed_arguments)).to eq "<%= foo #{mixed_arguments_output} %>"
26
+ end
27
+
28
+ it "converts a hash without an array key into a function with the hash as the only param" do
29
+ expect(subject.helper_markup_for("foo", argumentless_hash)).to eq "<%= foo #{argumentless_hash_output} %>"
30
+ end
31
+ end
32
+ end
33
+