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,11 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Coercers, ".unfold" do
4
+
5
+ subject { described_class[:unfold] }
6
+
7
+ it "coerces arguments" do
8
+ expect(subject[from: :baz]).to eq(key: :baz)
9
+ end
10
+
11
+ end # describe Faceter::Coercers.unfold
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Coercers, ".unwrap" do
4
+
5
+ subject { described_class[:unwrap] }
6
+
7
+ it "coerces arguments" do
8
+ expect(subject[from: :baz]).to eq(
9
+ key: :baz,
10
+ selector: Selector::ANYTHING
11
+ )
12
+ end
13
+
14
+ it "coerces arguments" do
15
+ expect(subject[:foo, :bar, from: :baz]).to eq(
16
+ key: :baz,
17
+ selector: Selector.new(only: [:foo, :bar])
18
+ )
19
+ end
20
+
21
+ it "coerces arguments" do
22
+ expect(subject[from: :baz, only: /foo/]).to eq(
23
+ key: :baz,
24
+ selector: Selector.new(only: /foo/)
25
+ )
26
+ end
27
+
28
+ it "coerces arguments" do
29
+ expect(subject[from: :baz, except: /foo/]).to eq(
30
+ key: :baz,
31
+ selector: Selector.new(except: /foo/)
32
+ )
33
+ end
34
+
35
+ end # describe Faceter::Coercers.unwrap
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Coercers, ".wrap" do
4
+
5
+ subject { described_class[:wrap] }
6
+
7
+ it "coerces arguments" do
8
+ expect(subject[to: :baz]).to eq(
9
+ key: :baz,
10
+ selector: Selector::ANYTHING
11
+ )
12
+ end
13
+
14
+ it "coerces arguments" do
15
+ expect(subject[:foo, :bar, to: :baz]).to eq(
16
+ key: :baz,
17
+ selector: Selector.new(only: [:foo, :bar])
18
+ )
19
+ end
20
+
21
+ it "coerces arguments" do
22
+ expect(subject[to: :baz, only: /foo/]).to eq(
23
+ key: :baz,
24
+ selector: Selector.new(only: /foo/)
25
+ )
26
+ end
27
+
28
+ it "coerces arguments" do
29
+ expect(subject[to: :baz, except: /foo/]).to eq(
30
+ key: :baz,
31
+ selector: Selector.new(except: /foo/)
32
+ )
33
+ end
34
+
35
+ end # describe Faceter::Coercers.wrap
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".add_prefix" do
4
+
5
+ it_behaves_like :transforming_immutable_data do
6
+ let(:arguments) { [:add_prefix, "foo", "."] }
7
+
8
+ let(:input) { "bar" }
9
+ let(:output) { "foo.bar" }
10
+ end
11
+
12
+ end # describe Faceter::Functions.add_prefix
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".claster" do
4
+
5
+ it_behaves_like :transforming_immutable_data do
6
+ let(:arguments) { [:claster, -> v { v.class }] }
7
+
8
+ let(:input) { [:foo, :bar, "foo", :bar, :baz] }
9
+ let(:output) { [[:foo, :bar], ["foo"], [:bar, :baz]] }
10
+ end
11
+
12
+ end # describe Faceter::Functions.claster
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".clean" do
4
+
5
+ let(:arguments) { [:clean, Selector.new(options)] }
6
+ let(:input) { { foo: { foo: :FOO }, bar: {}, baz: {}, qux: :QUX } }
7
+
8
+ it_behaves_like :transforming_immutable_data do
9
+ let(:options) { {} }
10
+ let(:output) { { foo: { foo: :FOO }, qux: :QUX } }
11
+ end
12
+
13
+ it_behaves_like :transforming_immutable_data do
14
+ let(:options) { { only: [:foo, :bar] } }
15
+ let(:output) { { foo: { foo: :FOO }, baz: {}, qux: :QUX } }
16
+ end
17
+
18
+ end # describe Faceter::Functions.clean
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".drop_prefix" do
4
+
5
+ it_behaves_like :transforming_immutable_data do
6
+ let(:arguments) { [:drop_prefix, "foo", "."] }
7
+
8
+ let(:input) { "foo.bar" }
9
+ let(:output) { "bar" }
10
+ end
11
+
12
+ it_behaves_like :transforming_immutable_data do
13
+ let(:arguments) { [:drop_prefix, "foo", "."] }
14
+
15
+ let(:input) { "foo." }
16
+ let(:output) { "" }
17
+ end
18
+
19
+ it_behaves_like :transforming_immutable_data do
20
+ let(:arguments) { [:drop_prefix, "foo", "."] }
21
+
22
+ let(:input) { "baz_bar" }
23
+ let(:output) { "baz_bar" }
24
+ end
25
+
26
+ it_behaves_like :transforming_immutable_data do
27
+ let(:arguments) { [:drop_prefix, "foo", "."] }
28
+
29
+ let(:input) { :foo_bar }
30
+ let(:output) { "foo_bar" }
31
+ end
32
+
33
+ end # describe Faceter::Functions.drop_prefix
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".exclude" do
4
+
5
+ let(:arguments) { [:exclude, Selector.new(options)] }
6
+ let(:input) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
7
+
8
+ it_behaves_like :transforming_immutable_data do
9
+ let(:options) { {} }
10
+ let(:output) { {} }
11
+ end
12
+
13
+ # :only
14
+
15
+ it_behaves_like :transforming_immutable_data do
16
+ let(:options) { { only: [] } }
17
+ let(:output) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
18
+ end
19
+
20
+ it_behaves_like :transforming_immutable_data do
21
+ let(:options) { { only: :qux } }
22
+ let(:output) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
23
+ end
24
+
25
+ it_behaves_like :transforming_immutable_data do
26
+ let(:options) { { only: :foo } }
27
+ let(:output) { { bar: :BAR, baz: :BAZ } }
28
+ end
29
+
30
+ it_behaves_like :transforming_immutable_data do
31
+ let(:options) { { only: [:foo, :bar, :qux] } }
32
+ let(:output) { { baz: :BAZ } }
33
+ end
34
+
35
+ # :except
36
+
37
+ it_behaves_like :transforming_immutable_data do
38
+ let(:options) { { except: [] } }
39
+ let(:output) { {} }
40
+ end
41
+
42
+ it_behaves_like :transforming_immutable_data do
43
+ let(:options) { { except: :qux } }
44
+ let(:output) { {} }
45
+ end
46
+
47
+ it_behaves_like :transforming_immutable_data do
48
+ let(:options) { { except: :foo } }
49
+ let(:output) { { foo: :FOO } }
50
+ end
51
+
52
+ it_behaves_like :transforming_immutable_data do
53
+ let(:options) { { except: [:foo, :bar, :qux] } }
54
+ let(:output) { { foo: :FOO, bar: :BAR } }
55
+ end
56
+
57
+ # :except and :only
58
+
59
+ it_behaves_like :transforming_immutable_data do
60
+ let(:options) { { except: /z/, only: /b/ } }
61
+ let(:output) { { foo: :FOO, baz: :BAZ } }
62
+ end
63
+
64
+ end # describe Faceter::Functions.exclude
@@ -0,0 +1,176 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".group" do
4
+
5
+ it_behaves_like :transforming_immutable_data do
6
+ let(:selector) { Selector.new(only: [:foo, :bar]) }
7
+ let(:arguments) { [:group, :baz, selector] }
8
+
9
+ let(:input) do
10
+ [{ foo: :FOO, bar: :FOO, qux: :QUX }, { foo: :BAR, bar: :BAR, qux: :QUX }]
11
+ end
12
+
13
+ let(:output) do
14
+ [
15
+ { qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }
16
+ ]
17
+ end
18
+ end
19
+
20
+ it_behaves_like :transforming_immutable_data do
21
+ let(:selector) { Selector.new(except: :qux) }
22
+ let(:arguments) { [:group, :baz, selector] }
23
+
24
+ let(:input) do
25
+ [{ foo: :FOO, bar: :FOO, qux: :QUX }, { foo: :BAR, bar: :BAR, qux: :QUX }]
26
+ end
27
+
28
+ let(:output) do
29
+ [
30
+ { qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }
31
+ ]
32
+ end
33
+ end
34
+
35
+ it_behaves_like :transforming_immutable_data do
36
+ let(:selector) { Selector.new(only: [:foo, :bar]) }
37
+ let(:arguments) { [:group, :baz, selector] }
38
+
39
+ let(:input) do
40
+ [
41
+ { foo: :FOO, bar: :FOO, baz: :BAZ, qux: :QUX },
42
+ { foo: :BAR, bar: :BAR, baz: :BAZ, qux: :QUX }
43
+ ]
44
+ end
45
+
46
+ let(:output) do
47
+ [
48
+ { qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }
49
+ ]
50
+ end
51
+ end
52
+
53
+ it_behaves_like :transforming_immutable_data do
54
+ let(:selector) { Selector.new(only: [:foo, :bar]) }
55
+ let(:arguments) { [:group, :baz, selector] }
56
+
57
+ let(:input) do
58
+ [
59
+ { foo: :FOO, bar: :FOO, baz: { bar: :BAZ }, qux: :QUX },
60
+ { foo: :BAR, bar: :BAR, baz: { bar: :BAZ }, qux: :QUX }
61
+ ]
62
+ end
63
+
64
+ let(:output) do
65
+ [
66
+ { qux: :QUX, baz: [{ foo: :FOO, bar: :FOO }, { foo: :BAR, bar: :BAR }] }
67
+ ]
68
+ end
69
+ end
70
+
71
+ it_behaves_like :transforming_immutable_data do
72
+ let(:selector) { Selector.new(only: [:foo, :bar]) }
73
+ let(:arguments) { [:group, :baz, selector] }
74
+
75
+ let(:input) do
76
+ [
77
+ { foo: :FOO, bar: :FOO, baz: [{ baz: :BAZ }], qux: :QUX },
78
+ { foo: :BAR, bar: :BAR, baz: [{ baz: :BAZZ }], qux: :QUX }
79
+ ]
80
+ end
81
+
82
+ let(:output) do
83
+ [
84
+ {
85
+ qux: :QUX,
86
+ baz: [
87
+ { foo: :FOO, bar: :FOO, baz: :BAZ },
88
+ { foo: :BAR, bar: :BAR, baz: :BAZZ }
89
+ ]
90
+ }
91
+ ]
92
+ end
93
+ end
94
+
95
+ it_behaves_like :transforming_immutable_data do
96
+ let(:selector) { Selector.new(only: :foo) }
97
+ let(:arguments) { [:group, :bar, selector] }
98
+
99
+ let(:input) do
100
+ [
101
+ { foo: :FOO, bar: [{ baz: :FOO }, { baz: :BAR }], qux: :QUX },
102
+ { foo: :BAR, bar: [{ baz: :BAZ }, { baz: :QUX }], qux: :QUX }
103
+ ]
104
+ end
105
+
106
+ let(:output) do
107
+ [
108
+ {
109
+ qux: :QUX,
110
+ bar: [
111
+ { baz: :FOO, foo: :FOO },
112
+ { baz: :BAR, foo: :FOO },
113
+ { baz: :BAZ, foo: :BAR },
114
+ { baz: :QUX, foo: :BAR }
115
+ ]
116
+ }
117
+ ]
118
+ end
119
+ end
120
+
121
+ it_behaves_like :transforming_immutable_data do
122
+ let(:selector) { Selector.new(only: [:foo, :baz]) }
123
+ let(:arguments) { [:group, :foo, selector] }
124
+
125
+ let(:input) do
126
+ [
127
+ { foo: :FOO, baz: :FOO, qux: :QUX },
128
+ { foo: :BAR, baz: :BAR, qux: :QUX }
129
+ ]
130
+ end
131
+
132
+ let(:output) do
133
+ [
134
+ { qux: :QUX, foo: [{ foo: :FOO, baz: :FOO }, { foo: :BAR, baz: :BAR }] }
135
+ ]
136
+ end
137
+ end
138
+
139
+ it_behaves_like :transforming_immutable_data do
140
+ let(:selector) { Selector.new(only: :foo) }
141
+ let(:arguments) { [:group, :foo, selector] }
142
+
143
+ let(:input) do
144
+ [
145
+ { foo: [{ bar: :FOO }, { baz: :FOO }], qux: :QUX },
146
+ { foo: [{ bar: :BAR }, { baz: :BAR }], qux: :QUX }
147
+ ]
148
+ end
149
+
150
+ let(:output) do
151
+ [
152
+ {
153
+ qux: :QUX,
154
+ foo: [
155
+ { foo: [{ bar: :FOO }, { baz: :FOO }] },
156
+ { foo: [{ bar: :BAR }, { baz: :BAR }] }
157
+ ]
158
+ }
159
+ ]
160
+ end
161
+ end
162
+
163
+ it_behaves_like :transforming_immutable_data do
164
+ let(:selector) { Selector.new(only: :quxx) }
165
+ let(:arguments) { [:group, :baz, selector] }
166
+
167
+ let(:input) do
168
+ [{ foo: :FOO, bar: :FOO, qux: :QUX }, { foo: :BAR, bar: :BAR, qux: :QUX }]
169
+ end
170
+
171
+ let(:output) do
172
+ [{ foo: :FOO, bar: :FOO, qux: :QUX }, { foo: :BAR, bar: :BAR, qux: :QUX }]
173
+ end
174
+ end
175
+
176
+ end # describe Faceter::Functions.group
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".keep_symbol" do
4
+
5
+ let(:function) { -> value { value.to_s.reverse.to_i } }
6
+
7
+ it_behaves_like :transforming_immutable_data do
8
+ let(:arguments) { [:keep_symbol, function] }
9
+
10
+ let(:input) { 123 }
11
+ let(:output) { 321 }
12
+ end
13
+
14
+ it_behaves_like :transforming_immutable_data do
15
+ let(:arguments) { [:keep_symbol, function] }
16
+
17
+ let(:input) { :"123" }
18
+ let(:output) { :"321" }
19
+ end
20
+
21
+ end # describe Faceter::Functions.keep_symbol
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ describe Faceter::Functions, ".split" do
4
+
5
+ let(:arguments) { [:split, Selector.new(options)] }
6
+ let(:input) { { foo: :FOO, bar: :BAR, baz: :BAZ } }
7
+
8
+ it_behaves_like :transforming_immutable_data do
9
+ let(:options) { {} }
10
+ let(:output) { [{ foo: :FOO, bar: :BAR, baz: :BAZ }, {}] }
11
+ end
12
+
13
+ # :only
14
+
15
+ it_behaves_like :transforming_immutable_data do
16
+ let(:options) { { only: [] } }
17
+ let(:output) { [{}, { foo: :FOO, bar: :BAR, baz: :BAZ }] }
18
+ end
19
+
20
+ it_behaves_like :transforming_immutable_data do
21
+ let(:options) { { only: :qux } }
22
+ let(:output) { [{}, { foo: :FOO, bar: :BAR, baz: :BAZ }] }
23
+ end
24
+
25
+ it_behaves_like :transforming_immutable_data do
26
+ let(:options) { { only: :foo } }
27
+ let(:output) { [{ foo: :FOO }, { bar: :BAR, baz: :BAZ }] }
28
+ end
29
+
30
+ it_behaves_like :transforming_immutable_data do
31
+ let(:options) { { only: [:foo, :bar, :qux] } }
32
+ let(:output) { [{ foo: :FOO, bar: :BAR }, { baz: :BAZ }] }
33
+ end
34
+
35
+ # :except
36
+
37
+ it_behaves_like :transforming_immutable_data do
38
+ let(:options) { { except: [] } }
39
+ let(:output) { [{ foo: :FOO, bar: :BAR, baz: :BAZ }, {}] }
40
+ end
41
+
42
+ it_behaves_like :transforming_immutable_data do
43
+ let(:options) { { except: :qux } }
44
+ let(:output) { [{ foo: :FOO, bar: :BAR, baz: :BAZ }, {}] }
45
+ end
46
+
47
+ it_behaves_like :transforming_immutable_data do
48
+ let(:options) { { except: :foo } }
49
+ let(:output) { [{ bar: :BAR, baz: :BAZ }, { foo: :FOO }] }
50
+ end
51
+
52
+ it_behaves_like :transforming_immutable_data do
53
+ let(:options) { { except: [:foo, :bar, :qux] } }
54
+ let(:output) { [{ baz: :BAZ }, { foo: :FOO, bar: :BAR }] }
55
+ end
56
+
57
+ # :except and :only
58
+
59
+ it_behaves_like :transforming_immutable_data do
60
+ let(:options) { { except: /z/, only: /b/ } }
61
+ let(:output) { [{ bar: :BAR }, { foo: :FOO, baz: :BAZ }] }
62
+ end
63
+
64
+ end # describe Faceter::Functions.split