faceter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +9 -0
  4. data/.metrics +9 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +2 -0
  7. data/.travis.yml +18 -0
  8. data/.yardopts +3 -0
  9. data/CHANGELOG.md +3 -0
  10. data/Gemfile +9 -0
  11. data/Guardfile +10 -0
  12. data/LICENSE +21 -0
  13. data/README.md +295 -0
  14. data/Rakefile +37 -0
  15. data/benchmark/data.json +1 -0
  16. data/benchmark/faceter.rb +73 -0
  17. data/benchmark/rom.rb +85 -0
  18. data/benchmark/run.rb +54 -0
  19. data/config/metrics/STYLEGUIDE +230 -0
  20. data/config/metrics/cane.yml +5 -0
  21. data/config/metrics/churn.yml +6 -0
  22. data/config/metrics/flay.yml +2 -0
  23. data/config/metrics/metric_fu.yml +14 -0
  24. data/config/metrics/reek.yml +1 -0
  25. data/config/metrics/roodi.yml +24 -0
  26. data/config/metrics/rubocop.yml +75 -0
  27. data/config/metrics/saikuro.yml +3 -0
  28. data/config/metrics/simplecov.yml +6 -0
  29. data/config/metrics/yardstick.yml +37 -0
  30. data/faceter.gemspec +29 -0
  31. data/lib/faceter.rb +54 -0
  32. data/lib/faceter/coercers.rb +68 -0
  33. data/lib/faceter/functions.rb +30 -0
  34. data/lib/faceter/functions/add_prefix.rb +25 -0
  35. data/lib/faceter/functions/claster.rb +27 -0
  36. data/lib/faceter/functions/clean.rb +27 -0
  37. data/lib/faceter/functions/drop_prefix.rb +29 -0
  38. data/lib/faceter/functions/exclude.rb +27 -0
  39. data/lib/faceter/functions/group.rb +41 -0
  40. data/lib/faceter/functions/keep_symbol.rb +27 -0
  41. data/lib/faceter/functions/split.rb +28 -0
  42. data/lib/faceter/functions/ungroup.rb +31 -0
  43. data/lib/faceter/functions/unwrap.rb +32 -0
  44. data/lib/faceter/functions/wrap.rb +32 -0
  45. data/lib/faceter/mapper.rb +38 -0
  46. data/lib/faceter/nodes/add_prefix.rb +21 -0
  47. data/lib/faceter/nodes/change_prefix.rb +51 -0
  48. data/lib/faceter/nodes/create.rb +43 -0
  49. data/lib/faceter/nodes/exclude.rb +25 -0
  50. data/lib/faceter/nodes/field.rb +25 -0
  51. data/lib/faceter/nodes/fold.rb +25 -0
  52. data/lib/faceter/nodes/group.rb +26 -0
  53. data/lib/faceter/nodes/list.rb +25 -0
  54. data/lib/faceter/nodes/remove_prefix.rb +21 -0
  55. data/lib/faceter/nodes/rename.rb +25 -0
  56. data/lib/faceter/nodes/stringify_keys.rb +26 -0
  57. data/lib/faceter/nodes/symbolize_keys.rb +26 -0
  58. data/lib/faceter/nodes/unfold.rb +25 -0
  59. data/lib/faceter/nodes/ungroup.rb +26 -0
  60. data/lib/faceter/nodes/unwrap.rb +26 -0
  61. data/lib/faceter/nodes/wrap.rb +26 -0
  62. data/lib/faceter/rules/append_nested.rb +28 -0
  63. data/lib/faceter/rules/merge_branches.rb +41 -0
  64. data/lib/faceter/rules/merge_excludes.rb +29 -0
  65. data/lib/faceter/rules/merge_renames.rb +27 -0
  66. data/lib/faceter/rules/order_fields.rb +27 -0
  67. data/lib/faceter/rules/prepend_nested.rb +51 -0
  68. data/lib/faceter/version.rb +11 -0
  69. data/spec/integration/commands/add_prefix_spec.rb +37 -0
  70. data/spec/integration/commands/create_spec.rb +33 -0
  71. data/spec/integration/commands/exclude_spec.rb +55 -0
  72. data/spec/integration/commands/fold_spec.rb +41 -0
  73. data/spec/integration/commands/group_spec.rb +64 -0
  74. data/spec/integration/commands/remove_prefix_spec.rb +63 -0
  75. data/spec/integration/commands/rename_spec.rb +45 -0
  76. data/spec/integration/commands/stringify_keys_spec.rb +65 -0
  77. data/spec/integration/commands/symbolize_keys_spec.rb +49 -0
  78. data/spec/integration/commands/unfold_spec.rb +41 -0
  79. data/spec/integration/commands/ungroup_spec.rb +64 -0
  80. data/spec/integration/commands/unwrap_spec.rb +51 -0
  81. data/spec/integration/commands/wrap_spec.rb +51 -0
  82. data/spec/integration/rom_spec.rb +39 -0
  83. data/spec/spec_helper.rb +25 -0
  84. data/spec/unit/coercers/create_spec.rb +16 -0
  85. data/spec/unit/coercers/exclude_spec.rb +31 -0
  86. data/spec/unit/coercers/field_spec.rb +11 -0
  87. data/spec/unit/coercers/fold_spec.rb +11 -0
  88. data/spec/unit/coercers/prefix_spec.rb +38 -0
  89. data/spec/unit/coercers/rename_spec.rb +11 -0
  90. data/spec/unit/coercers/unfold_spec.rb +11 -0
  91. data/spec/unit/coercers/unwrap_spec.rb +35 -0
  92. data/spec/unit/coercers/wrap_spec.rb +35 -0
  93. data/spec/unit/functions/add_prefix_spec.rb +12 -0
  94. data/spec/unit/functions/claster_spec.rb +12 -0
  95. data/spec/unit/functions/clean_spec.rb +18 -0
  96. data/spec/unit/functions/drop_prefix_spec.rb +33 -0
  97. data/spec/unit/functions/exclude_spec.rb +64 -0
  98. data/spec/unit/functions/group_spec.rb +176 -0
  99. data/spec/unit/functions/keep_symbol_spec.rb +21 -0
  100. data/spec/unit/functions/split_spec.rb +64 -0
  101. data/spec/unit/functions/ungroup_spec.rb +87 -0
  102. data/spec/unit/functions/unwrap_spec.rb +54 -0
  103. data/spec/unit/functions/wrap_spec.rb +67 -0
  104. data/spec/unit/nodes/add_prefix_spec.rb +62 -0
  105. data/spec/unit/nodes/create_spec.rb +53 -0
  106. data/spec/unit/nodes/exclude_spec.rb +18 -0
  107. data/spec/unit/nodes/field_spec.rb +30 -0
  108. data/spec/unit/nodes/fold_spec.rb +19 -0
  109. data/spec/unit/nodes/group_spec.rb +163 -0
  110. data/spec/unit/nodes/list_spec.rb +27 -0
  111. data/spec/unit/nodes/remove_prefix_spec.rb +62 -0
  112. data/spec/unit/nodes/rename_spec.rb +16 -0
  113. data/spec/unit/nodes/stringify_keys_spec.rb +21 -0
  114. data/spec/unit/nodes/symbolize_keys_spec.rb +21 -0
  115. data/spec/unit/nodes/unfold_spec.rb +19 -0
  116. data/spec/unit/nodes/ungroup_spec.rb +92 -0
  117. data/spec/unit/nodes/unwrap_spec.rb +47 -0
  118. data/spec/unit/nodes/wrap_spec.rb +33 -0
  119. data/spec/unit/rules/append_nested_spec.rb +41 -0
  120. data/spec/unit/rules/merge_branches_spec.rb +58 -0
  121. data/spec/unit/rules/merge_excludes_spec.rb +31 -0
  122. data/spec/unit/rules/merge_renames_spec.rb +29 -0
  123. data/spec/unit/rules/order_fields_spec.rb +31 -0
  124. data/spec/unit/rules/prepend_nested_spec.rb +41 -0
  125. metadata +315 -0
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::List do
4
+
5
+ before do
6
+ class Faceter::Test::Foo < AbstractMapper::Node
7
+ define_method(:transproc) { Faceter::Functions[:rename_keys, foo: :baz] }
8
+ end
9
+
10
+ class Faceter::Test::Bar < AbstractMapper::Node
11
+ define_method(:transproc) { Faceter::Functions[:rename_keys, bar: :qux] }
12
+ end
13
+ end
14
+
15
+ let(:foo) { Faceter::Test::Foo.new }
16
+ let(:bar) { Faceter::Test::Bar.new }
17
+
18
+ it_behaves_like :creating_immutable_branch
19
+
20
+ it_behaves_like :mapping_immutable_input do
21
+ let(:block) { proc { [foo, bar] } }
22
+
23
+ let(:input) { [{ foo: :FOO, bar: :BAR }, { foo: :BAZ, bar: :QUX }] }
24
+ let(:output) { [{ baz: :FOO, qux: :BAR }, { baz: :BAZ, qux: :QUX }] }
25
+ end
26
+
27
+ end # describe Faceter::Nodes::List
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::RemovePrefix do
4
+
5
+ it_behaves_like :creating_immutable_node do
6
+ let(:attributes) { { prefix: :foo } }
7
+ end
8
+
9
+ it_behaves_like :mapping_immutable_input do
10
+ let(:attributes) { { prefix: "foo" } }
11
+
12
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
13
+ let(:output) { { bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
14
+ end
15
+
16
+ it_behaves_like :mapping_immutable_input do
17
+ let(:selector) { Selector.new only: /foo_bar/ }
18
+ let(:attributes) { { prefix: "foo", selector: selector } }
19
+
20
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
21
+ let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
22
+ end
23
+
24
+ it_behaves_like :mapping_immutable_input do
25
+ let(:selector) { Selector.new except: "foo_baz" }
26
+ let(:attributes) { { prefix: "foo", selector: selector } }
27
+
28
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
29
+ let(:output) { { bar: { "foo_baz" => :QUX }, "foo_baz" => :BAZ } }
30
+ end
31
+
32
+ it_behaves_like :mapping_immutable_input do
33
+ let(:attributes) { { prefix: "foo", separator: "." } }
34
+
35
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
36
+ let(:output) { { foo_bar: { "foo_baz" => :QUX }, "baz" => :BAZ } }
37
+ end
38
+
39
+ it_behaves_like :mapping_immutable_input do
40
+ let(:attributes) { { prefix: "foo", nested: true } }
41
+
42
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
43
+ let(:output) { { bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
44
+ end
45
+
46
+ it_behaves_like :mapping_immutable_input do
47
+ let(:selector) { Selector.new(except: :foo_bar) }
48
+ let(:attributes) { { prefix: "foo", selector: selector, nested: true } }
49
+
50
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
51
+ let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
52
+ end
53
+
54
+ it_behaves_like :mapping_immutable_input do
55
+ let(:selector) { Selector.new(only: "foo_baz") }
56
+ let(:attributes) { { prefix: "foo", selector: selector, nested: true } }
57
+
58
+ let(:input) { { foo_bar: { "foo_baz" => :QUX }, "foo.baz" => :BAZ } }
59
+ let(:output) { { foo_bar: { "baz" => :QUX }, "foo.baz" => :BAZ } }
60
+ end
61
+
62
+ end # describe Faceter::Nodes::RemovePrefix
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::Rename do
4
+
5
+ it_behaves_like :creating_immutable_node do
6
+ let(:attributes) { { keys: {} } }
7
+ end
8
+
9
+ it_behaves_like :mapping_immutable_input do
10
+ let(:attributes) { { keys: { foo: "bar", baz: "qux" } } }
11
+
12
+ let(:input) { { foo: :FOO, baz: :BAZ } }
13
+ let(:output) { { "bar" => :FOO, "qux" => :BAZ } }
14
+ end
15
+
16
+ end # describe Faceter::Nodes::Rename
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::StringifyKeys do
4
+
5
+ let(:input) { { foo: [{ 1 => :BAZ }] } }
6
+
7
+ it_behaves_like :creating_immutable_node do
8
+ let(:attributes) { {} }
9
+ end
10
+
11
+ it_behaves_like :mapping_immutable_input do
12
+ let(:attributes) { {} }
13
+ let(:output) { { "foo" => [{ "1" => :BAZ }] } }
14
+ end
15
+
16
+ it_behaves_like :mapping_immutable_input do
17
+ let(:attributes) { { nested: false } }
18
+ let(:output) { { "foo" => [{ 1 => :BAZ }] } }
19
+ end
20
+
21
+ end # describe Faceter::Nodes::StringifyKeys
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::SymbolizeKeys do
4
+
5
+ let(:input) { { "foo" => [{ 1 => :BAZ }] } }
6
+
7
+ it_behaves_like :creating_immutable_node do
8
+ let(:attributes) { {} }
9
+ end
10
+
11
+ it_behaves_like :mapping_immutable_input do
12
+ let(:attributes) { {} }
13
+ let(:output) { { foo: [{ "1".to_sym => :BAZ }] } }
14
+ end
15
+
16
+ it_behaves_like :mapping_immutable_input do
17
+ let(:attributes) { { nested: false } }
18
+ let(:output) { { foo: [{ 1 => :BAZ }] } }
19
+ end
20
+
21
+ end # describe Faceter::Nodes::SymbolizeKeys
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::Unfold do
4
+
5
+ let(:attributes) { { key: :foo } }
6
+
7
+ it_behaves_like :creating_immutable_node
8
+
9
+ it_behaves_like :mapping_immutable_input do
10
+ let(:input) { { foo: :FOO } }
11
+ let(:output) { :FOO }
12
+ end
13
+
14
+ it_behaves_like :mapping_immutable_input do
15
+ let(:input) { {} }
16
+ let(:output) { nil }
17
+ end
18
+
19
+ end # describe Faceter::Nodes::Unfold
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::Ungroup do
4
+
5
+ let(:attributes) { { key: :baz, selector: selector } }
6
+ let(:selector) { Selector.new(options) }
7
+
8
+ it_behaves_like :creating_immutable_node do
9
+ let(:options) { {} }
10
+ end
11
+
12
+ it_behaves_like :mapping_immutable_input do
13
+ let(:options) { {} }
14
+
15
+ let(:input) do
16
+ [{ qux: :QUX, baz: [] }]
17
+ end
18
+
19
+ let(:output) do
20
+ [{ qux: :QUX }]
21
+ end
22
+ end
23
+
24
+ it_behaves_like :mapping_immutable_input do
25
+ let(:options) { {} }
26
+
27
+ let(:input) do
28
+ [{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }]
29
+ end
30
+
31
+ let(:output) do
32
+ [{ qux: :QUX, foo: :FOO, bar: :FOO }, { qux: :QUX, foo: :BAR, bar: :BAR }]
33
+ end
34
+ end
35
+
36
+ it_behaves_like :mapping_immutable_input do
37
+ let(:options) { { only: [:foo, :bar] } }
38
+
39
+ let(:input) do
40
+ [{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }]
41
+ end
42
+
43
+ let(:output) do
44
+ [{ qux: :QUX, foo: :FOO, bar: :FOO }, { qux: :QUX, foo: :BAR, bar: :BAR }]
45
+ end
46
+ end
47
+
48
+ it_behaves_like :mapping_immutable_input do
49
+ let(:options) { { only: :foo } }
50
+
51
+ let(:input) do
52
+ [{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }]
53
+ end
54
+
55
+ let(:output) do
56
+ [
57
+ { qux: :QUX, foo: :FOO, baz: [{ bar: :FOO }] },
58
+ { qux: :QUX, foo: :BAR, baz: [{ bar: :BAR }] }
59
+ ]
60
+ end
61
+ end
62
+
63
+ it_behaves_like :mapping_immutable_input do
64
+ let(:options) { { only: :foo } }
65
+
66
+ let(:input) do
67
+ [{ qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :FOO, bar: :BAR }] }]
68
+ end
69
+
70
+ let(:output) do
71
+ [{ qux: :QUX, foo: :FOO, baz: [{ bar: :FOO }, { bar: :BAR }] }]
72
+ end
73
+ end
74
+
75
+ it_behaves_like :mapping_immutable_input do
76
+ let(:options) { { only: [:foo, :bar] } }
77
+
78
+ let(:input) do
79
+ [
80
+ {
81
+ qux: :QUX, foo: :QUX,
82
+ baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }]
83
+ }
84
+ ]
85
+ end
86
+
87
+ let(:output) do
88
+ [{ qux: :QUX, foo: :FOO, bar: :FOO }, { qux: :QUX, foo: :BAR, bar: :BAR }]
89
+ end
90
+ end
91
+
92
+ end # describe Faceter::Nodes::Ungroup
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::Unwrap do
4
+
5
+ let(:attributes) { { key: :baz, selector: selector } }
6
+ let(:selector) { Selector.new(options) }
7
+
8
+ it_behaves_like :creating_immutable_node do
9
+ let(:options) { {} }
10
+ end
11
+
12
+ it_behaves_like :mapping_immutable_input do
13
+ let(:options) { {} }
14
+
15
+ let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
16
+ let(:output) { { qux: :QUX, foo: :FOO, bar: :BAR, baz: :BAZ } }
17
+ end
18
+
19
+ it_behaves_like :mapping_immutable_input do
20
+ let(:options) { { only: [:foo, :bar] } }
21
+
22
+ let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
23
+ let(:output) { { baz: { baz: :BAZ }, qux: :QUX, foo: :FOO, bar: :BAR } }
24
+ end
25
+
26
+ it_behaves_like :mapping_immutable_input do
27
+ let(:options) { { only: [:foo, :baz] } }
28
+
29
+ let(:input) { { baz: { foo: :FOO, bar: :BAR, baz: :BAZ }, qux: :QUX } }
30
+ let(:output) { { qux: :QUX, foo: :FOO, baz: :BAZ } }
31
+ end
32
+
33
+ it_behaves_like :mapping_immutable_input do
34
+ let(:options) { { only: [:foo, :baz] } }
35
+
36
+ let(:input) { { baz: { foo: :FOO, baz: { bar: :BAR } }, qux: :QUX } }
37
+ let(:output) { { qux: :QUX, foo: :FOO, baz: { bar: :BAR } } }
38
+ end
39
+
40
+ it_behaves_like :mapping_immutable_input do
41
+ let(:options) { { only: :foo } }
42
+
43
+ let(:input) { { foo: { baz: :BAZ }, baz: { foo: { bar: :QUX } } } }
44
+ let(:output) { { foo: { bar: :QUX } } }
45
+ end
46
+
47
+ end # describe Faceter::Nodes::Unwrap
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Nodes::Wrap do
4
+
5
+ let(:attributes) { { key: key, selector: selector } }
6
+ let(:selector) { Selector.new(only: [:foo, :bar]) }
7
+
8
+ it_behaves_like :creating_immutable_node do
9
+ let(:key) { :baz }
10
+ end
11
+
12
+ it_behaves_like :mapping_immutable_input do
13
+ let(:key) { :bar }
14
+
15
+ let(:input) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
16
+ let(:output) { { bar: { foo: :FOO, bar: :BAR }, baz: :BAZ } }
17
+ end
18
+
19
+ it_behaves_like :mapping_immutable_input do
20
+ let(:key) { :baz }
21
+
22
+ let(:input) { { foo: :FOO, bar: :BAR, baz: { qux: :QUX } } }
23
+ let(:output) { { baz: { foo: :FOO, bar: :BAR, qux: :QUX } } }
24
+ end
25
+
26
+ it_behaves_like :mapping_immutable_input do
27
+ let(:key) { :bar }
28
+
29
+ let(:input) { { foo: :FOO, bar: { qux: :QUX }, baz: :BAZ } }
30
+ let(:output) { { bar: { foo: :FOO, bar: { qux: :QUX } }, baz: :BAZ } }
31
+ end
32
+
33
+ end # describe Faceter::Nodes::Wrap
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ module Faceter::Nodes
4
+
5
+ describe Faceter::Rules::AppendNested do
6
+
7
+ let(:one) { ice_double }
8
+ let(:input) { [left, right] }
9
+
10
+ it_behaves_like :skipping_nodes do
11
+ let(:left) { AddPrefix.new(prefix: :bar) }
12
+ let(:right) { AddPrefix.new(prefix: :foo) }
13
+ end
14
+
15
+ it_behaves_like :skipping_nodes do
16
+ let(:left) { Field.new(key: :bar) }
17
+ let(:right) { AddPrefix.new(prefix: :foo) }
18
+ end
19
+
20
+ it_behaves_like :skipping_nodes do
21
+ let(:left) { List.new }
22
+ let(:right) { Exclude.new(prefix: :foo) }
23
+ end
24
+
25
+ it_behaves_like :optimizing_nodes do
26
+ let(:left) { List.new { [one] } }
27
+ let(:right) { AddPrefix.new(prefix: :foo) }
28
+
29
+ let(:output) { left }
30
+ end
31
+
32
+ it_behaves_like :optimizing_nodes do
33
+ let(:left) { List.new { [one] } }
34
+ let(:right) { AddPrefix.new(prefix: :foo, nested: true) }
35
+
36
+ let(:output) { List.new { [one, right] } }
37
+ end
38
+
39
+ end # describe Faceter::Rules::AppendNested
40
+
41
+ end # module Faceter::Nodes
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ module Faceter::Nodes # namespace for constants
4
+
5
+ describe Faceter::Rules::MergeBranches do
6
+
7
+ let(:one) { ice_double }
8
+ let(:two) { ice_double }
9
+
10
+ it_behaves_like :skipping_nodes do
11
+ let(:left) { AddPrefix.new(prefix: :foo) }
12
+ let(:right) { AddPrefix.new(prefix: :foo) }
13
+ let(:input) { [left, right] }
14
+ end
15
+
16
+ it_behaves_like :skipping_nodes do
17
+ let(:left) { Field.new(key: :foo) }
18
+ let(:right) { AddPrefix.new(prefix: :foo) }
19
+ let(:input) { [left, right] }
20
+ end
21
+
22
+ it_behaves_like :skipping_nodes do
23
+ let(:left) { List.new }
24
+ let(:right) { Field.new(key: :foo) }
25
+ let(:input) { [left, right] }
26
+ end
27
+
28
+ it_behaves_like :skipping_nodes do
29
+ let(:left) { AbstractMapper::Branch.new }
30
+ let(:right) { List.new }
31
+ let(:input) { [left, right] }
32
+ end
33
+
34
+ it_behaves_like :skipping_nodes do
35
+ let(:left) { Field.new(key: :foo) }
36
+ let(:right) { Field.new(key: :bar) }
37
+ let(:input) { [left, right] }
38
+ end
39
+
40
+ it_behaves_like :optimizing_nodes do
41
+ let(:left) { List.new { [one] } }
42
+ let(:right) { List.new { [two] } }
43
+ let(:input) { [left, right] }
44
+
45
+ let(:output) { List.new { [one, two] } }
46
+ end
47
+
48
+ it_behaves_like :optimizing_nodes do
49
+ let(:left) { Field.new(key: :foo) { [one] } }
50
+ let(:right) { Field.new(key: :foo) { [two] } }
51
+ let(:input) { [left, right] }
52
+
53
+ let(:output) { Field.new(key: :foo) { [one, two] } }
54
+ end
55
+
56
+ end # describe Faceter::Rules::MergeBranches
57
+
58
+ end # module Faceter