docks_app 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.editorconfig +8 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +3 -0
- data/bin/docks +5 -0
- data/config/json/docks_config.json +71 -0
- data/config/ruby/docks_config.rb +127 -0
- data/config/yaml/docks_config.yml +70 -0
- data/docks.gemspec +38 -0
- data/lib/docks/build.rb +300 -0
- data/lib/docks/cache.rb +143 -0
- data/lib/docks/command_line.rb +65 -0
- data/lib/docks/configuration.rb +217 -0
- data/lib/docks/containers/base_container.rb +103 -0
- data/lib/docks/containers/class_container.rb +39 -0
- data/lib/docks/containers/component_container.rb +92 -0
- data/lib/docks/containers/demo_container.rb +105 -0
- data/lib/docks/containers/factory_container.rb +12 -0
- data/lib/docks/containers/function_container.rb +46 -0
- data/lib/docks/containers/mixin_container.rb +19 -0
- data/lib/docks/containers/pattern_container.rb +168 -0
- data/lib/docks/containers/pattern_library_container.rb +77 -0
- data/lib/docks/containers/state_container.rb +9 -0
- data/lib/docks/containers/symbol_container.rb +77 -0
- data/lib/docks/containers/variable_container.rb +47 -0
- data/lib/docks/containers/variant_container.rb +9 -0
- data/lib/docks/containers/variation_container.rb +38 -0
- data/lib/docks/containers.rb +25 -0
- data/lib/docks/descriptor.rb +60 -0
- data/lib/docks/errors.rb +5 -0
- data/lib/docks/group.rb +66 -0
- data/lib/docks/helpers/github_helper.rb +29 -0
- data/lib/docks/helpers/path_helper.rb +94 -0
- data/lib/docks/helpers/render_helper.rb +87 -0
- data/lib/docks/helpers.rb +19 -0
- data/lib/docks/languages/base_language.rb +17 -0
- data/lib/docks/languages/coffeescript_language.rb +30 -0
- data/lib/docks/languages/common_types/markup_language.rb +71 -0
- data/lib/docks/languages/css_language.rb +13 -0
- data/lib/docks/languages/erb_language.rb +21 -0
- data/lib/docks/languages/haml_language.rb +21 -0
- data/lib/docks/languages/html_language.rb +10 -0
- data/lib/docks/languages/javascript_language.rb +42 -0
- data/lib/docks/languages/json_language.rb +18 -0
- data/lib/docks/languages/less_language.rb +33 -0
- data/lib/docks/languages/markdown_language.rb +10 -0
- data/lib/docks/languages/sass_language.rb +36 -0
- data/lib/docks/languages/slim_language.rb +21 -0
- data/lib/docks/languages/stylus_language.rb +26 -0
- data/lib/docks/languages/yaml_language.rb +18 -0
- data/lib/docks/languages.rb +103 -0
- data/lib/docks/markdown.rb +18 -0
- data/lib/docks/messenger.rb +69 -0
- data/lib/docks/naming_conventions/base_naming_convention.rb +9 -0
- data/lib/docks/naming_conventions/bem_naming_convention.rb +45 -0
- data/lib/docks/naming_conventions/suit_naming_convention.rb +45 -0
- data/lib/docks/naming_conventions.rb +21 -0
- data/lib/docks/ostruct.rb +17 -0
- data/lib/docks/parser.rb +86 -0
- data/lib/docks/parsers/base_parser.rb +128 -0
- data/lib/docks/parsers/coffeescript_parser.rb +30 -0
- data/lib/docks/parsers/css_parser.rb +27 -0
- data/lib/docks/parsers/javascript_parser.rb +30 -0
- data/lib/docks/parsers/less_parser.rb +22 -0
- data/lib/docks/parsers/sass_parser.rb +31 -0
- data/lib/docks/parsers/stylus_parser.rb +28 -0
- data/lib/docks/process.rb +60 -0
- data/lib/docks/processors.rb +416 -0
- data/lib/docks/renderers/base_renderer.rb +64 -0
- data/lib/docks/renderers/common_features/capturable.rb +69 -0
- data/lib/docks/renderers/common_features/helperable.rb +23 -0
- data/lib/docks/renderers/erb_renderer.rb +68 -0
- data/lib/docks/renderers/haml_renderer.rb +37 -0
- data/lib/docks/renderers/slim_renderer.rb +33 -0
- data/lib/docks/symbol_sources/base_symbol_source.rb +12 -0
- data/lib/docks/symbol_sources/jquery_symbol_source.rb +17 -0
- data/lib/docks/symbol_sources/mdn_symbol_source.rb +35 -0
- data/lib/docks/symbol_sources/sass_symbol_source.rb +27 -0
- data/lib/docks/symbol_sources.rb +28 -0
- data/lib/docks/tags/access_tag.rb +27 -0
- data/lib/docks/tags/activate_with_tag.rb +17 -0
- data/lib/docks/tags/active_tag.rb +14 -0
- data/lib/docks/tags/alias_tag.rb +17 -0
- data/lib/docks/tags/author_tag.rb +19 -0
- data/lib/docks/tags/base_tag.rb +52 -0
- data/lib/docks/tags/beta_tag.rb +26 -0
- data/lib/docks/tags/class_tag.rb +16 -0
- data/lib/docks/tags/compatibility_tag.rb +19 -0
- data/lib/docks/tags/demo_type_tag.rb +14 -0
- data/lib/docks/tags/deprecated_tag.rb +26 -0
- data/lib/docks/tags/description_tag.rb +99 -0
- data/lib/docks/tags/example_tag.rb +20 -0
- data/lib/docks/tags/factory_tag.rb +16 -0
- data/lib/docks/tags/for_tag.rb +23 -0
- data/lib/docks/tags/group_tag.rb +10 -0
- data/lib/docks/tags/helper_tag.rb +13 -0
- data/lib/docks/tags/include_with_tag.rb +57 -0
- data/lib/docks/tags/javascript_action_tag.rb +10 -0
- data/lib/docks/tags/link_tag.rb +18 -0
- data/lib/docks/tags/markup_tag.rb +106 -0
- data/lib/docks/tags/member_tag.rb +37 -0
- data/lib/docks/tags/method_tag.rb +18 -0
- data/lib/docks/tags/name_tag.rb +10 -0
- data/lib/docks/tags/object_tag.rb +15 -0
- data/lib/docks/tags/param_tag.rb +94 -0
- data/lib/docks/tags/pattern_tag.rb +21 -0
- data/lib/docks/tags/preclude_tag.rb +17 -0
- data/lib/docks/tags/private_tag.rb +15 -0
- data/lib/docks/tags/property_tag.rb +18 -0
- data/lib/docks/tags/public_tag.rb +15 -0
- data/lib/docks/tags/require_tag.rb +47 -0
- data/lib/docks/tags/returns_tag.rb +31 -0
- data/lib/docks/tags/set_by_tag.rb +18 -0
- data/lib/docks/tags/signature_tag.rb +35 -0
- data/lib/docks/tags/since_tag.rb +26 -0
- data/lib/docks/tags/source_tag.rb +12 -0
- data/lib/docks/tags/state_tag.rb +21 -0
- data/lib/docks/tags/static_tag.rb +14 -0
- data/lib/docks/tags/subcomponent_tag.rb +68 -0
- data/lib/docks/tags/subtitle_tag.rb +11 -0
- data/lib/docks/tags/symbol_type_tag.rb +10 -0
- data/lib/docks/tags/throws_tag.rb +30 -0
- data/lib/docks/tags/title_tag.rb +10 -0
- data/lib/docks/tags/type_tag.rb +10 -0
- data/lib/docks/tags/value_tag.rb +10 -0
- data/lib/docks/tags/variant_tag.rb +21 -0
- data/lib/docks/tags/variation_tag.rb +136 -0
- data/lib/docks/tags.rb +103 -0
- data/lib/docks/templates.rb +122 -0
- data/lib/docks/themes.rb +19 -0
- data/lib/docks/types.rb +26 -0
- data/lib/docks/version.rb +3 -0
- data/lib/docks.rb +37 -0
- data/spec/fixtures/build/scripts/bar/bar_2.js +1 -0
- data/spec/fixtures/build/scripts/bar.js +1 -0
- data/spec/fixtures/build/styles/foo/foo-2.css +1 -0
- data/spec/fixtures/build/styles/foo.css +1 -0
- data/spec/fixtures/build/templates/baz/baz_2.erb +1 -0
- data/spec/fixtures/build/templates/baz.erb +1 -0
- data/spec/fixtures/grouper/components/button/button.coffee +0 -0
- data/spec/fixtures/grouper/components/button/button.haml +0 -0
- data/spec/fixtures/grouper/components/button/button.scss +0 -0
- data/spec/fixtures/grouper/components/checkbox/_checkbox.haml +0 -0
- data/spec/fixtures/grouper/components/checkbox/_checkbox.scss +0 -0
- data/spec/fixtures/grouper/components/checkbox/checkbox.coffee +0 -0
- data/spec/fixtures/grouper/components/form/form.coffee +0 -0
- data/spec/fixtures/grouper/components/form/form.m +0 -0
- data/spec/fixtures/grouper/components/form/form.scss +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/_next-expanding-textarea.scss +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/_next_expanding_textarea.coffee +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/next-expanding-textarea.haml +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.coffee +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.haml +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.scss +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.coffee +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.haml +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.min.html +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.scss +0 -0
- data/spec/fixtures/grouper/markup/list-view.haml +0 -0
- data/spec/fixtures/grouper/markup/resizable/resizable.haml +0 -0
- data/spec/fixtures/grouper/markup/toggle.haml +0 -0
- data/spec/fixtures/grouper/scripts/resizable/resizable.coffee +0 -0
- data/spec/fixtures/grouper/scripts/toggle.coffee +0 -0
- data/spec/fixtures/grouper/style/_list-view.scss +0 -0
- data/spec/fixtures/grouper/style/_toggle.scss +0 -0
- data/spec/fixtures/languages/stub.json +3 -0
- data/spec/fixtures/languages/stub.yml +2 -0
- data/spec/fixtures/parsers/coffeescript_parser_fixture_basic.coffee +20 -0
- data/spec/fixtures/parsers/coffeescript_parser_fixture_complex.coffee +80 -0
- data/spec/fixtures/parsers/css_parser_fixture_basic.css +44 -0
- data/spec/fixtures/parsers/css_parser_fixture_complex.css +120 -0
- data/spec/fixtures/parsers/javascript_parser_fixture_basic.js +27 -0
- data/spec/fixtures/parsers/javascript_parser_fixture_complex.js +85 -0
- data/spec/fixtures/parsers/sass_parser_fixture_basic.scss +39 -0
- data/spec/fixtures/parsers/sass_parser_fixture_complex.scss +149 -0
- data/spec/fixtures/parsers/stylus_parser_fixture_basic.styl +34 -0
- data/spec/fixtures/parsers/stylus_parser_fixture_complex.styl +113 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/code_blocks.txt +10 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/headings.txt +15 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/lists.txt +21 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/lists_with_nesting.txt +13 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/multiple_paragraphs.txt +11 -0
- data/spec/fixtures/renderers/helpers.rb +37 -0
- data/spec/fixtures/renderers/html_output.html +7 -0
- data/spec/fixtures/renderers/templates/layouts/application.html.erb +0 -0
- data/spec/fixtures/renderers/templates/layouts/more/subdirectory.html.erb +0 -0
- data/spec/fixtures/renderers/templates/partials/_leading_underscore.html.erb +1 -0
- data/spec/fixtures/renderers/templates/partials/more/_subdirectory.html.erb +1 -0
- data/spec/fixtures/renderers/templates/partials/partial.html.erb +0 -0
- data/spec/fixtures/renderers/templates/partials/template.html.erb +1 -0
- data/spec/fixtures/renderers/templates/template.html.erb +1 -0
- data/spec/fixtures/tags/description/button.md +24 -0
- data/spec/fixtures/tags/description/class.md +27 -0
- data/spec/fixtures/tags/description/component.md +23 -0
- data/spec/fixtures/tags/description/function.md +30 -0
- data/spec/lib/build_spec.rb +467 -0
- data/spec/lib/cache_spec.rb +175 -0
- data/spec/lib/command_line_spec.rb +77 -0
- data/spec/lib/configuration_spec.rb +180 -0
- data/spec/lib/containers/base_container_spec.rb +214 -0
- data/spec/lib/containers/class_container_spec.rb +209 -0
- data/spec/lib/containers/component_container_spec.rb +158 -0
- data/spec/lib/containers/demo_container_spec.rb +113 -0
- data/spec/lib/containers/function_container_spec.rb +116 -0
- data/spec/lib/containers/mixin_container_spec.rb +4 -0
- data/spec/lib/containers/pattern_container_spec.rb +291 -0
- data/spec/lib/containers/pattern_library_container_spec.rb +130 -0
- data/spec/lib/containers/symbol_container_spec.rb +216 -0
- data/spec/lib/containers/variable_container_spec.rb +116 -0
- data/spec/lib/containers/variation_container_spec.rb +52 -0
- data/spec/lib/containers_spec.rb +22 -0
- data/spec/lib/descriptor_spec.rb +73 -0
- data/spec/lib/group_spec.rb +151 -0
- data/spec/lib/helpers/path_helper_spec.rb +202 -0
- data/spec/lib/helpers/render_helper_spec.rb +159 -0
- data/spec/lib/helpers_spec.rb +35 -0
- data/spec/lib/languages/base_language_spec.rb +32 -0
- data/spec/lib/languages/coffeescript_language_spec.rb +52 -0
- data/spec/lib/languages/css_language_spec.rb +13 -0
- data/spec/lib/languages/erb_language_spec.rb +33 -0
- data/spec/lib/languages/haml_language_spec.rb +32 -0
- data/spec/lib/languages/javascript_language_spec.rb +54 -0
- data/spec/lib/languages/json_language_spec.rb +24 -0
- data/spec/lib/languages/less_language_spec.rb +39 -0
- data/spec/lib/languages/markup_language_spec.rb +95 -0
- data/spec/lib/languages/sass_language_spec.rb +53 -0
- data/spec/lib/languages/slim_language_spec.rb +32 -0
- data/spec/lib/languages/stylus_language_spec.rb +34 -0
- data/spec/lib/languages/yaml_language_spec.rb +24 -0
- data/spec/lib/languages_spec.rb +127 -0
- data/spec/lib/markdown_spec.rb +63 -0
- data/spec/lib/messenger_spec.rb +1 -0
- data/spec/lib/naming_conventions/bem_naming_convention_spec.rb +112 -0
- data/spec/lib/naming_conventions/suit_naming_convention_spec.rb +107 -0
- data/spec/lib/naming_conventions_spec.rb +28 -0
- data/spec/lib/ostruct_spec.rb +15 -0
- data/spec/lib/parser_spec.rb +93 -0
- data/spec/lib/parsers/base_parser_spec.rb +128 -0
- data/spec/lib/parsers/coffeescript_parser_spec.rb +184 -0
- data/spec/lib/parsers/css_parser_spec.rb +136 -0
- data/spec/lib/parsers/javascript_parser_spec.rb +216 -0
- data/spec/lib/parsers/less_parser_spec.rb +111 -0
- data/spec/lib/parsers/sass_parser_spec.rb +233 -0
- data/spec/lib/parsers/stylus_parser_spec.rb +212 -0
- data/spec/lib/process_spec.rb +96 -0
- data/spec/lib/processors_spec.rb +555 -0
- data/spec/lib/renderers/base_renderer_spec.rb +122 -0
- data/spec/lib/renderers/common_features/helperable_spec.rb +30 -0
- data/spec/lib/renderers/erb_renderer_spec.rb +119 -0
- data/spec/lib/renderers/haml_renderer_spec.rb +103 -0
- data/spec/lib/renderers/slim_renderer_spec.rb +103 -0
- data/spec/lib/symbol_sources/jquery_symbol_source_spec.rb +25 -0
- data/spec/lib/symbol_sources/mdn_symbol_source_spec.rb +40 -0
- data/spec/lib/symbol_sources/sass_symbol_source_spec.rb +39 -0
- data/spec/lib/symbol_sources_spec.rb +19 -0
- data/spec/lib/tags/access_tag_spec.rb +32 -0
- data/spec/lib/tags/activate_with_tag_spec.rb +31 -0
- data/spec/lib/tags/active_tag_spec.rb +24 -0
- data/spec/lib/tags/alias_tag_spec.rb +31 -0
- data/spec/lib/tags/author_tag_spec.rb +172 -0
- data/spec/lib/tags/base_tag_spec.rb +21 -0
- data/spec/lib/tags/beta_tag_spec.rb +52 -0
- data/spec/lib/tags/class_tag_spec.rb +29 -0
- data/spec/lib/tags/compatibility_tag_spec.rb +159 -0
- data/spec/lib/tags/demo_type_tag_spec.rb +24 -0
- data/spec/lib/tags/deprecated_tag_spec.rb +50 -0
- data/spec/lib/tags/description_tag_spec.rb +242 -0
- data/spec/lib/tags/example_tag_spec.rb +37 -0
- data/spec/lib/tags/factory_tag_spec.rb +29 -0
- data/spec/lib/tags/for_tag_spec.rb +45 -0
- data/spec/lib/tags/group_tag_spec.rb +20 -0
- data/spec/lib/tags/helper_tag_spec.rb +22 -0
- data/spec/lib/tags/include_with_tag_spec.rb +74 -0
- data/spec/lib/tags/javascript_action_tag_spec.rb +20 -0
- data/spec/lib/tags/link_tag_spec.rb +49 -0
- data/spec/lib/tags/markup_tag_spec.rb +255 -0
- data/spec/lib/tags/member_tag_spec.rb +167 -0
- data/spec/lib/tags/method_tag_spec.rb +27 -0
- data/spec/lib/tags/name_tag_spec.rb +20 -0
- data/spec/lib/tags/object_tag_spec.rb +24 -0
- data/spec/lib/tags/param_tag_spec.rb +261 -0
- data/spec/lib/tags/pattern_tag_spec.rb +49 -0
- data/spec/lib/tags/preclude_tag_spec.rb +31 -0
- data/spec/lib/tags/private_tag_spec.rb +31 -0
- data/spec/lib/tags/property_tag_spec.rb +27 -0
- data/spec/lib/tags/public_tag_spec.rb +29 -0
- data/spec/lib/tags/require_tag_spec.rb +133 -0
- data/spec/lib/tags/returns_tag_spec.rb +85 -0
- data/spec/lib/tags/set_by_tag_spec.rb +92 -0
- data/spec/lib/tags/signature_tag_spec.rb +125 -0
- data/spec/lib/tags/since_tag_spec.rb +48 -0
- data/spec/lib/tags/state_tag_spec.rb +199 -0
- data/spec/lib/tags/static_tag_spec.rb +27 -0
- data/spec/lib/tags/subcomponent_tag_spec.rb +78 -0
- data/spec/lib/tags/subtitle_tag_spec.rb +13 -0
- data/spec/lib/tags/symbol_type_tag_spec.rb +20 -0
- data/spec/lib/tags/throws_tag_spec.rb +49 -0
- data/spec/lib/tags/title_tag_spec.rb +20 -0
- data/spec/lib/tags/type_tag_spec.rb +20 -0
- data/spec/lib/tags/value_tag_spec.rb +20 -0
- data/spec/lib/tags/variant_tag_spec.rb +13 -0
- data/spec/lib/tags/variation_tag_spec.rb +154 -0
- data/spec/lib/tags_spec.rb +264 -0
- data/spec/lib/templates_spec.rb +185 -0
- data/spec/lib/themes_spec.rb +32 -0
- data/spec/spec_helper.rb +34 -0
- data/tasks/rspec.rake +7 -0
- data/tasks/rubocop.rake +8 -0
- metadata +740 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Renderers::Common::Helperable do
|
4
|
+
subject { Class.new { include Docks::Renderers::Common::Helperable }.new }
|
5
|
+
|
6
|
+
it "includes all passed helpers" do
|
7
|
+
module Module1; end
|
8
|
+
module Module2; end
|
9
|
+
|
10
|
+
expect(subject).to receive(:extend).with Module1
|
11
|
+
expect(subject).to receive(:extend).with Module2
|
12
|
+
|
13
|
+
subject.helpers Module1, Module2
|
14
|
+
end
|
15
|
+
|
16
|
+
it "includes all modules in passed files" do
|
17
|
+
helper_file = File.expand_path("../../../../fixtures/renderers/helpers.rb", __FILE__)
|
18
|
+
require helper_file
|
19
|
+
subject.helpers helper_file
|
20
|
+
|
21
|
+
(Helpers.instance_methods(false) + Helpers2.instance_methods(false)).each do |meth|
|
22
|
+
expect(subject).to respond_to meth
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "doesn't include helper files that don't exist" do
|
27
|
+
expect(File).not_to receive(:read).with "foo.txt"
|
28
|
+
subject.helpers "foo.txt"
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Renderers::ERB do
|
4
|
+
subject { Docks::Renderers::ERB.new }
|
5
|
+
|
6
|
+
after :each do
|
7
|
+
subject.instance_variable_set(:@content_blocks, Hash.new)
|
8
|
+
subject.send(:clean)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#render" do
|
12
|
+
it "renders ERB" do
|
13
|
+
erb_template = <<-HTML
|
14
|
+
<ul>
|
15
|
+
<% 5.times do |i| %>
|
16
|
+
<li>Item <%= i + 1 %></li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
HTML
|
20
|
+
|
21
|
+
expect(subject.render(inline: erb_template).gsub(/\s/, "")).to eq File.read(File.expand_path("../../../fixtures/renderers/html_output.html", __FILE__)).gsub(/\s/, "")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "captures ERB" do
|
25
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
26
|
+
|
27
|
+
erb_template = <<-HTML
|
28
|
+
<% helper4 do %>
|
29
|
+
bar
|
30
|
+
<% end %>
|
31
|
+
HTML
|
32
|
+
|
33
|
+
expect(subject.render(inline: erb_template).strip).to eq "foo bar!"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "captures ERB with arguments" do
|
37
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
38
|
+
expect(subject.render(inline: "<% helper6('bar') do |val| %>\n foo <%= val %>\n<% end %>").strip).to eq "foo bar"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "renders a template with the passed locals" do
|
42
|
+
expect(subject.render(inline: "<%= foo %>", locals: { foo: "bar" }).strip).to eq "bar"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "throws an error when a method is not available" do
|
46
|
+
expect { subject.render(inline: "<%= foo_bar_baz %>") }.to raise_error(NameError)
|
47
|
+
expect { subject.render(inline: "<%= foo_bar_baz %>", locals: { foo: "bar" }) }.to raise_error(NameError)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "renders a template with access to the same helpers as the base template" do
|
51
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
52
|
+
expect(subject.render(inline: "<%= helper %>\n<%= helper3 %>").strip).to eq "foo bar baz\nBAR"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "allows helpers to use classes in their scope" do
|
56
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
57
|
+
expect(subject.render(inline: "<%= helper5 %>").strip).to eq "thing one"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "allows helpers to be called from within capture blocks" do
|
61
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
62
|
+
expect(subject.render(inline: "<% helper4 do %>\n <%= render(inline: 'foo') %>\n<% end %>").strip).to eq "foo foo!"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "doesn't preserve locals between template renders" do
|
66
|
+
erb_template = "<%= foo %>"
|
67
|
+
|
68
|
+
subject.render(inline: erb_template, locals: { foo: "bar" })
|
69
|
+
expect(subject.render(inline: erb_template, locals: { foo: "baz" }).strip).to eq "baz"
|
70
|
+
expect(subject.render(inline: erb_template, locals: { foo: "" }).strip).to eq ""
|
71
|
+
end
|
72
|
+
|
73
|
+
context "when there's a layout" do
|
74
|
+
it "allows setting a layout file that is rendered around the main file" do
|
75
|
+
layout = "Foo <%= yield.strip %> baz"
|
76
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
77
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
78
|
+
|
79
|
+
expect(subject.render(inline: "bar", layout: layout).strip).to eq "Foo bar baz"
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#content_for" do
|
83
|
+
it "allows setting the content for multiple yielded blocks using #content_for" do
|
84
|
+
layout = "Foo <%= yield(:first).strip %> <%= yield(:second).strip %>."
|
85
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
86
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
87
|
+
|
88
|
+
expect(subject.render(inline: "<% content_for(:first) do %>bar<% end %>\n<% content_for(:second) do %>baz<% end %>", layout: layout).strip).to eq "Foo bar baz."
|
89
|
+
end
|
90
|
+
|
91
|
+
it "allows both named and a default content block" do
|
92
|
+
layout = "Foo <%= yield(:first).strip %> <%= yield.strip %>."
|
93
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
94
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
95
|
+
|
96
|
+
expect(subject.render(inline: "<% content_for(:first) do %>bar<% end %>\nbaz", layout: layout).strip).to eq "Foo bar baz."
|
97
|
+
end
|
98
|
+
|
99
|
+
it "yields do a given content block when no block is given" do
|
100
|
+
layout = "Foo <%= content_for(:first).strip %> <%= yield.strip %>."
|
101
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
102
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
103
|
+
|
104
|
+
expect(subject.render(inline: "<% content_for(:first) do %>bar<% end %>\nbaz", layout: layout).strip).to eq "Foo bar baz."
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#content_for?" do
|
109
|
+
it "identifies whether a block has been given" do
|
110
|
+
layout = "first? <%= content_for?(:first).to_s %>, second? <%= content_for?(:second).to_s %>"
|
111
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
112
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
113
|
+
|
114
|
+
expect(subject.render(inline: "<% content_for(:first) do %>bar<% end %>", layout: layout).strip).to eq "first? true, second? false"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Renderers::Haml do
|
4
|
+
subject { Docks::Renderers::Haml.new }
|
5
|
+
|
6
|
+
after :each do
|
7
|
+
subject.instance_variable_set(:@content_blocks, Hash.new)
|
8
|
+
subject.send(:clean)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#render" do
|
12
|
+
it "renders Haml" do
|
13
|
+
haml_template = "%ul\n - 5.times do |i|\n %li Item \#{i + 1}"
|
14
|
+
expect(subject.render(inline: haml_template).gsub(/\s/, "")).to eq File.read(File.expand_path("../../../fixtures/renderers/html_output.html", __FILE__)).gsub(/\s/, "")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "captures Haml" do
|
18
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
19
|
+
expect(subject.render(inline: "= helper4 do\n bar").strip).to eq "foo bar!"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "captures Haml with arguments" do
|
23
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
24
|
+
expect(subject.render(inline: "= helper6('bar') do |val|\n foo \#{val}").strip).to eq "foo bar"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "renders a template with the passed locals" do
|
28
|
+
expect(subject.render(inline: "= foo", locals: { foo: "bar" }).strip).to eq "bar"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "renders a template with access to the same helpers as the base template" do
|
32
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
33
|
+
|
34
|
+
expect(subject.render(inline: "= helper\n= helper3").strip).to eq "foo bar baz\nBAR"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "allows helpers to use classes in their scope" do
|
38
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
39
|
+
|
40
|
+
expect(subject.render(inline: "= helper5").strip).to eq "thing one"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "allows helpers to be called from within capture blocks" do
|
44
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
45
|
+
|
46
|
+
expect(subject.render(inline: "= helper4 do\n = render(inline: 'foo')").strip).to eq "foo foo!"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "doesn't preserve locals between template renders" do
|
50
|
+
haml_template = "= foo"
|
51
|
+
|
52
|
+
subject.render(inline: haml_template, locals: { foo: "bar" })
|
53
|
+
expect(subject.render(inline: haml_template, locals: { foo: "baz" }).strip).to eq "baz"
|
54
|
+
expect(subject.render(inline: haml_template, locals: { foo: "" }).strip).to eq ""
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when there's a layout" do
|
58
|
+
it "allows setting a layout file that is rendered around the main file" do
|
59
|
+
layout = "Foo \#{yield.strip} baz"
|
60
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
61
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
62
|
+
|
63
|
+
expect(subject.render(inline: "bar", layout: layout).strip).to eq "Foo bar baz"
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#content_for" do
|
67
|
+
it "allows setting the content for multiple yielded blocks using #content_for" do
|
68
|
+
layout = "Foo \#{yield(:first).strip} \#{yield(:second).strip}."
|
69
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
70
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
71
|
+
|
72
|
+
expect(subject.render(inline: "- content_for(:first) do\n bar\n\n- content_for(:second) do\n baz", layout: layout).strip).to eq "Foo bar baz."
|
73
|
+
end
|
74
|
+
|
75
|
+
it "allows both named and a default content block" do
|
76
|
+
layout = "Foo \#{yield(:first).strip} \#{yield.strip}."
|
77
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
78
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
79
|
+
|
80
|
+
expect(subject.render(inline: "- content_for(:first) do\n bar\n\nbaz", layout: layout).strip).to eq "Foo bar baz."
|
81
|
+
end
|
82
|
+
|
83
|
+
it "yields do a given content block when no block is given" do
|
84
|
+
layout = "Foo \#{content_for(:first).strip} \#{yield.strip}."
|
85
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
86
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
87
|
+
|
88
|
+
expect(subject.render(inline: "- content_for(:first) do\n bar\n\nbaz", layout: layout).strip).to eq "Foo bar baz."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#content_for?" do
|
93
|
+
it "identifies whether a block has been given" do
|
94
|
+
layout = "first? \#{content_for?(:first).to_s}, second? \#{content_for?(:second).to_s}"
|
95
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
96
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
97
|
+
|
98
|
+
expect(subject.render(inline: "- content_for(:first) do\n bar", layout: layout).strip).to eq "first? true, second? false"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Renderers::Slim do
|
4
|
+
subject { Docks::Renderers::Slim.new }
|
5
|
+
|
6
|
+
after :each do
|
7
|
+
subject.instance_variable_set(:@content_blocks, Hash.new)
|
8
|
+
subject.send(:clean)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#render" do
|
12
|
+
it "renders Slim" do
|
13
|
+
slim_template = "ul\n - 5.times do |i|\n li Item \#{i + 1}"
|
14
|
+
expect(subject.render(inline: slim_template).gsub(/\s/, "")).to eq File.read(File.expand_path("../../../fixtures/renderers/html_output.html", __FILE__)).gsub(/\s/, "")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "captures Slim" do
|
18
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
19
|
+
expect(subject.render(inline: "= helper4 do\n | bar").strip).to eq "foo bar!"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "captures Slim with arguments" do
|
23
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
24
|
+
expect(subject.render(inline: "= helper6('bar') do |val|\n | foo \#{val}").strip).to eq "foo bar"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "renders a template with the passed locals" do
|
28
|
+
expect(subject.render(inline: "= foo", locals: { foo: "bar" }).strip).to eq "bar"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "renders a template with access to the same helpers as the base template" do
|
32
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
33
|
+
|
34
|
+
expect(subject.render(inline: "== helper\n==< helper2").strip).to eq "foo bar baz baz bar foo"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "allows helpers to use classes in their scope" do
|
38
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
39
|
+
|
40
|
+
expect(subject.render(inline: "= helper5").strip).to eq "thing one"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "allows helpers to be called from within capture blocks" do
|
44
|
+
subject.helpers File.expand_path("../../../fixtures/renderers/helpers.rb", __FILE__)
|
45
|
+
|
46
|
+
expect(subject.render(inline: "= helper4 do\n = render(inline: '| foo')").strip).to eq "foo foo!"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "doesn't preserve locals between template renders" do
|
50
|
+
slim_template = "= foo"
|
51
|
+
|
52
|
+
subject.render(inline: slim_template, locals: { foo: "bar" })
|
53
|
+
expect(subject.render(inline: slim_template, locals: { foo: "baz" }).strip).to eq "baz"
|
54
|
+
expect(subject.render(inline: slim_template, locals: { foo: "" }).strip).to eq ""
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when there's a layout" do
|
58
|
+
it "allows setting a layout file that is rendered around the main file" do
|
59
|
+
layout = "| Foo \#{yield.strip} baz"
|
60
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
61
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
62
|
+
|
63
|
+
expect(subject.render(inline: "| bar", layout: layout).strip).to eq "Foo bar baz"
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#content_for" do
|
67
|
+
it "allows setting the content for multiple yielded blocks using #content_for" do
|
68
|
+
layout = "| Foo \#{yield(:first).strip} \#{yield(:second).strip}."
|
69
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
70
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
71
|
+
|
72
|
+
expect(subject.render(inline: "= content_for(:first) do\n | bar\n\n= content_for(:second) do\n | baz", layout: layout).strip).to eq "Foo bar baz."
|
73
|
+
end
|
74
|
+
|
75
|
+
it "allows both named and a default content block" do
|
76
|
+
layout = "| Foo \#{yield(:first).strip} \#{yield.strip}."
|
77
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
78
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
79
|
+
|
80
|
+
expect(subject.render(inline: "= content_for(:first) do\n | bar\n| baz", layout: layout).strip).to eq "Foo bar baz."
|
81
|
+
end
|
82
|
+
|
83
|
+
it "yields do a given content block when no block is given" do
|
84
|
+
layout = "| Foo \#{content_for(:first).strip} \#{yield.strip}."
|
85
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
86
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
87
|
+
|
88
|
+
expect(subject.render(inline: "= content_for(:first) do\n | bar\n\n| baz", layout: layout).strip).to eq "Foo bar baz."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#content_for?" do
|
93
|
+
it "identifies whether a block has been given" do
|
94
|
+
layout = "| first? \#{content_for?(:first).to_s}, second? \#{content_for?(:second).to_s}"
|
95
|
+
expect(Docks::Templates).to receive(:search_for_template).with(layout, anything).and_return(layout)
|
96
|
+
expect(File).to receive(:read).with(layout).and_return(layout)
|
97
|
+
|
98
|
+
expect(subject.render(inline: "= content_for(:first) do\n | bar", layout: layout).strip).to eq "first? true, second? false"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::SymbolSources::JQuery do
|
4
|
+
subject { described_class.instance }
|
5
|
+
|
6
|
+
describe "#recognizes?" do
|
7
|
+
it "doesn't recognize a language that isn't a scripting one" do
|
8
|
+
Docks::Languages.register_bundled_languages
|
9
|
+
expect(subject.recognizes?("jQuery", language: "js")).to be true
|
10
|
+
expect(subject.recognizes?("jQuery", language: "coffee")).to be true
|
11
|
+
expect(subject.recognizes?("jQuery", language: "css")).to be false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "identifies a jQuery object" do
|
15
|
+
expect(subject.recognizes?("jQuery")).to be true
|
16
|
+
expect(subject.recognizes?("jquery")).to be true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#path_for" do
|
21
|
+
it "creates a path to jQuery API page" do
|
22
|
+
expect(subject.path_for("jQuery")).to eq "http://api.jquery.com/"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::SymbolSources::MDN do
|
4
|
+
subject { described_class.instance }
|
5
|
+
|
6
|
+
describe "#recognizes?" do
|
7
|
+
it "doesn't recognize a language that isn't a scripting one" do
|
8
|
+
Docks::Languages.register_bundled_languages
|
9
|
+
expect(subject.recognizes?("Object", language: "js")).to be true
|
10
|
+
expect(subject.recognizes?("Object", language: "coffee")).to be true
|
11
|
+
expect(subject.recognizes?("Object", language: "css")).to be false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "identifies a symbol that is a global object" do
|
15
|
+
expect(subject.recognizes?("Object")).to be true
|
16
|
+
expect(subject.recognizes?("object")).to be true
|
17
|
+
expect(subject.recognizes?("Array")).to be true
|
18
|
+
expect(subject.recognizes?("String")).to be true
|
19
|
+
expect(subject.recognizes?("Iterator")).to be true
|
20
|
+
expect(subject.recognizes?("Set")).to be true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "identifies a symbol that is a web API object" do
|
24
|
+
expect(subject.recognizes?("HTMLElement")).to be true
|
25
|
+
expect(subject.recognizes?("htmlelement")).to be true
|
26
|
+
expect(subject.recognizes?("Blob")).to be true
|
27
|
+
expect(subject.recognizes?("NodeList")).to be true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#path_for" do
|
32
|
+
it "creates a path to the MDN reference for a global object" do
|
33
|
+
expect(subject.path_for("Object")).to eq "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "creates a path to the MDN reference for a web API object" do
|
37
|
+
expect(subject.path_for("NodeList")).to eq "https://developer.mozilla.org/docs/Web/API/NodeList"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::SymbolSources::Sass do
|
4
|
+
subject { described_class.instance }
|
5
|
+
|
6
|
+
describe "#recognizes?" do
|
7
|
+
it "only recognizes Sass" do
|
8
|
+
Docks::Languages.register_bundled_languages
|
9
|
+
expect(subject.recognizes?("Color", language: "sass")).to be true
|
10
|
+
expect(subject.recognizes?("Color", language: "scss")).to be true
|
11
|
+
expect(subject.recognizes?("Color", language: "css")).to be false
|
12
|
+
expect(subject.recognizes?("Color", language: "js")).to be false
|
13
|
+
end
|
14
|
+
|
15
|
+
it "identifies a symbol that a Sass value object" do
|
16
|
+
expect(subject.recognizes?("arglist")).to be true
|
17
|
+
expect(subject.recognizes?("color")).to be true
|
18
|
+
expect(subject.recognizes?("list")).to be true
|
19
|
+
expect(subject.recognizes?("map")).to be true
|
20
|
+
expect(subject.recognizes?("null")).to be true
|
21
|
+
expect(subject.recognizes?("number")).to be true
|
22
|
+
expect(subject.recognizes?("string")).to be true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "identifies the function symbol" do
|
26
|
+
expect(subject.recognizes?("function")).to be true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#path_for" do
|
31
|
+
it "creates a path to Sass values" do
|
32
|
+
expect(subject.path_for("color")).to eq "http://sass-lang.com/documentation/Sass/Script/Value/Color.html"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "creates a path to Sass functions" do
|
36
|
+
expect(subject.path_for("Function")).to eq "http://sass-lang.com/documentation/Sass/Script/Script/Functions.html"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::SymbolSources do
|
4
|
+
subject { described_class }
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Docks::Languages.register_bundled_languages
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#path_for" do
|
11
|
+
it "returns nil when no sources recognize a symbol" do
|
12
|
+
expect(subject.path_for("foo")).to be nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns the path from a symbol source that recognizes the symbol" do
|
16
|
+
expect(subject.path_for("jquery")).to eq Docks::SymbolSources::JQuery.instance.path_for("jquery")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Tags::Access do
|
4
|
+
subject { Docks::Tags::Access.instance }
|
5
|
+
|
6
|
+
it "does not allow multiline content" do
|
7
|
+
expect(subject.multiline?).to be false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "only allows one tag per block" do
|
11
|
+
expect(subject.multiple_allowed?).to be false
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#process" do
|
15
|
+
let(:symbol) { Docks::Containers::Symbol.new }
|
16
|
+
|
17
|
+
it "allows one of the included access types" do
|
18
|
+
Docks::Types::Access.constants.each do |const|
|
19
|
+
access_type = Docks::Types::Access.const_get(const)
|
20
|
+
symbol.access = access_type
|
21
|
+
subject.process(symbol)
|
22
|
+
expect(symbol.access).to eq access_type
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "sets the access to public for any non-recognized access type" do
|
27
|
+
symbol.access = "foo"
|
28
|
+
subject.process(symbol)
|
29
|
+
expect(symbol.access).to eq Docks::Types::Access::PUBLIC
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Tags::ActivateWith do
|
4
|
+
subject { Docks::Tags::ActivateWith.instance }
|
5
|
+
|
6
|
+
it "does not allow multiline content" do
|
7
|
+
expect(subject.multiline?).to be false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "allows multiple tags per block" do
|
11
|
+
expect(subject.multiple_allowed?).to be true
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#process" do
|
15
|
+
let(:symbol) { Docks::Containers::Symbol.new }
|
16
|
+
|
17
|
+
it "breaks apart activate_withs on commas, spaces and pipes" do
|
18
|
+
activate_withs = "foo | bar, baz qux"
|
19
|
+
symbol[subject.name] = activate_withs
|
20
|
+
subject.process(symbol)
|
21
|
+
expect(symbol[subject.name]).to eq Docks::Processors.split_on_commas_spaces_and_pipes(activate_withs)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "joins together multiple lines of activate_withs" do
|
25
|
+
activate_withs = ["foo | bar, baz qux", "lux fuz"]
|
26
|
+
symbol[subject.name] = activate_withs.dup
|
27
|
+
subject.process(symbol)
|
28
|
+
expect(symbol[subject.name]).to eq activate_withs.map { |with| Docks::Processors.split_on_commas_spaces_and_pipes(with) }.flatten
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Tags::Active do
|
4
|
+
subject { Docks::Tags::Active.instance }
|
5
|
+
|
6
|
+
it "does not allow multiline content" do
|
7
|
+
expect(subject.multiline?).to be false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "only allows one tag per block" do
|
11
|
+
expect(subject.multiple_allowed?).to be false
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#process" do
|
15
|
+
it "boolean-ifies the parsed value" do
|
16
|
+
symbol = Docks::Containers::Symbol.new
|
17
|
+
symbol[subject.name] = "false"
|
18
|
+
|
19
|
+
expect(subject).to receive(:stringy_boolean).and_call_original
|
20
|
+
subject.process(symbol)
|
21
|
+
expect(symbol[subject.name]).to be false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Docks::Tags::Alias do
|
4
|
+
subject { Docks::Tags::Alias.instance }
|
5
|
+
|
6
|
+
it "does not allow multiline content" do
|
7
|
+
expect(subject.multiline?).to be false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "allows multiple tags per block" do
|
11
|
+
expect(subject.multiple_allowed?).to be true
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#process" do
|
15
|
+
let(:symbol) { Docks::Containers::Symbol.new }
|
16
|
+
|
17
|
+
it "breaks apart aliases on commas, spaces and pipes" do
|
18
|
+
aliases = "foo | bar, baz qux"
|
19
|
+
symbol[subject.name] = aliases
|
20
|
+
subject.process(symbol)
|
21
|
+
expect(symbol[subject.name]).to eq Docks::Processors.split_on_commas_spaces_and_pipes(aliases)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "joins together multiple lines of aliases" do
|
25
|
+
aliases = ["foo | bar, baz qux", "lux fuz"]
|
26
|
+
symbol[subject.name] = aliases.dup
|
27
|
+
subject.process(symbol)
|
28
|
+
expect(symbol[subject.name]).to eq aliases.map { |alias_line| Docks::Processors.split_on_commas_spaces_and_pipes(alias_line) }.flatten
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|