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,158 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Containers::Component do
|
|
4
|
+
let(:sub_subcomponent) do
|
|
5
|
+
Docks::Containers::Component.new(name: "foo__bar__baz")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:subcomponent) do
|
|
9
|
+
Docks::Containers::Component.new(name: "foo__bar", subcomponents: [sub_subcomponent])
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:component) do
|
|
13
|
+
Docks::Containers::Component.new(name: "foo", subcomponents: [subcomponent])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:states) do
|
|
17
|
+
[
|
|
18
|
+
Docks::Containers::State.new(name: "foo--is-bar"),
|
|
19
|
+
Docks::Containers::State.new(name: "foo--is-baz")
|
|
20
|
+
]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:variants) do
|
|
24
|
+
[
|
|
25
|
+
Docks::Containers::Variant.new(name: "foo--bar"),
|
|
26
|
+
Docks::Containers::Variant.new(name: "foo--baz")
|
|
27
|
+
]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#has_demo?" do
|
|
31
|
+
it "has a demo when it has non-empty markup" do
|
|
32
|
+
expect(described_class.new(markup: "<p>Hi!</p>").has_demo?).to be true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "has a demo when it has non-empty helper" do
|
|
36
|
+
expect(described_class.new(helper: "<p><%= foo %></p>").has_demo?).to be true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "doesn't have a demo when there is no markup or helper" do
|
|
40
|
+
expect(described_class.new(foo: "bar").has_demo?).to be false
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "doesn't have a demo when the markup is empty" do
|
|
44
|
+
expect(described_class.new(markup: "").has_demo?).to be false
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "doesn't have a demo when the helper is empty" do
|
|
48
|
+
expect(described_class.new(helper: "").has_demo?).to be false
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe "#subcomponents" do
|
|
53
|
+
context "when no options are passed" do
|
|
54
|
+
it "has subcomponents when they are included on the component" do
|
|
55
|
+
expect(component.subcomponent.length).to be 1
|
|
56
|
+
expect(component.subcomponents).to include subcomponent
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "has an empty array of subcomponents when not included" do
|
|
60
|
+
component = described_class.new
|
|
61
|
+
expect(component.subcomponent).to be_an Array
|
|
62
|
+
expect(component.subcomponent).to be_empty
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "when the :recursive option is true" do
|
|
67
|
+
it "returns subcomponents recursively" do
|
|
68
|
+
subcomponents = component.subcomponents(recursive: true)
|
|
69
|
+
expect(subcomponents.length).to be 2
|
|
70
|
+
expect(subcomponents).to include subcomponent
|
|
71
|
+
expect(subcomponents).to include sub_subcomponent
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "doesn't duplicate the subcomponents" do
|
|
75
|
+
component.subcomponents(recursive: true)
|
|
76
|
+
expect(component.subcomponents.length).to be 1
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe "#variations" do
|
|
82
|
+
it "has no variations when there are no states or variants" do
|
|
83
|
+
component = described_class.new({})
|
|
84
|
+
expect(component.variations).to be_empty
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "has variations when there are only states" do
|
|
88
|
+
component = described_class.new(state: states)
|
|
89
|
+
variations = component.variations
|
|
90
|
+
|
|
91
|
+
expect(variations).not_to be_empty
|
|
92
|
+
states.each do |state|
|
|
93
|
+
expect(variations).to include(state)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "has variations when there are only variants" do
|
|
98
|
+
component = described_class.new(variant: variants)
|
|
99
|
+
variations = component.variations
|
|
100
|
+
|
|
101
|
+
expect(variations).not_to be_empty
|
|
102
|
+
variants.each do |variant|
|
|
103
|
+
expect(variations).to include(variant)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "has variations when there are states and variants" do
|
|
108
|
+
component = described_class.new(state: states, variant: variants)
|
|
109
|
+
variations = component.variations
|
|
110
|
+
|
|
111
|
+
expect(variations).not_to be_empty
|
|
112
|
+
(states + variants).each do |variation|
|
|
113
|
+
expect(variations).to include(variation)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe "#find" do
|
|
119
|
+
it "returns a component when the descriptor exactly matches" do
|
|
120
|
+
expect(component.find(component.name)).to be component
|
|
121
|
+
expect(component.find("#{component.name}#bar")).to be false
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "returns a nested component when it exactly matches" do
|
|
125
|
+
expect(component.find(sub_subcomponent.name)).to be sub_subcomponent
|
|
126
|
+
expect(component.find("#{sub_subcomponent.name}#bar")).to be false
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "returns a variation when the variation name exactly matches" do
|
|
130
|
+
subcomponent.states.concat(states)
|
|
131
|
+
states.each { |state| state.for = subcomponent.name }
|
|
132
|
+
expect(component.find(states.first.name)).to be states.first
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "returns a variation that is declared as an instance member" do
|
|
136
|
+
subcomponent.states.concat(states)
|
|
137
|
+
states.each { |state| state.for = subcomponent.name }
|
|
138
|
+
expect(component.find("#{subcomponent.name}##{states.first.name}")).to be states.first
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "doesn't return a variation unless the symbol name matches" do
|
|
142
|
+
subcomponent.states.concat(states)
|
|
143
|
+
expect(component.find("qux##{states.first.name}")).to be false
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe "#summary" do
|
|
148
|
+
let(:summary) { component.summary }
|
|
149
|
+
|
|
150
|
+
it "preserves the symbol_id, name, variations, and subcomponents" do
|
|
151
|
+
expect(summary).to be_a described_class
|
|
152
|
+
expect(summary.name).to eq component.name
|
|
153
|
+
expect(summary.symbol_id).to eq component.symbol_id
|
|
154
|
+
expect(summary.variations).to eq component.variations.map(&:summary)
|
|
155
|
+
expect(summary.subcomponents).to eq component.subcomponents.map(&:summary)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
state_one = OpenStruct.new(name: "foo", demo_type: Docks::Types::Demo::NONE)
|
|
4
|
+
state_two = OpenStruct.new(name: "bar", base_class: "b", demo_type: Docks::Types::Demo::SELECT)
|
|
5
|
+
variant_one = OpenStruct.new(name: "baz", demo_type: Docks::Types::Demo::SELECT)
|
|
6
|
+
variant_two = OpenStruct.new(name: "qux", demo_type: Docks::Types::Demo::JOINT)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe Docks::Containers::Demo do
|
|
10
|
+
subject { Docks::Containers::Demo }
|
|
11
|
+
|
|
12
|
+
before :each do
|
|
13
|
+
Docks::Tags.register_bundled_tags
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:basic_component) do
|
|
17
|
+
Docks::Containers::Component.new(name: "flarb", state: [state_one])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
let(:complex_component) do
|
|
21
|
+
Docks::Containers::Component.new(name: "blarg", state: [state_one, state_two], variant: [variant_one, variant_two])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
let(:basic_demo) { subject.new(basic_component) }
|
|
25
|
+
let(:complex_demo) { subject.new(complex_component) }
|
|
26
|
+
|
|
27
|
+
describe "#name" do
|
|
28
|
+
it "has the same name as its main component" do
|
|
29
|
+
expect(complex_demo.name).to eq complex_component.name
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "#component" do
|
|
34
|
+
it "returns its main component" do
|
|
35
|
+
expect(complex_demo.component).to be complex_component
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "#select_variations" do
|
|
40
|
+
it "has no select variations when none are included in the component" do
|
|
41
|
+
expect(basic_demo.select_variations).to eq Array.new
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "has select variations when they are included with the component" do
|
|
45
|
+
variations = complex_demo.select_variations
|
|
46
|
+
expect(variations.length).to be 2
|
|
47
|
+
expect(variations).to include state_two
|
|
48
|
+
expect(variations).to include variant_one
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "has no select variations when none are included and the user asks them to be grouped by base component" do
|
|
52
|
+
expect(basic_demo.select_variations(group_by_component: true)).to eq Hash.new
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "groups select variations by their base component when requested" do
|
|
56
|
+
variations = complex_demo.select_variations(group_by_component: true)
|
|
57
|
+
|
|
58
|
+
expect(variations.length).to be 1
|
|
59
|
+
|
|
60
|
+
component_variations = variations[complex_demo.name]
|
|
61
|
+
expect(component_variations.length).to be 2
|
|
62
|
+
expect(component_variations).to include state_two
|
|
63
|
+
expect(component_variations).to include variant_one
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "includes select variations from subcomponents" do
|
|
67
|
+
basic_component[:state] = [state_two]
|
|
68
|
+
complex_component[:subcomponents] = [basic_component]
|
|
69
|
+
variations = complex_demo.select_variations(group_by_component: true)
|
|
70
|
+
|
|
71
|
+
expect(variations.length).to be 2
|
|
72
|
+
|
|
73
|
+
subcomponent_variations = variations[basic_component.name]
|
|
74
|
+
expect(subcomponent_variations.length).to be 1
|
|
75
|
+
expect(subcomponent_variations).to include state_two
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "includes select variations from included components" do
|
|
79
|
+
basic_component[:state] = [state_two]
|
|
80
|
+
complex_component[:included_symbols] = [basic_component]
|
|
81
|
+
variations = complex_demo.select_variations(group_by_component: true)
|
|
82
|
+
|
|
83
|
+
expect(variations.length).to be 2
|
|
84
|
+
|
|
85
|
+
subcomponent_variations = variations[basic_component.name]
|
|
86
|
+
expect(subcomponent_variations.length).to be 1
|
|
87
|
+
expect(subcomponent_variations).to include state_two
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "includes select variations that are directly included" do
|
|
91
|
+
complex_component[:included_symbols] = [state_one, state_two]
|
|
92
|
+
variations = complex_demo.select_variations(group_by_component: true)
|
|
93
|
+
|
|
94
|
+
expect(variations.length).to be 2
|
|
95
|
+
|
|
96
|
+
subcomponent_variations = variations[state_two.base_class]
|
|
97
|
+
expect(subcomponent_variations.length).to be 1
|
|
98
|
+
expect(subcomponent_variations).to include state_two
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "#joint_variations" do
|
|
103
|
+
it "has no joint variations when none are included in the component" do
|
|
104
|
+
expect(basic_demo.joint_variations).to eq Array.new
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "has joint variations when they are included in the component" do
|
|
108
|
+
variations = complex_demo.joint_variations
|
|
109
|
+
expect(variations.length).to be 1
|
|
110
|
+
expect(variations).to include variant_two
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Containers::Function do
|
|
4
|
+
let(:instance_method) do
|
|
5
|
+
described_class.new(name: "foo", static: false, method: true, for: "Foo")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:static_method) do
|
|
9
|
+
described_class.new(name: "bar", static: true, method: true, for: "Foo")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
let(:function) do
|
|
13
|
+
described_class.new(name: "baz")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
let(:factory) do
|
|
17
|
+
Docks::Containers::Factory.new(name: "Foo")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
before(:each) do
|
|
21
|
+
factory.add_members(instance_method, static_method)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "#static?" do
|
|
25
|
+
it "returns true for a static method" do
|
|
26
|
+
expect(instance_method.static?).to be false
|
|
27
|
+
expect(static_method.static?).to be true
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "#instance?" do
|
|
32
|
+
it "returns true for an instance method" do
|
|
33
|
+
expect(instance_method.instance?).to be true
|
|
34
|
+
expect(static_method.instance?).to be false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "#method?" do
|
|
39
|
+
it "is a method when it has a for attribute" do
|
|
40
|
+
expect(function.method?).to be false
|
|
41
|
+
expect(instance_method.method?).to be true
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "#symbol_id" do
|
|
46
|
+
it "returns the default if the function is not a method" do
|
|
47
|
+
expect(function.symbol_id).to eq "function-#{function.name}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "indicates it's a method and adds the classlike's name if it is a method" do
|
|
51
|
+
expect(instance_method.symbol_id).to eq "method-#{factory.name}-#{instance_method.name}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "indicates that it's static if appropriate" do
|
|
55
|
+
expect(static_method.symbol_id).to eq "method-static-#{factory.name}-#{static_method.name}"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#to_descriptor" do
|
|
60
|
+
let(:pattern) { Docks::Containers::Pattern.new(name: "foo") }
|
|
61
|
+
|
|
62
|
+
it "returns the super descriptor if not a property" do
|
|
63
|
+
expect(function.to_descriptor).to eq function.name
|
|
64
|
+
|
|
65
|
+
pattern.add(:script, function)
|
|
66
|
+
expect(function.to_descriptor).to eq "#{pattern.name}::#{function.name}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "returns the proper instance property descriptor" do
|
|
70
|
+
pattern.add(:script, factory)
|
|
71
|
+
expect(instance_method.to_descriptor).to eq "#{factory.to_descriptor}##{instance_method.name}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "returns the proper static property descriptor" do
|
|
75
|
+
pattern.add(:script, factory)
|
|
76
|
+
expect(static_method.to_descriptor).to eq "#{factory.to_descriptor}.#{static_method.name}"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "#summary" do
|
|
81
|
+
it "preserves the symbol_id, name, static and method status" do
|
|
82
|
+
[static_method, instance_method, function].each do |func|
|
|
83
|
+
summary = func.summary
|
|
84
|
+
|
|
85
|
+
expect(summary).to be_a described_class
|
|
86
|
+
expect(summary.name).to eq func.name
|
|
87
|
+
expect(summary.symbol_id).to eq func.symbol_id
|
|
88
|
+
expect(summary.method?).to eq func.method?
|
|
89
|
+
expect(summary.static?).to eq func.static?
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "#find" do
|
|
95
|
+
it "finds the function if it's not a method and the symbol matches" do
|
|
96
|
+
expect(function.find(function.name)).to be function
|
|
97
|
+
expect(function.find(static_method.name)).to be false
|
|
98
|
+
expect(static_method.find(static_method.name)).to be false
|
|
99
|
+
expect(instance_method.find(instance_method.name)).to be false
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "finds the function if it's a static method and the name matches" do
|
|
103
|
+
expect(function.find("foo.#{function.name}")).to be false
|
|
104
|
+
expect(static_method.find("foo.#{static_method.name}")).to be static_method
|
|
105
|
+
expect(static_method.find("foo.#{instance_method.name}")).to be false
|
|
106
|
+
expect(instance_method.find("foo.#{instance_method.name}")).to be false
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "finds the function if it's an instance method and the name matches" do
|
|
110
|
+
expect(function.find("foo##{function.name}")).to be false
|
|
111
|
+
expect(static_method.find("foo##{static_method.name}")).to be false
|
|
112
|
+
expect(instance_method.find("foo##{instance_method.name}")).to be instance_method
|
|
113
|
+
expect(static_method.find("foo##{static_method.name}")).to be false
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Docks::Containers::Pattern do
|
|
4
|
+
before :each do
|
|
5
|
+
Docks::Tags.register_bundled_tags
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:name) { "button" }
|
|
9
|
+
let(:title) { "UI Button" }
|
|
10
|
+
let(:now) { Date.parse("1991-01-11") }
|
|
11
|
+
let(:pattern_symbol) { Docks::Containers::Symbol.new(pattern: title) }
|
|
12
|
+
let(:pattern) { described_class.new(name: name) }
|
|
13
|
+
|
|
14
|
+
describe "#name" do
|
|
15
|
+
it "is the name of the pattern during initialization" do
|
|
16
|
+
expect(pattern.name).to eq name
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "#title" do
|
|
21
|
+
it "is the capitalized name of the pattern if pattern block has been added" do
|
|
22
|
+
expect(pattern.title).to eq name.capitalize
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "is the title specified in the pattern block if it has been added" do
|
|
26
|
+
pattern.add(:style, pattern_symbol)
|
|
27
|
+
expect(pattern.title).to eq title
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe "#group" do
|
|
32
|
+
it "defaults to including the pattern in some common group" do
|
|
33
|
+
group_1, group_2 = pattern.group, described_class.new(name: "foo").group
|
|
34
|
+
expect(group_1).to_not be nil
|
|
35
|
+
expect(group_1).to eq group_2
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "uses the group from the pattern block, if added" do
|
|
39
|
+
pattern_symbol[Docks::Tags::Group] = "foo"
|
|
40
|
+
pattern.add(:style, pattern_symbol)
|
|
41
|
+
expect(pattern.group).to eq "foo"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "#valid?" do
|
|
46
|
+
it "is invalid if it has no pattern block and no other symbols" do
|
|
47
|
+
expect(pattern.valid?).to be false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "is valid if it has a pattern block" do
|
|
51
|
+
pattern.add(:style, pattern_symbol)
|
|
52
|
+
expect(pattern.valid?).to be true
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "isn't valid if all details of the pattern are nil" do
|
|
56
|
+
pattern.description = nil
|
|
57
|
+
expect(pattern.valid?).to be false
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "is valid if any other symbol has been added" do
|
|
61
|
+
pattern.add(:script, Docks::Containers::Function.new)
|
|
62
|
+
expect(pattern.valid?).to be true
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "#structure_symbols" do
|
|
67
|
+
before(:each) do
|
|
68
|
+
pattern.add(:style, Docks::Containers::Component.new)
|
|
69
|
+
pattern.add(:script, Docks::Containers::Component.new)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "returns all symbols from style sources" do
|
|
73
|
+
expect(pattern.structure_symbols.length).to be 1
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "is aliased to #style_symbols" do
|
|
77
|
+
expect(pattern.style_symbols).to be pattern.structure_symbols
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe "#has_structure?" do
|
|
82
|
+
it "has no structure when there are no style results" do
|
|
83
|
+
expect(pattern.has_structure?).to be false
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "has structure when there are style results" do
|
|
87
|
+
pattern.add(:style, Docks::Containers::Component.new)
|
|
88
|
+
expect(pattern.has_structure?).to be true
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe "#behavior_symbols" do
|
|
93
|
+
before(:each) do
|
|
94
|
+
pattern.add(:style, Docks::Containers::Component.new)
|
|
95
|
+
pattern.add(:script, Docks::Containers::Component.new)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "returns all symbols from style sources" do
|
|
99
|
+
expect(pattern.behavior_symbols.length).to be 1
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "is aliased to #script_symbols" do
|
|
103
|
+
expect(pattern.script_symbols).to be pattern.behavior_symbols
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
describe "#has_behavior?" do
|
|
108
|
+
it "has no behavior when there are no script results" do
|
|
109
|
+
expect(pattern.has_behavior?).to be false
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "has behavior when there are script results" do
|
|
113
|
+
pattern.add(:script, Docks::Containers::Factory.new)
|
|
114
|
+
expect(pattern.has_behavior?).to be true
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe "#add" do
|
|
119
|
+
let(:dummy_symbol_1) { Docks::Containers::Symbol.new }
|
|
120
|
+
let(:dummy_symbol_2) { Docks::Containers::Symbol.new }
|
|
121
|
+
|
|
122
|
+
it "adds a symbol to the passed source" do
|
|
123
|
+
pattern.add(:script, dummy_symbol_1)
|
|
124
|
+
pattern.add(:style, dummy_symbol_2)
|
|
125
|
+
|
|
126
|
+
expect(pattern.behavior_symbols.length).to be 1
|
|
127
|
+
expect(pattern.behavior_symbols.first).to be dummy_symbol_1
|
|
128
|
+
expect(pattern.structure_symbols.length).to be 1
|
|
129
|
+
expect(pattern.structure_symbols.first).to be dummy_symbol_2
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "adds an array of symbols to the passed source" do
|
|
133
|
+
pattern.add(:script, [dummy_symbol_1, dummy_symbol_2])
|
|
134
|
+
|
|
135
|
+
expect(pattern.behavior_symbols.length).to be 2
|
|
136
|
+
expect(pattern.behavior_symbols).to eq [dummy_symbol_1, dummy_symbol_2]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "doesn't add a pattern symbol to the passed source" do
|
|
140
|
+
pattern.add(:script, pattern_symbol)
|
|
141
|
+
expect(pattern.behavior_symbols).to be_empty
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "still adds the other symbols in a passed array even if a pattern symbol is among them" do
|
|
145
|
+
pattern.add(:script, [dummy_symbol_1, pattern_symbol, dummy_symbol_2])
|
|
146
|
+
|
|
147
|
+
expect(pattern.behavior_symbols.length).to be 2
|
|
148
|
+
expect(pattern.behavior_symbols).to eq [dummy_symbol_1, dummy_symbol_2]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "adds the belongs_to attribute to all contained symbols" do
|
|
152
|
+
pattern.add(:script, [dummy_symbol_1, dummy_symbol_2])
|
|
153
|
+
|
|
154
|
+
pattern.symbols.each do |symbol|
|
|
155
|
+
expect(symbol.belongs_to).to be pattern
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
describe "#remove" do
|
|
161
|
+
it "removes a symbol" do
|
|
162
|
+
symbol = Docks::Containers::Symbol.new
|
|
163
|
+
pattern.add(:style, symbol)
|
|
164
|
+
expect(pattern.structure_symbols).to include symbol
|
|
165
|
+
pattern.remove(symbol)
|
|
166
|
+
expect(pattern.structure_symbols).not_to include symbol
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe "#method_missing" do
|
|
171
|
+
it "delegates missing methods to the pattern block" do
|
|
172
|
+
expect(pattern.deprecated).to be nil
|
|
173
|
+
|
|
174
|
+
pattern_symbol.deprecated = "2.0"
|
|
175
|
+
pattern.add(:style, pattern_symbol)
|
|
176
|
+
expect(pattern.deprecated).to eq "2.0"
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
describe "#find" do
|
|
181
|
+
it "returns itself if there is a matching pattern name and no symbol" do
|
|
182
|
+
expect(pattern.find(Docks::Descriptor.new(pattern.name, assume: :pattern))).to be pattern
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "returns false when it can't find a given symbol" do
|
|
186
|
+
expect(pattern.find("foo")).to be false
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it "returns a symbol whose name matches the passed descriptor" do
|
|
190
|
+
symbol = Docks::Containers::Component.new(name: "bar")
|
|
191
|
+
pattern.add(:style, symbol)
|
|
192
|
+
expect(pattern.find(symbol.name)).to be symbol
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "asks the contained symbol to find the descriptor and returns if successful" do
|
|
196
|
+
method = Docks::Containers::Function.new(name: "toggle", method: true)
|
|
197
|
+
factory = Docks::Containers::Factory.new(name: "Foo")
|
|
198
|
+
factory.add_member(method)
|
|
199
|
+
|
|
200
|
+
pattern.add(:script, factory)
|
|
201
|
+
|
|
202
|
+
search = Docks::Descriptor.new("Foo#toggle")
|
|
203
|
+
expect(factory).to receive(:find).with(search).and_call_original
|
|
204
|
+
expect(pattern.find(search)).to be method
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
describe "container associations" do
|
|
209
|
+
it "includes a method to access all symbols of a given type" do
|
|
210
|
+
Docks::Containers::TOP_LEVEL_SYMBOLS.each do |symbol|
|
|
211
|
+
symbol_instance = Docks::Containers.container_for(symbol).new(name: "foo")
|
|
212
|
+
pattern.add(:script, symbol_instance)
|
|
213
|
+
|
|
214
|
+
results_of_symbol = pattern.send(symbol.pluralize.to_sym)
|
|
215
|
+
expect(results_of_symbol.length).to be 1
|
|
216
|
+
expect(results_of_symbol.first).to be symbol_instance
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
it "includes only the set of symbols of a given type matching the passed options" do
|
|
221
|
+
Docks::Containers::TOP_LEVEL_SYMBOLS.each do |symbol|
|
|
222
|
+
symbol_instance = Docks::Containers.container_for(symbol).new(name: "foo")
|
|
223
|
+
pattern.add(:script, symbol_instance)
|
|
224
|
+
|
|
225
|
+
results_of_symbol = pattern.send(symbol.pluralize.to_sym, exclude: :script)
|
|
226
|
+
expect(results_of_symbol.length).to be 0
|
|
227
|
+
|
|
228
|
+
results_of_symbol = pattern.send(symbol.pluralize.to_sym, include: :script)
|
|
229
|
+
expect(results_of_symbol.length).to be 1
|
|
230
|
+
expect(results_of_symbol.first).to be symbol_instance
|
|
231
|
+
|
|
232
|
+
results_of_symbol = pattern.send(symbol.pluralize.to_sym, exclude: :style)
|
|
233
|
+
expect(results_of_symbol.length).to be 1
|
|
234
|
+
expect(results_of_symbol.first).to be symbol_instance
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
describe "#symbols" do
|
|
240
|
+
it "combines all symbol sources" do
|
|
241
|
+
symbol_one = Docks::Containers::Symbol.new(name: "foo")
|
|
242
|
+
symbol_two = Docks::Containers::Symbol.new(name: "bar")
|
|
243
|
+
symbol_three = Docks::Containers::Symbol.new(name: "baz")
|
|
244
|
+
pattern.add(:style, symbol_one)
|
|
245
|
+
pattern.add(:script, symbol_two)
|
|
246
|
+
pattern.add(:style, symbol_three)
|
|
247
|
+
|
|
248
|
+
symbols = pattern.symbols
|
|
249
|
+
expect(symbols.length).to be 3
|
|
250
|
+
expect(symbols).to include symbol_one
|
|
251
|
+
expect(symbols).to include symbol_two
|
|
252
|
+
expect(symbols).to include symbol_three
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
describe "#demos" do
|
|
257
|
+
it "creates a demo for each component that needs one" do
|
|
258
|
+
component_one = Docks::Containers::Component.new(name: "foo")
|
|
259
|
+
component_two = Docks::Containers::Component.new(name: "bar")
|
|
260
|
+
pattern.add(:style, [component_one, component_two])
|
|
261
|
+
|
|
262
|
+
expect(component_one).to receive(:has_demo?).and_return(true)
|
|
263
|
+
expect(component_two).to receive(:has_demo?).and_return(false)
|
|
264
|
+
|
|
265
|
+
expect(pattern.demos.length).to be 1
|
|
266
|
+
expect(pattern.demos.first.component).to be component_one
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it "creates a demo for variations that need one" do
|
|
270
|
+
variant = OpenStruct.new(demo_type: Docks::Types::Demo::OWN, name: "bar--baz")
|
|
271
|
+
component = Docks::Containers::Component.new(name: "bar", variant: [variant])
|
|
272
|
+
pattern.add(:style, component)
|
|
273
|
+
|
|
274
|
+
expect(pattern.demos.length).to be 1
|
|
275
|
+
expect(pattern.demos.last.component).to be variant
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
describe "#summary" do
|
|
280
|
+
before(:each) { pattern.add(:script, Docks::Containers::Function.new(name: "foo")) }
|
|
281
|
+
let(:summary) { pattern.summary }
|
|
282
|
+
|
|
283
|
+
it "preserves the name, group, title, and symbols" do
|
|
284
|
+
expect(summary).to be_a described_class
|
|
285
|
+
expect(summary.name).to eq pattern.name
|
|
286
|
+
expect(summary.group).to eq pattern.group
|
|
287
|
+
expect(summary.title).to eq pattern.title
|
|
288
|
+
expect(summary.symbols).to eq pattern.symbols.map(&:summary)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
end
|