docks_app 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,255 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Tags::Markup do
|
|
4
|
+
subject { Docks::Tags::Markup.instance }
|
|
5
|
+
|
|
6
|
+
it "allows multiline content" do
|
|
7
|
+
expect(subject.multiline?).to be true
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "only allows one description per block" do
|
|
11
|
+
expect(subject.multiple_allowed?).to be false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#process" do
|
|
15
|
+
it "connects multiline content with line breaks" do
|
|
16
|
+
markup = ["foo", "bar"]
|
|
17
|
+
symbol = Docks::Containers::Symbol.new(markup: markup.dup)
|
|
18
|
+
subject.process(symbol)
|
|
19
|
+
expect(symbol[subject.name]).to eq markup.join("\n")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "post processing" do
|
|
24
|
+
let(:name) { "foo" }
|
|
25
|
+
let(:markup_file_name) { "pattern_lab/markup/_#{name}.erb" }
|
|
26
|
+
let(:stub_file_name) { "pattern_lab/stubs/#{name}.json" }
|
|
27
|
+
let(:markup) { "<div class='#{name}'>content!</div>" }
|
|
28
|
+
|
|
29
|
+
let(:component) { Docks::Containers::Component.new(name: name) }
|
|
30
|
+
let(:pattern) do
|
|
31
|
+
pattern = Docks::Containers::Pattern.new(name: name)
|
|
32
|
+
pattern.add(:style, component)
|
|
33
|
+
pattern
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
before(:each) { Docks::Languages.register_bundled_languages }
|
|
37
|
+
|
|
38
|
+
describe "markup association and clean up" do
|
|
39
|
+
let(:name) { "foo" }
|
|
40
|
+
let(:markup_file_name) { "pattern_lab/markup/_#{name}.erb" }
|
|
41
|
+
let(:stub_file_name) { "pattern_lab/stubs/#{name}.json" }
|
|
42
|
+
let(:markup) { "<div class='#{name}'>content!</div>" }
|
|
43
|
+
|
|
44
|
+
let(:component) { Docks::Containers::Component.new(name: name) }
|
|
45
|
+
let(:pattern) do
|
|
46
|
+
pattern = Docks::Containers::Pattern.new(name: name)
|
|
47
|
+
pattern.add(:style, component)
|
|
48
|
+
pattern
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "associates external markup files" do
|
|
52
|
+
before :each do
|
|
53
|
+
expect(Docks::Grouper).to receive(:source_files_of_type).with(Docks::Types::Languages::MARKUP).at_least(:once).and_return ["components/baz.erb", markup_file_name]
|
|
54
|
+
expect(Docks::Grouper).to receive(:source_files_of_type).with(Docks::Types::Languages::STUB).at_least(:once).and_return []
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "associates a markup file matching a component with the markup for that component" do
|
|
58
|
+
expect(File).to receive(:read).with(markup_file_name).and_return(markup)
|
|
59
|
+
post_process
|
|
60
|
+
expect(component.markup).to eq markup
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "does not associate a markup file when none matches the component" do
|
|
64
|
+
component.name = "qux"
|
|
65
|
+
expect(File).not_to receive(:read)
|
|
66
|
+
expect { post_process }.not_to change { component }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "does not associate a markup file when the component already has a markup" do
|
|
70
|
+
component.markup = "<div class='bar'></div>"
|
|
71
|
+
expect(File).not_to receive(:read)
|
|
72
|
+
expect { post_process }.not_to change { component }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "only associates markup files with components" do
|
|
76
|
+
pattern.remove(component)
|
|
77
|
+
function = Docks::Containers::Function.new(name: name)
|
|
78
|
+
pattern.add(:style, function)
|
|
79
|
+
expect(File).not_to receive(:read)
|
|
80
|
+
expect { post_process }.not_to change { function }
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe "creates helper functions from a helper method name and external stub file" do
|
|
85
|
+
let(:stub) do
|
|
86
|
+
{ foo: "bar", baz: "qux" }
|
|
87
|
+
end
|
|
88
|
+
let(:stub_language) { Docks::Languages::JSON.instance }
|
|
89
|
+
|
|
90
|
+
before :each do
|
|
91
|
+
component.helper = "foo"
|
|
92
|
+
|
|
93
|
+
expect(Docks::Grouper).to receive(:source_files_of_type).with(Docks::Types::Languages::MARKUP).at_least(:once).and_return []
|
|
94
|
+
expect(Docks::Grouper).to receive(:source_files_of_type).with(Docks::Types::Languages::STUB).at_least(:once).and_return ["stubs/baz.yml", stub_file_name]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "does not create helper markup if there is regular markup" do
|
|
98
|
+
component.markup = "foo"
|
|
99
|
+
expect { post_process }.not_to change { component }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "does not create helper markup when no stubs match the component" do
|
|
103
|
+
component.name = "qux"
|
|
104
|
+
expect { post_process }.not_to change { component }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "does not create helper markup there is no helper method" do
|
|
108
|
+
component.helper = nil
|
|
109
|
+
expect { post_process }.not_to change { component }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "adds helper markup from ERB by default when there is a helper name and associated stub" do
|
|
113
|
+
helper = "<%= foo bar: :baz %>"
|
|
114
|
+
expect(stub_language).to receive(:load_stub).and_return(stub)
|
|
115
|
+
expect(Docks::Languages::ERB.instance).to receive(:helper_markup_for).with(component.helper, stub).and_return(helper)
|
|
116
|
+
post_process
|
|
117
|
+
expect(component.helper).to eq helper
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "doesn't add helper markup when the most common markup file type is HTML" do
|
|
121
|
+
expect(Docks::Languages).to receive(:most_common_markup_language).and_return(Docks::Languages::HTML.instance)
|
|
122
|
+
expect { post_process }.not_to change { component }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "only associates markup files with components" do
|
|
126
|
+
pattern.remove(component)
|
|
127
|
+
function = Docks::Containers::Function.new(name: name, helper: "foo")
|
|
128
|
+
pattern.add(:style, function)
|
|
129
|
+
expect { post_process }.not_to change { function }
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe "cleans up the combination of markup and helper" do
|
|
134
|
+
before(:each) do
|
|
135
|
+
expect(Docks::Grouper).to receive(:source_files_of_type).at_least(:once).and_return []
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "leaves everything alone when the markup and helper don't overlap" do
|
|
139
|
+
component.helper = component.markup = nil
|
|
140
|
+
expect { post_process }.not_to change { component }
|
|
141
|
+
|
|
142
|
+
component.helper = nil
|
|
143
|
+
component.markup = "<div>foo</div>"
|
|
144
|
+
expect { post_process }.not_to change { component }
|
|
145
|
+
|
|
146
|
+
component.markup = nil
|
|
147
|
+
component.helper = "<div>foo</div>"
|
|
148
|
+
expect { post_process }.not_to change { component }
|
|
149
|
+
|
|
150
|
+
component.helper = "<div>bar</div>"
|
|
151
|
+
component.markup = "<div>foo</div>"
|
|
152
|
+
expect { post_process }.not_to change { component }
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "overwrites the helper with the markup when the helper name is contained in the markup" do
|
|
156
|
+
markup = "<%= ui_foo bar: 'baz' %>\n <p>foo bar baz</p>\n<% end %>"
|
|
157
|
+
component.helper = "ui_foo"
|
|
158
|
+
component.markup = markup
|
|
159
|
+
|
|
160
|
+
post_process
|
|
161
|
+
|
|
162
|
+
expect(component.helper).to eq markup
|
|
163
|
+
expect(component.markup).to be nil
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def post_process
|
|
168
|
+
Docks::Process.process(pattern)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
describe "clean up the markup for variations" do
|
|
173
|
+
let(:state_with_demo) { Docks::Containers::State.new(name: "foo--is-bar") }
|
|
174
|
+
let(:state_without_demo) { Docks::Containers::State.new(name: "foo--is-baz") }
|
|
175
|
+
let(:component) { Docks::Containers::Component.new(name: "foo", states: [state_without_demo, state_with_demo]) }
|
|
176
|
+
|
|
177
|
+
let(:pattern) do
|
|
178
|
+
pattern = Docks::Containers::Pattern.new(name: "foo")
|
|
179
|
+
pattern.add(:style, component)
|
|
180
|
+
pattern
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
let(:component_markup) { "<div class='fool foo'><div class='foo__qux'></div></div>" }
|
|
184
|
+
let(:component_helper_one) { "<%= docks_foo baz?: false, bar?: false %>" }
|
|
185
|
+
let(:component_helper_two) { "<%= docks_foo type: :baz %>" }
|
|
186
|
+
let(:component_helper_three) { "<%= docks_foo \"type\" => :baz %>" }
|
|
187
|
+
|
|
188
|
+
before(:each) do
|
|
189
|
+
expect(state_with_demo).to receive(:has_demo?).and_return true
|
|
190
|
+
expect(state_without_demo).to receive(:has_demo?).and_return false
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it "adds adjusted markup to variations with their own demo" do
|
|
194
|
+
component.markup = component_markup
|
|
195
|
+
post_process
|
|
196
|
+
|
|
197
|
+
expect(state_without_demo.markup).to be nil
|
|
198
|
+
expect(state_with_demo.markup).to eq "<div class='fool foo foo--is-bar'><div class='foo__qux'></div></div>"
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it "doesn't add markup when it already exists" do
|
|
202
|
+
state_with_demo.markup = component.markup = component_markup
|
|
203
|
+
expect { post_process }.not_to change { state_with_demo }
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it "doesn't add markup when helper markup already exists" do
|
|
207
|
+
component.markup = component_markup
|
|
208
|
+
state_with_demo.helper = component_helper_two
|
|
209
|
+
state_with_demo.set_by.concat [{setter: "qux"}, {setter: ":type", constant: ":bar"}]
|
|
210
|
+
expect { post_process }.not_to change { state_with_demo }
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "adds adjusted helper markup with boolean parameters" do
|
|
214
|
+
component.helper = component_helper_one
|
|
215
|
+
state_with_demo.set_by.concat [{setter: ":bar?"}, {setter: "qux"}]
|
|
216
|
+
post_process
|
|
217
|
+
expect(state_without_demo.helper).to be nil
|
|
218
|
+
expect(state_with_demo.helper).to eq "<%= docks_foo baz?: false, bar?: true %>"
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
it "adds adjusted helper markup with constant parameters" do
|
|
222
|
+
component.helper = component_helper_two
|
|
223
|
+
state_with_demo.set_by.concat [{setter: "qux"}, {setter: ":type", constant: ":bar"}]
|
|
224
|
+
post_process
|
|
225
|
+
expect(state_without_demo.helper).to be nil
|
|
226
|
+
expect(state_with_demo.helper).to eq "<%= docks_foo type: :bar %>"
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
it "adds adjusted helper markup with alternative hash markups" do
|
|
230
|
+
component.helper = component_helper_three
|
|
231
|
+
state_with_demo.set_by.concat [{setter: "qux"}, {setter: "\"type\"", constant: "Foo::BAR"}]
|
|
232
|
+
post_process
|
|
233
|
+
expect(state_without_demo.helper).to be nil
|
|
234
|
+
expect(state_with_demo.helper).to eq "<%= docks_foo \"type\" => Foo::BAR %>"
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it "doesn't add helper markup when it already exists" do
|
|
238
|
+
state_with_demo.helper = component.helper = component_helper_two
|
|
239
|
+
state_with_demo.set_by.concat [{setter: "qux"}, {setter: ":type", constant: ":bar"}]
|
|
240
|
+
expect { post_process }.not_to change { state_with_demo }
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it "doesn't add helper markup when it markup already exists" do
|
|
244
|
+
component.helper = component_helper_two
|
|
245
|
+
state_with_demo.set_by.concat [{setter: "qux"}, {setter: ":type", constant: ":bar"}]
|
|
246
|
+
state_with_demo.markup = component_markup
|
|
247
|
+
expect { post_process }.not_to change { state_with_demo }
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def post_process
|
|
251
|
+
Docks::Process.process(pattern)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Tags::Member do
|
|
4
|
+
subject { described_class.instance }
|
|
5
|
+
|
|
6
|
+
it "can't be be parsed from files" do
|
|
7
|
+
expect(subject.parseable?).to be false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "post process" do
|
|
11
|
+
before(:each) { Docks::Tags.register_bundled_tags }
|
|
12
|
+
|
|
13
|
+
let(:pattern) { Docks::Containers::Pattern.new(name: "symbol_1") }
|
|
14
|
+
let(:factory) { Docks::Containers::Factory.new(name: "symbol_2") }
|
|
15
|
+
let(:klass) { Docks::Containers::Klass.new(name: "symbol_3") }
|
|
16
|
+
let(:object) { Docks::Containers::Variable.new(name: "symbol_4", object: true) }
|
|
17
|
+
let(:variable) { Docks::Containers::Variable.new(name: "symbol_5") }
|
|
18
|
+
let(:function) { Docks::Containers::Function.new(name: "symbol_6") }
|
|
19
|
+
let(:method) { Docks::Containers::Function.new(name: "symbol_7", method: true) }
|
|
20
|
+
let(:property) { Docks::Containers::Variable.new(name: "symbol_8", property: true) }
|
|
21
|
+
|
|
22
|
+
it "adds methods following a class to its array of methods" do
|
|
23
|
+
pattern.add(:script, [factory, klass, method])
|
|
24
|
+
post_process
|
|
25
|
+
|
|
26
|
+
expect(pattern.script_symbols.length).to be 2
|
|
27
|
+
expect(pattern.script_symbols).not_to include method
|
|
28
|
+
expect(klass.methods.length).to be 1
|
|
29
|
+
expect(klass.methods).to include method
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "adds properties following a class to its array of properties" do
|
|
33
|
+
pattern.add(:script, [factory, klass, property])
|
|
34
|
+
post_process
|
|
35
|
+
|
|
36
|
+
expect(pattern.script_symbols.length).to be 2
|
|
37
|
+
expect(pattern.script_symbols).not_to include property
|
|
38
|
+
expect(klass.properties.length).to be 1
|
|
39
|
+
expect(klass.properties).to include property
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "adds methods following a factory to its array of methods" do
|
|
43
|
+
pattern.add(:script, [function, factory, method])
|
|
44
|
+
post_process
|
|
45
|
+
|
|
46
|
+
expect(pattern.script_symbols.length).to be 2
|
|
47
|
+
expect(pattern.script_symbols).not_to include method
|
|
48
|
+
expect(factory.methods.length).to be 1
|
|
49
|
+
expect(factory.methods).to include method
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "adds properties following a factory to its array of properties" do
|
|
53
|
+
pattern.add(:script, [function, factory, property])
|
|
54
|
+
post_process
|
|
55
|
+
|
|
56
|
+
expect(pattern.script_symbols.length).to be 2
|
|
57
|
+
expect(pattern.script_symbols).not_to include property
|
|
58
|
+
expect(factory.properties.length).to be 1
|
|
59
|
+
expect(factory.properties).to include property
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "adds methods following an object to its array of methods" do
|
|
63
|
+
pattern.add(:script, [klass, object, method])
|
|
64
|
+
post_process
|
|
65
|
+
|
|
66
|
+
expect(pattern.script_symbols.length).to be 2
|
|
67
|
+
expect(pattern.script_symbols).not_to include method
|
|
68
|
+
expect(object.methods.length).to be 1
|
|
69
|
+
expect(object.methods).to include method
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "adds properties following an object to its array of properties" do
|
|
73
|
+
pattern.add(:script, [klass, object, property])
|
|
74
|
+
post_process
|
|
75
|
+
|
|
76
|
+
expect(pattern.script_symbols.length).to be 2
|
|
77
|
+
expect(pattern.script_symbols).not_to include property
|
|
78
|
+
expect(object.properties.length).to be 1
|
|
79
|
+
expect(object.properties).to include property
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "adds methods following a variable to its array of methods" do
|
|
83
|
+
pattern.add(:script, [object, variable, method])
|
|
84
|
+
post_process
|
|
85
|
+
|
|
86
|
+
expect(pattern.script_symbols.length).to be 2
|
|
87
|
+
expect(pattern.script_symbols).not_to include method
|
|
88
|
+
expect(variable.methods.length).to be 1
|
|
89
|
+
expect(variable.methods).to include method
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "adds properties following a variable to its array of properties" do
|
|
93
|
+
pattern.add(:script, [object, variable, property])
|
|
94
|
+
post_process
|
|
95
|
+
|
|
96
|
+
expect(pattern.script_symbols.length).to be 2
|
|
97
|
+
expect(pattern.script_symbols).not_to include property
|
|
98
|
+
expect(variable.properties.length).to be 1
|
|
99
|
+
expect(variable.properties).to include property
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "adds methods following a function to its array of methods" do
|
|
103
|
+
pattern.add(:script, [variable, function, method])
|
|
104
|
+
post_process
|
|
105
|
+
|
|
106
|
+
expect(pattern.script_symbols.length).to be 2
|
|
107
|
+
expect(pattern.script_symbols).not_to include method
|
|
108
|
+
expect(function.methods.length).to be 1
|
|
109
|
+
expect(function.methods).to include method
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "adds properties following a function to its array of properties" do
|
|
113
|
+
pattern.add(:script, [variable, function, property])
|
|
114
|
+
post_process
|
|
115
|
+
|
|
116
|
+
expect(pattern.script_symbols.length).to be 2
|
|
117
|
+
expect(pattern.script_symbols).not_to include property
|
|
118
|
+
expect(function.properties.length).to be 1
|
|
119
|
+
expect(function.properties).to include property
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "adds properties and methods to the most object" do
|
|
123
|
+
pattern.add(:script, [object, klass, property, factory, method])
|
|
124
|
+
post_process
|
|
125
|
+
|
|
126
|
+
expect(pattern.script_symbols.length).to be 3
|
|
127
|
+
expect(pattern.script_symbols).not_to include property
|
|
128
|
+
expect(pattern.script_symbols).not_to include method
|
|
129
|
+
|
|
130
|
+
expect(factory.properties).to be_empty
|
|
131
|
+
expect(klass.properties.length).to be 1
|
|
132
|
+
expect(klass.properties).to include property
|
|
133
|
+
|
|
134
|
+
expect(klass.methods).to be_empty
|
|
135
|
+
expect(factory.methods.length).to be 1
|
|
136
|
+
expect(factory.methods).to include method
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "adds properties to a non-recent object if the for attribute is explicitly set" do
|
|
140
|
+
property.for = factory.name
|
|
141
|
+
pattern.add(:script, [factory, object, property])
|
|
142
|
+
post_process
|
|
143
|
+
|
|
144
|
+
expect(pattern.script_symbols.length).to be 2
|
|
145
|
+
expect(pattern.script_symbols).not_to include property
|
|
146
|
+
expect(factory.properties).to eq [property]
|
|
147
|
+
expect(object.properties).to be_empty
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it "adds nested properties" do
|
|
151
|
+
object.for = factory.name
|
|
152
|
+
pattern.add(:script, [factory, object, property])
|
|
153
|
+
post_process
|
|
154
|
+
|
|
155
|
+
expect(pattern.script_symbols.length).to be 1
|
|
156
|
+
expect(pattern.script_symbols).to include factory
|
|
157
|
+
expect(factory.properties).to eq [object]
|
|
158
|
+
expect(object.properties).to eq [property]
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
private
|
|
162
|
+
|
|
163
|
+
def post_process
|
|
164
|
+
Docks::Process.process(pattern)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Tags::Method do
|
|
4
|
+
subject { Docks::Tags::Method.instance }
|
|
5
|
+
|
|
6
|
+
it "does not allow multiline content" do
|
|
7
|
+
expect(subject.multiline?).to be false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "only allows multiple per block" do
|
|
11
|
+
expect(subject.multiple_allowed?).to be false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#process" do
|
|
15
|
+
it "marks the attribute as true" do
|
|
16
|
+
symbol = Docks::Containers::Symbol.new(name: "foo", method: "")
|
|
17
|
+
Docks::Process.process(symbol)
|
|
18
|
+
expect(symbol[subject.name]).to be true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "forces the symbol to be a function type" do
|
|
22
|
+
symbol = Docks::Containers::Symbol.new(name: "foo", method: "")
|
|
23
|
+
symbol = Docks::Process.process(symbol)
|
|
24
|
+
expect(symbol).to be_a Docks::Containers::Function
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Tags::Name do
|
|
4
|
+
subject { Docks::Tags::Name.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 "does not perform any processing" do
|
|
16
|
+
content = "foo"
|
|
17
|
+
expect(subject.process(content)).to eq content
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Tags::Object do
|
|
4
|
+
subject { Docks::Tags::Object.instance }
|
|
5
|
+
|
|
6
|
+
it "does not allow multiline content" do
|
|
7
|
+
expect(subject.multiline?).to be false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "does not allow multiple tags 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 "sets the type of the symbol to 'object'" do
|
|
18
|
+
symbol[subject.name] = ""
|
|
19
|
+
subject.process(symbol)
|
|
20
|
+
expect(symbol[subject.name]).to be true
|
|
21
|
+
expect(symbol.type).to eq "Object"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|