gitara 1.0.1 → 1.2.0
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.markdown +6 -0
- data/README.markdown +1 -1
- data/examples/aimee-man-wise-up.ly +1 -1
- data/gitara.gemspec +3 -4
- data/lib/gitara/app.rb +3 -3
- data/lib/gitara/node/base.rb +1 -4
- data/lib/gitara/template/tab.erb +1 -1
- data/lib/gitara/utilities.rb +7 -4
- data/lib/gitara/version.rb +1 -1
- data/lib/gitara.rb +2 -2
- data/spec/factories.rb +7 -7
- data/spec/lib/gitara/app_spec.rb +4 -4
- data/spec/lib/gitara/dsl_spec.rb +112 -112
- data/spec/lib/gitara/node/alternative_spec.rb +4 -4
- data/spec/lib/gitara/node/bar/chorded_version_spec.rb +6 -6
- data/spec/lib/gitara/node/bar/stanza_version_spec.rb +5 -5
- data/spec/lib/gitara/node/bar/voiced_version_spec.rb +5 -5
- data/spec/lib/gitara/node/bar_spec.rb +20 -20
- data/spec/lib/gitara/node/base/node_version_spec.rb +19 -19
- data/spec/lib/gitara/node/base/voiced_version_spec.rb +9 -9
- data/spec/lib/gitara/node/base_spec.rb +113 -106
- data/spec/lib/gitara/node/chord_set/chorded_version_spec.rb +2 -2
- data/spec/lib/gitara/node/line_spec.rb +2 -2
- data/spec/lib/gitara/node/repeat_spec.rb +3 -3
- data/spec/lib/gitara/node/stanza_spec.rb +14 -14
- data/spec/lib/gitara/node/tab_spec.rb +25 -25
- data/spec/lib/gitara/time_signature_spec.rb +6 -6
- data/spec/lib/gitara/voice_spec.rb +33 -33
- data/spec/lib/gitara_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -4
- data/spec/support/app_tester.rb +5 -5
- metadata +68 -118
data/spec/lib/gitara/dsl_spec.rb
CHANGED
@@ -3,324 +3,324 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Dsl do
|
4
4
|
describe "#bar" do
|
5
5
|
it "should add a bar with the name" do
|
6
|
-
dsl =
|
7
|
-
dsl.node.children.
|
6
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
7
|
+
expect(dsl.node.children).to be_empty
|
8
8
|
|
9
9
|
dsl.bar 'Intro'
|
10
10
|
|
11
|
-
dsl.node.children.
|
11
|
+
expect(dsl.node.children.size).to eq(1)
|
12
12
|
|
13
13
|
bar = dsl.node.children[0]
|
14
|
-
bar.name.
|
15
|
-
bar.children.
|
14
|
+
expect(bar.name).to eq('Intro')
|
15
|
+
expect(bar.children).to be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should add the definition_children declared in the block to the bar" do
|
19
|
-
dsl =
|
20
|
-
dsl.node.children.
|
19
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
20
|
+
expect(dsl.node.children).to be_empty
|
21
21
|
|
22
|
-
note_set =
|
22
|
+
note_set = FactoryBot.build(:note_set)
|
23
23
|
|
24
24
|
dsl.bar 'Intro' do
|
25
25
|
add note_set
|
26
26
|
end
|
27
27
|
|
28
|
-
dsl.node.children.
|
29
|
-
dsl.node.children[0].name.
|
28
|
+
expect(dsl.node.children.size).to eq(1)
|
29
|
+
expect(dsl.node.children[0].name).to eq('Intro')
|
30
30
|
|
31
31
|
bar = dsl.node.children[0]
|
32
|
-
bar.children.
|
33
|
-
bar.children[0].
|
32
|
+
expect(bar.children.size).to eq(1)
|
33
|
+
expect(bar.children[0]).to eq(note_set)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#add" do
|
38
38
|
it "should add the child to the dsl's node" do
|
39
|
-
dsl =
|
40
|
-
dsl.node.children.
|
39
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
40
|
+
expect(dsl.node.children).to be_empty
|
41
41
|
|
42
|
-
bar =
|
42
|
+
bar = FactoryBot.build(:bar, :name => 'Intro')
|
43
43
|
|
44
44
|
dsl.add bar
|
45
45
|
|
46
|
-
dsl.node.children.
|
47
|
-
dsl.node.children[0].
|
46
|
+
expect(dsl.node.children.size).to eq(1)
|
47
|
+
expect(dsl.node.children[0]).to eq(bar)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should add the definition_children in the block to the child" do
|
51
|
-
dsl =
|
52
|
-
dsl.node.children.
|
51
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
52
|
+
expect(dsl.node.children).to be_empty
|
53
53
|
|
54
|
-
bar =
|
55
|
-
note_set =
|
54
|
+
bar = FactoryBot.build(:bar, :children => [])
|
55
|
+
note_set = FactoryBot.build(:note_set)
|
56
56
|
|
57
57
|
dsl.add bar do
|
58
58
|
add note_set
|
59
59
|
end
|
60
60
|
|
61
|
-
dsl.node.children.
|
62
|
-
dsl.node.children[0].
|
61
|
+
expect(dsl.node.children.size).to eq(1)
|
62
|
+
expect(dsl.node.children[0]).to eq(bar)
|
63
63
|
|
64
|
-
bar.children.
|
65
|
-
bar.children[0].
|
64
|
+
expect(bar.children.size).to eq(1)
|
65
|
+
expect(bar.children[0]).to eq(note_set)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "#notes" do
|
70
70
|
it "should add a note set with the value" do
|
71
|
-
dsl =
|
72
|
-
dsl.node.children.
|
71
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:bar, :children => []))
|
72
|
+
expect(dsl.node.children).to be_empty
|
73
73
|
|
74
74
|
dsl.notes 'test'
|
75
75
|
|
76
|
-
dsl.node.children.
|
77
|
-
dsl.node.children[0].value.
|
76
|
+
expect(dsl.node.children.size).to eq(1)
|
77
|
+
expect(dsl.node.children[0].value).to eq('test')
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "#line" do
|
82
82
|
it "should add a line with the name" do
|
83
|
-
dsl =
|
84
|
-
dsl.node.children.
|
83
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
84
|
+
expect(dsl.node.children).to be_empty
|
85
85
|
|
86
86
|
dsl.line 'Intro'
|
87
87
|
|
88
|
-
dsl.node.children.
|
88
|
+
expect(dsl.node.children.size).to eq(1)
|
89
89
|
|
90
90
|
line = dsl.node.children[0]
|
91
|
-
line.name.
|
92
|
-
line.children.
|
91
|
+
expect(line.name).to eq('Intro')
|
92
|
+
expect(line.children).to be_empty
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should add the definition_children declared in the block to the line" do
|
96
|
-
dsl =
|
97
|
-
dsl.node.children.
|
96
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
97
|
+
expect(dsl.node.children).to be_empty
|
98
98
|
|
99
|
-
bar =
|
99
|
+
bar = FactoryBot.build(:bar)
|
100
100
|
|
101
101
|
dsl.line 'Intro' do
|
102
102
|
add bar
|
103
103
|
end
|
104
104
|
|
105
|
-
dsl.node.children.
|
106
|
-
dsl.node.children[0].name.
|
105
|
+
expect(dsl.node.children.size).to eq(1)
|
106
|
+
expect(dsl.node.children[0].name).to eq('Intro')
|
107
107
|
|
108
108
|
line = dsl.node.children[0]
|
109
|
-
line.children.
|
110
|
-
line.children[0].
|
109
|
+
expect(line.children.size).to eq(1)
|
110
|
+
expect(line.children[0]).to eq(bar)
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should allow breaking to be toggled" do
|
114
|
-
dsl =
|
114
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
115
115
|
dsl.line :manual_break => false
|
116
116
|
|
117
|
-
dsl.node.children.
|
118
|
-
dsl.node.children[0].name.
|
119
|
-
dsl.node.children[0].manual_break
|
117
|
+
expect(dsl.node.children.size).to eq(1)
|
118
|
+
expect(dsl.node.children[0].name).to eq('TabOneLineOne') # not manual_breaking=false
|
119
|
+
expect(dsl.node.children[0].manual_break?).to be_falsy
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
describe "#add_names" do
|
124
124
|
it "should add a node with o[:name] of o[:node_class] to the node" do
|
125
|
-
dsl =
|
126
|
-
dsl.node.children.
|
125
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
126
|
+
expect(dsl.node.children).to be_empty
|
127
127
|
|
128
128
|
dsl.add_names :names => [:Intro, :Intro], :node_class => Node::Bar
|
129
129
|
|
130
|
-
dsl.node.children.
|
130
|
+
expect(dsl.node.children.size).to eq(2)
|
131
131
|
dsl.node.children.each do |child|
|
132
|
-
child.
|
133
|
-
child.name.
|
132
|
+
expect(child).to be_a(Node::Bar)
|
133
|
+
expect(child.name).to eq(:Intro)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should add a node with nil name if the o[:names] is blank" do
|
138
|
-
dsl =
|
139
|
-
dsl.node.children.
|
138
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
139
|
+
expect(dsl.node.children).to be_empty
|
140
140
|
|
141
141
|
dsl.add_names :names => [], :node_class => Node::Bar
|
142
142
|
|
143
|
-
dsl.node.children.
|
144
|
-
dsl.node.children[0].attributes[:name].
|
145
|
-
dsl.node.children[0].
|
143
|
+
expect(dsl.node.children.size).to eq(1)
|
144
|
+
expect(dsl.node.children[0].attributes[:name]).to be_nil
|
145
|
+
expect(dsl.node.children[0]).to be_a(Node::Bar)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should set o[:options] as attributes of the nodes" do
|
149
|
-
dsl =
|
150
|
-
dsl.node.children.
|
149
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
150
|
+
expect(dsl.node.children).to be_empty
|
151
151
|
|
152
152
|
dsl.add_names :names => [:Intro, :Intro], :options => {:value => 1 }, :node_class => Node::Base
|
153
153
|
|
154
|
-
dsl.node.children.
|
154
|
+
expect(dsl.node.children.size).to eq(2)
|
155
155
|
dsl.node.children.each do |child|
|
156
|
-
child.name.
|
157
|
-
child.value.
|
156
|
+
expect(child.name).to eq(:Intro)
|
157
|
+
expect(child.value).to eq(1)
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
describe "#score" do
|
163
163
|
it "should add a score with the name" do
|
164
|
-
dsl =
|
165
|
-
dsl.node.children.
|
164
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
165
|
+
expect(dsl.node.children).to be_empty
|
166
166
|
|
167
167
|
dsl.score
|
168
168
|
|
169
|
-
dsl.node.children.
|
169
|
+
expect(dsl.node.children.size).to eq(1)
|
170
170
|
|
171
171
|
score = dsl.node.children[0]
|
172
|
-
score.
|
173
|
-
score.children.
|
172
|
+
expect(score).to be_a(Node::Score)
|
173
|
+
expect(score.children).to be_empty
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should add the definition_children declared in the block to the score" do
|
177
|
-
dsl =
|
178
|
-
dsl.node.children.
|
177
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
178
|
+
expect(dsl.node.children).to be_empty
|
179
179
|
|
180
|
-
note_set =
|
180
|
+
note_set = FactoryBot.build(:note_set)
|
181
181
|
|
182
182
|
dsl.score do
|
183
183
|
add note_set
|
184
184
|
end
|
185
185
|
|
186
|
-
dsl.node.children.
|
186
|
+
expect(dsl.node.children.size).to eq(1)
|
187
187
|
|
188
188
|
score = dsl.node.children[0]
|
189
|
-
score.children.
|
190
|
-
score.children[0].
|
189
|
+
expect(score.children.size).to eq(1)
|
190
|
+
expect(score.children[0]).to eq(note_set)
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
194
|
describe "#stanza" do
|
195
195
|
it "should add a stanza with the name" do
|
196
|
-
dsl =
|
197
|
-
dsl.node.children.
|
196
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
197
|
+
expect(dsl.node.children).to be_empty
|
198
198
|
|
199
199
|
dsl.stanza 'Intro'
|
200
200
|
|
201
|
-
dsl.node.children.
|
201
|
+
expect(dsl.node.children.size).to eq(1)
|
202
202
|
|
203
203
|
stanza = dsl.node.children[0]
|
204
|
-
stanza.name.
|
205
|
-
stanza.children.
|
204
|
+
expect(stanza.name).to eq('Intro')
|
205
|
+
expect(stanza.children).to be_empty
|
206
206
|
end
|
207
207
|
|
208
208
|
it "should add the definition_children declared in the block to the stanza" do
|
209
|
-
dsl =
|
210
|
-
dsl.node.children.
|
209
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
210
|
+
expect(dsl.node.children).to be_empty
|
211
211
|
|
212
|
-
line =
|
212
|
+
line = FactoryBot.build(:line)
|
213
213
|
|
214
214
|
dsl.stanza 'Intro' do
|
215
215
|
add line
|
216
216
|
end
|
217
217
|
|
218
|
-
dsl.node.children.
|
219
|
-
dsl.node.children[0].name.
|
218
|
+
expect(dsl.node.children.size).to eq(1)
|
219
|
+
expect(dsl.node.children[0].name).to eq('Intro')
|
220
220
|
|
221
221
|
stanza = dsl.node.children[0]
|
222
|
-
stanza.children.
|
223
|
-
stanza.children[0].
|
222
|
+
expect(stanza.children.size).to eq(1)
|
223
|
+
expect(stanza.children[0]).to eq(line)
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
227
227
|
[:title, :composer, :arranger, :instrument, :key, :midi_instrument, :string_tunings, :tempo, :transposition].each do |property|
|
228
228
|
describe "##{property}" do
|
229
229
|
it "should set the #{property} of the tab to value" do
|
230
|
-
tab =
|
230
|
+
tab = FactoryBot.build(:tab)
|
231
231
|
|
232
|
-
dsl =
|
232
|
+
dsl = FactoryBot.build(:dsl, :node => tab)
|
233
233
|
dsl.send property, "test"
|
234
234
|
|
235
|
-
tab.send(property).
|
235
|
+
expect(tab.send(property)).to eq("test")
|
236
236
|
end
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
240
|
describe "#chords" do
|
241
241
|
it "should add a chord set with the name" do
|
242
|
-
dsl =
|
243
|
-
dsl.node.children.
|
242
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
243
|
+
expect(dsl.node.children).to be_empty
|
244
244
|
|
245
245
|
dsl.chords :Am, 'r4-"Am" r r r'
|
246
246
|
|
247
|
-
dsl.node.children.
|
247
|
+
expect(dsl.node.children.size).to eq(1)
|
248
248
|
|
249
249
|
chord_set = dsl.node.children[0]
|
250
|
-
chord_set.name.
|
251
|
-
chord_set.value.
|
250
|
+
expect(chord_set.name).to eq(:Am)
|
251
|
+
expect(chord_set.value).to eq('r4-"Am" r r r')
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
255
255
|
describe "#chords" do
|
256
256
|
it "should add a bar with the name" do
|
257
|
-
dsl =
|
258
|
-
dsl.node.children.
|
257
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
258
|
+
expect(dsl.node.children).to be_empty
|
259
259
|
|
260
260
|
dsl.chords :Am
|
261
261
|
|
262
|
-
dsl.node.children.
|
262
|
+
expect(dsl.node.children.size).to eq(1)
|
263
263
|
|
264
264
|
chord_set = dsl.node.children[0]
|
265
|
-
chord_set.name.
|
265
|
+
expect(chord_set.name).to eq(:Am)
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
269
|
describe "#partial" do
|
270
270
|
it "should set the specified duration of the bar node to duration" do
|
271
|
-
dsl =
|
272
|
-
dsl.node.specified_duration.
|
271
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:bar))
|
272
|
+
expect(dsl.node.specified_duration).to be_nil
|
273
273
|
|
274
274
|
dsl.partial 8
|
275
275
|
|
276
|
-
dsl.node.specified_duration.
|
276
|
+
expect(dsl.node.specified_duration).to eq(8)
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
280
|
describe "#repeat" do
|
281
281
|
it "should add a repeat with the value" do
|
282
|
-
dsl =
|
282
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
283
283
|
|
284
284
|
dsl.repeat 2
|
285
285
|
|
286
|
-
dsl.node.children.
|
286
|
+
expect(dsl.node.children.size).to eq(1)
|
287
287
|
|
288
288
|
repeat = dsl.node.children[0]
|
289
|
-
repeat.value.
|
290
|
-
repeat.children.
|
289
|
+
expect(repeat.value).to eq(2)
|
290
|
+
expect(repeat.children).to be_empty
|
291
291
|
end
|
292
292
|
|
293
293
|
it "should add the children declared in the block to the repeat" do
|
294
|
-
dsl =
|
294
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
295
295
|
|
296
|
-
bar =
|
296
|
+
bar = FactoryBot.build(:bar)
|
297
297
|
|
298
298
|
dsl.repeat 2 do
|
299
299
|
add bar
|
300
300
|
end
|
301
301
|
|
302
|
-
dsl.node.children.
|
302
|
+
expect(dsl.node.children.size).to eq(1)
|
303
303
|
|
304
304
|
repeat = dsl.node.children[0]
|
305
|
-
repeat.children.
|
306
|
-
repeat.children[0].
|
305
|
+
expect(repeat.children.size).to eq(1)
|
306
|
+
expect(repeat.children[0]).to eq(bar)
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
310
|
describe "#alternative" do
|
311
311
|
it "should add the children declared in the block to the alternative" do
|
312
|
-
dsl =
|
313
|
-
bar =
|
312
|
+
dsl = FactoryBot.build(:dsl, :node => FactoryBot.build(:tab, :children => []))
|
313
|
+
bar = FactoryBot.build(:bar)
|
314
314
|
|
315
315
|
dsl.alternative do
|
316
316
|
add bar
|
317
317
|
end
|
318
318
|
|
319
|
-
dsl.node.children.
|
319
|
+
expect(dsl.node.children.size).to eq(1)
|
320
320
|
|
321
321
|
alternative = dsl.node.children[0]
|
322
|
-
alternative.children.
|
323
|
-
alternative.children[0].
|
322
|
+
expect(alternative.children.size).to eq(1)
|
323
|
+
expect(alternative.children[0]).to eq(bar)
|
324
324
|
end
|
325
325
|
end
|
326
326
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Alternative do
|
4
4
|
describe "#call_value" do
|
5
5
|
it "should be a call to lilypond's alternative command" do
|
6
|
-
alternative =
|
7
|
-
|
8
|
-
|
6
|
+
alternative = FactoryBot.build(:alternative, :children => [
|
7
|
+
FactoryBot.build(:bar, :name => 'First'),
|
8
|
+
FactoryBot.build(:bar, :name => 'Second')
|
9
9
|
])
|
10
10
|
|
11
11
|
version = Node::Base::NodeVersion.new(:node => alternative)
|
12
|
-
alternative.call_value(version).
|
12
|
+
expect(alternative.call_value(version)).to eq("\\alternative { { \\nBarFirst } { \\nBarSecond } }")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,17 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Bar::ChordedVersion do
|
4
4
|
describe "#value" do
|
5
5
|
it "should be the call names of the chord sets in the bar, if available" do
|
6
|
-
bar =
|
6
|
+
bar = FactoryBot.build(:bar, :children => [FactoryBot.build(:chord_set, :name => :Am, :value => 'r-"Am"')])
|
7
7
|
|
8
|
-
chorded_bar =
|
9
|
-
chorded_bar.value.
|
8
|
+
chorded_bar = FactoryBot.build(:chorded_bar, :node => bar)
|
9
|
+
expect(chorded_bar.value).to eq('\cChordSetAm')
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should be blank, if the bar does not have any chord sets" do
|
13
|
-
bar =
|
13
|
+
bar = FactoryBot.build(:bar, :children => [FactoryBot.build(:note_set, :value => 'c')])
|
14
14
|
|
15
|
-
chorded_bar =
|
16
|
-
chorded_bar.value.
|
15
|
+
chorded_bar = FactoryBot.build(:chorded_bar, :node => bar)
|
16
|
+
expect(chorded_bar.value).to eq("")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -3,12 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Bar::StanzaVersion do
|
4
4
|
describe "#value" do
|
5
5
|
it "should be the stanza heading of the bar" do
|
6
|
-
bar =
|
7
|
-
stanza =
|
8
|
-
tab =
|
6
|
+
bar = FactoryBot.build(:bar)
|
7
|
+
stanza = FactoryBot.build(:stanza, :name => 'Intro', :children => [bar])
|
8
|
+
tab = FactoryBot.build(:tab, :children => [stanza], :time => '4/4')
|
9
9
|
|
10
|
-
stanza_version_of_bar =
|
11
|
-
stanza_version_of_bar.value.
|
10
|
+
stanza_version_of_bar = FactoryBot.build(:stanza_version_bar, :node => bar)
|
11
|
+
expect(stanza_version_of_bar.value).to eq('r1')
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -3,14 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Bar::VoicedVersion do
|
4
4
|
describe "#matching_note_set" do
|
5
5
|
it "should be the note_set matching this voiced bar" do
|
6
|
-
note_set =
|
6
|
+
note_set = FactoryBot.build(:note_set)
|
7
7
|
|
8
|
-
bar =
|
8
|
+
bar = FactoryBot.build(:bar, :children => [note_set])
|
9
9
|
|
10
|
-
voice =
|
10
|
+
voice = FactoryBot.build(:voice, :id => 1)
|
11
11
|
|
12
|
-
voiced_bar =
|
13
|
-
voiced_bar.matching_note_set.
|
12
|
+
voiced_bar = FactoryBot.build(:voiced_bar, :node => bar, :voice => voice)
|
13
|
+
expect(voiced_bar.matching_note_set).to eq(note_set)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -3,50 +3,50 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Bar do
|
4
4
|
describe "#note_sets" do
|
5
5
|
it "should be the note sets of its definition" do
|
6
|
-
definition_bar =
|
6
|
+
definition_bar = FactoryBot.build(:bar, :name => 'Intro').tap {|bar|
|
7
7
|
bar.children = [
|
8
|
-
|
9
|
-
|
8
|
+
FactoryBot.build(:note_set),
|
9
|
+
FactoryBot.build(:note_set)
|
10
10
|
]
|
11
11
|
}
|
12
12
|
|
13
|
-
call_bar =
|
13
|
+
call_bar = FactoryBot.build(:bar, :name => 'Intro', :children => [])
|
14
14
|
|
15
|
-
tab =
|
15
|
+
tab = FactoryBot.build(:tab, :children => [definition_bar, call_bar])
|
16
16
|
|
17
|
-
call_bar.note_sets.
|
17
|
+
expect(call_bar.note_sets.size).to eq(2)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#stanza_heading" do
|
22
22
|
it "should be a whole rest with no stanza name" do
|
23
|
-
first_bar =
|
24
|
-
second_bar =
|
25
|
-
stanza =
|
26
|
-
tab =
|
23
|
+
first_bar = FactoryBot.build(:bar)
|
24
|
+
second_bar = FactoryBot.build(:bar)
|
25
|
+
stanza = FactoryBot.build(:stanza, :name => 'Intro', :children => [first_bar, second_bar])
|
26
|
+
tab = FactoryBot.build(:tab, :children => [stanza], :time => '4/4')
|
27
27
|
|
28
|
-
second_bar.stanza_heading.
|
28
|
+
expect(second_bar.stanza_heading).to eq('r1')
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should be a partial with no stanza name if the bar has a special_duration" do
|
32
|
-
first_bar =
|
33
|
-
second_bar =
|
34
|
-
stanza =
|
35
|
-
tab =
|
32
|
+
first_bar = FactoryBot.build(:bar)
|
33
|
+
second_bar = FactoryBot.build(:bar, :specified_duration => 8)
|
34
|
+
stanza = FactoryBot.build(:stanza, :name => 'Intro', :children => [first_bar, second_bar])
|
35
|
+
tab = FactoryBot.build(:tab, :children => [stanza], :time => '4/4')
|
36
36
|
|
37
|
-
second_bar.stanza_heading.
|
37
|
+
expect(second_bar.stanza_heading).to eq('r8')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "#specified_duration_as_lilypond" do
|
42
42
|
it "should be \\partial specified_duration if present" do
|
43
|
-
bar =
|
44
|
-
bar.specified_duration_as_lilypond.
|
43
|
+
bar = FactoryBot.build(:bar, :specified_duration => 8)
|
44
|
+
expect(bar.specified_duration_as_lilypond).to eq('\partial 8')
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should be nil if there is no specified_duration" do
|
48
|
-
bar =
|
49
|
-
bar.specified_duration_as_lilypond.
|
48
|
+
bar = FactoryBot.build(:bar, :specified_duration => nil)
|
49
|
+
expect(bar.specified_duration_as_lilypond).to be_nil
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|