gitara 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.markdown +11 -0
- data/README.markdown +1 -1
- data/examples/aimee-man-wise-up.ly +1 -1
- data/gitara.gemspec +4 -5
- 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 -140
- data/examples/aimee-man-wise-up.midi +0 -0
- data/examples/aimee-man-wise-up.pdf +0 -0
- data/examples/eraserheads-huling-el-bimbo.midi +0 -0
- data/examples/eraserheads-huling-el-bimbo.pdf +0 -0
- data/examples/foo-fighters-walking-after-you.midi +0 -0
- data/examples/foo-fighters-walking-after-you.pdf +0 -0
- data/examples/tab-with-alternate-tuning.midi +0 -0
- data/examples/tab-with-alternate-tuning.pdf +0 -0
- data/examples/tab-with-chords.midi +0 -0
- data/examples/tab-with-chords.pdf +0 -0
- data/examples/tab-with-key-signature.midi +0 -0
- data/examples/tab-with-key-signature.pdf +0 -0
- data/examples/tab-with-line-with-no-break.midi +0 -0
- data/examples/tab-with-line-with-no-break.pdf +0 -0
- data/examples/tab-with-partial.midi +0 -0
- data/examples/tab-with-partial.pdf +0 -0
- data/examples/tab-with-repeats.midi +0 -0
- data/examples/tab-with-repeats.pdf +0 -0
- data/examples/tab-with-reused-bar-in-stanza.midi +0 -0
- data/examples/tab-with-reused-bar-in-stanza.pdf +0 -0
- data/examples/tab-with-time-signature.midi +0 -0
- data/examples/tab-with-time-signature.pdf +0 -0
@@ -4,62 +4,62 @@ describe Gitara::Node::Base::NodeVersion do
|
|
4
4
|
describe "#prefix" do
|
5
5
|
it "should be by default the first letter of the class" do
|
6
6
|
version = Node::Base::NodeVersion.new
|
7
|
-
version.prefix.
|
7
|
+
expect(version.prefix).to eq('n')
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#definition_name" do
|
12
12
|
it "should include the node's class and the node's name" do
|
13
|
-
version = Node::Base::NodeVersion.new(:node =>
|
14
|
-
version.definition_name.
|
13
|
+
version = Node::Base::NodeVersion.new(:node => FactoryBot.build(:base, :name => 'some node'))
|
14
|
+
expect(version.definition_name).to eq('nBaseSomeNode')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#call_name" do
|
19
19
|
it "should be the call version of the definition name" do
|
20
|
-
version = Node::Base::NodeVersion.new(:node =>
|
21
|
-
version.call_name.
|
20
|
+
version = Node::Base::NodeVersion.new(:node => FactoryBot.build(:base, :name => 'some node'))
|
21
|
+
expect(version.call_name).to eq('\nBaseSomeNode')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#value" do
|
26
26
|
it "should be the call values of its definition_children" do
|
27
|
-
node =
|
28
|
-
|
29
|
-
|
27
|
+
node = FactoryBot.build(:base, :children => [
|
28
|
+
FactoryBot.build(:base, :name => :First),
|
29
|
+
FactoryBot.build(:base, :name => :Second)
|
30
30
|
])
|
31
31
|
node_version = Node::Base::NodeVersion.new(:node => node)
|
32
|
-
node_version.value.
|
32
|
+
expect(node_version.value).to eq('\nBaseFirst \nBaseSecond')
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#definition_children" do
|
37
37
|
it "should be versionized versions of the node's definition_children" do
|
38
|
-
parent =
|
39
|
-
child =
|
38
|
+
parent = FactoryBot.build(:base, :name => 'parent')
|
39
|
+
child = FactoryBot.build(:base, :name => 'child')
|
40
40
|
parent.add child
|
41
41
|
|
42
42
|
node_version = Node::Base::NodeVersion.new(:node => parent)
|
43
43
|
|
44
44
|
children = node_version.definition_children
|
45
|
-
children.
|
46
|
-
children[0].node.
|
47
|
-
children[0].
|
45
|
+
expect(children.size).to eq(1)
|
46
|
+
expect(children[0].node).to eq(child)
|
47
|
+
expect(children[0]).to be_a(Node::Base::NodeVersion)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#call_value" do
|
52
52
|
it "should be the call name if we want to render the node's definition name in the lilypond output" do
|
53
|
-
node =
|
53
|
+
node = FactoryBot.build(:base, :name => 'parent')
|
54
54
|
node_version = Node::Base::NodeVersion.new(:node => node)
|
55
|
-
node_version.call_value.
|
55
|
+
expect(node_version.call_value).to eq('\nBaseParent')
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should be the call value of the node if we don't want to render the node's definition name in the lilypond output" do
|
59
|
-
node =
|
59
|
+
node = FactoryBot.build(:base, :name => 'name')
|
60
60
|
node_version = Node::Base::NodeVersion.new(:node => node)
|
61
|
-
node.
|
62
|
-
node_version.call_value.
|
61
|
+
expect(node).to receive(:call_value).with(node_version).and_return("todo { }")
|
62
|
+
expect(node_version.call_value).to eq("todo { }")
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -3,25 +3,25 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Base::VoicedVersion do
|
4
4
|
describe "#prefix" do
|
5
5
|
it "should be based on the voice's id" do
|
6
|
-
voiced_version =
|
7
|
-
voiced_version.prefix.
|
6
|
+
voiced_version = FactoryBot.build(:voiced_version, :node => FactoryBot.build(:base, :name => 'Intro'), :voice => FactoryBot.build(:voice, :id => 1))
|
7
|
+
expect(voiced_version.prefix).to eq('vOne')
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#definition_children" do
|
12
12
|
it "should be voiced versions of the node's definition_children" do
|
13
|
-
parent =
|
14
|
-
child =
|
13
|
+
parent = FactoryBot.build(:base, :name => 'parent')
|
14
|
+
child = FactoryBot.build(:base, :name => 'child')
|
15
15
|
parent.add child
|
16
16
|
|
17
|
-
voice =
|
17
|
+
voice = FactoryBot.build(:voice, :id => 1)
|
18
18
|
|
19
|
-
voiced_version =
|
19
|
+
voiced_version = FactoryBot.build(:voiced_version, :node => parent, :voice => voice)
|
20
20
|
|
21
21
|
children = voiced_version.definition_children
|
22
|
-
children.
|
23
|
-
children[0].node.
|
24
|
-
children[0].voice.
|
22
|
+
expect(children.size).to eq(1)
|
23
|
+
expect(children[0].node).to eq(child)
|
24
|
+
expect(children[0].voice).to eq(voice)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -3,278 +3,285 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Base do
|
4
4
|
describe "#definition_children" do
|
5
5
|
it "should be its own children if they exist" do
|
6
|
-
child =
|
6
|
+
child = FactoryBot.build(:base, :id => nil)
|
7
7
|
|
8
|
-
parent =
|
8
|
+
parent = FactoryBot.build(:base)
|
9
9
|
parent.children = [child]
|
10
|
-
parent.definition_children.
|
10
|
+
expect(parent.definition_children).to eq([child])
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should be the children of its definition if the node is not a definition" do
|
14
|
-
child =
|
15
|
-
definition_bar =
|
14
|
+
child = FactoryBot.build(:note_set)
|
15
|
+
definition_bar = FactoryBot.build(:bar, :name => 'Intro').tap {|bar|
|
16
16
|
bar.children = [child]
|
17
17
|
}
|
18
18
|
|
19
|
-
call_bar =
|
19
|
+
call_bar = FactoryBot.build(:bar, :name => 'Intro', :children => [])
|
20
20
|
|
21
|
-
tab =
|
21
|
+
tab = FactoryBot.build(:tab, :children => [definition_bar, call_bar])
|
22
22
|
|
23
|
-
call_bar.definition_children.
|
23
|
+
expect(call_bar.definition_children).to eq([child])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "#children=" do
|
28
28
|
it "should set the ids and parents of the children" do
|
29
|
-
parent =
|
30
|
-
parent.children = [
|
31
|
-
parent.children[0].id.
|
32
|
-
parent.children[0].parent.
|
29
|
+
parent = FactoryBot.build(:base)
|
30
|
+
parent.children = [FactoryBot.build(:base, :id => nil)]
|
31
|
+
expect(parent.children[0].id).to eq(1)
|
32
|
+
expect(parent.children[0].parent).to eq(parent)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#add" do
|
37
37
|
it "should set the id and parent of the child" do
|
38
|
-
parent =
|
38
|
+
parent = FactoryBot.build(:base)
|
39
39
|
|
40
|
-
parent.add
|
41
|
-
parent.children[0].id.
|
42
|
-
parent.children[0].parent.
|
40
|
+
parent.add FactoryBot.build(:base, :id => nil)
|
41
|
+
expect(parent.children[0].id).to eq(1)
|
42
|
+
expect(parent.children[0].parent).to eq(parent)
|
43
43
|
|
44
|
-
parent.add
|
45
|
-
parent.children[1].id.
|
46
|
-
parent.children[1].parent.
|
44
|
+
parent.add FactoryBot.build(:base, :id => nil)
|
45
|
+
expect(parent.children[1].id).to eq(2)
|
46
|
+
expect(parent.children[1].parent).to eq(parent)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should set the id based on existing siblings having the same class as the child" do
|
50
|
-
parent =
|
50
|
+
parent = FactoryBot.build(:base)
|
51
51
|
|
52
|
-
bar_1 =
|
52
|
+
bar_1 = FactoryBot.build(:bar)
|
53
53
|
parent.add bar_1
|
54
|
-
bar_1.id.
|
54
|
+
expect(bar_1.id).to eq(1)
|
55
55
|
|
56
|
-
line_1 =
|
56
|
+
line_1 = FactoryBot.build(:line)
|
57
57
|
parent.add line_1
|
58
|
-
line_1.id.
|
58
|
+
expect(line_1.id).to eq(1)
|
59
59
|
|
60
|
-
bar_2 =
|
60
|
+
bar_2 = FactoryBot.build(:bar)
|
61
61
|
parent.add bar_2
|
62
|
-
bar_2.id.
|
62
|
+
expect(bar_2.id).to eq(2)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "#definition" do
|
67
67
|
it "should be the definition node which matches this node's name" do
|
68
|
-
definition_bar =
|
68
|
+
definition_bar = FactoryBot.build(:bar, :name => 'Intro').tap {|bar|
|
69
69
|
bar.children = [
|
70
|
-
|
71
|
-
|
70
|
+
FactoryBot.build(:note_set),
|
71
|
+
FactoryBot.build(:note_set)
|
72
72
|
]
|
73
73
|
}
|
74
74
|
|
75
|
-
call_bar =
|
75
|
+
call_bar = FactoryBot.build(:bar, :name => 'Intro', :children => [])
|
76
76
|
|
77
|
-
tab =
|
77
|
+
tab = FactoryBot.build(:tab, :children => [definition_bar, call_bar])
|
78
78
|
|
79
|
-
call_bar.send(:definition).
|
79
|
+
expect(call_bar.send(:definition)).to eq(definition_bar)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
describe "#definition?" do
|
84
84
|
it "should be true if this node has children" do
|
85
|
-
definition_bar =
|
86
|
-
bar.add
|
87
|
-
bar.add
|
85
|
+
definition_bar = FactoryBot.build(:bar, :name => 'Intro').tap {|bar|
|
86
|
+
bar.add FactoryBot.build(:note_set)
|
87
|
+
bar.add FactoryBot.build(:note_set)
|
88
88
|
}
|
89
|
-
definition_bar.
|
89
|
+
expect(definition_bar).to be_definition
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should be true if the node has a value" do
|
93
|
-
chord_set =
|
94
|
-
chord_set.children.
|
95
|
-
chord_set.
|
93
|
+
chord_set = FactoryBot.build(:chord_set, :name => :Am, :value =>'r4-"Am" r r r')
|
94
|
+
expect(chord_set.children).to be_empty
|
95
|
+
expect(chord_set).to be_definition
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should be false if this node does not have children and it does not have a value" do
|
99
|
-
call_bar =
|
100
|
-
call_bar.children.
|
101
|
-
call_bar.value.
|
102
|
-
call_bar.
|
99
|
+
call_bar = FactoryBot.build(:bar, :name => 'Intro', :children => [])
|
100
|
+
expect(call_bar.children).to be_empty
|
101
|
+
expect(call_bar.value).to be_nil
|
102
|
+
expect(call_bar).to_not be_definition
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe "#value" do
|
107
107
|
it "should convert slashes to backslashes" do
|
108
|
-
node =
|
109
|
-
node.value.
|
108
|
+
node = FactoryBot.build(:base, :value => %q|notes "<g'/1>8 <a/3>8 <g'/1>8 <a/3>16 <g'/1>8 <g/3>16 <e'/1>4 <g/3>8"|)
|
109
|
+
expect(node.value).to eq(%q|notes "<g'\1>8 <a\3>8 <g'\1>8 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>8"|)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should work with non-strings" do
|
113
|
-
node =
|
114
|
-
node.value.
|
113
|
+
node = FactoryBot.build(:base, :value => 1)
|
114
|
+
expect(node.value).to eq(1)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "#voiced_as" do
|
119
119
|
it "should return the voiced version of the node, if arg is a voice" do
|
120
|
-
node =
|
121
|
-
voice =
|
120
|
+
node = FactoryBot.build(:base)
|
121
|
+
voice = FactoryBot.build(:voice)
|
122
122
|
|
123
123
|
node_voice_pair = node.voiced_as(voice)
|
124
|
-
node_voice_pair.
|
125
|
-
node_voice_pair.node.
|
126
|
-
node_voice_pair.voice.
|
124
|
+
expect(node_voice_pair).to be_a(Node::Base::VoicedVersion)
|
125
|
+
expect(node_voice_pair.node).to eq(node)
|
126
|
+
expect(node_voice_pair.voice).to eq(voice)
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should return the voiced versions of the node, if arg are voices" do
|
130
|
-
node =
|
131
|
-
voices = [
|
130
|
+
node = FactoryBot.build(:base)
|
131
|
+
voices = [FactoryBot.build(:voice), FactoryBot.build(:voice)]
|
132
132
|
|
133
133
|
node_voice_pairs = node.voiced_as(voices)
|
134
|
-
node_voice_pairs.size.
|
134
|
+
expect(node_voice_pairs.size).to eq(2)
|
135
135
|
|
136
136
|
node_voice_pairs.each do |pair|
|
137
|
-
pair.
|
138
|
-
pair.node.
|
137
|
+
expect(pair).to be_a(Node::Base::VoicedVersion)
|
138
|
+
expect(pair.node).to eq(node)
|
139
139
|
end
|
140
140
|
|
141
|
-
node_voice_pairs[0].voice.
|
142
|
-
node_voice_pairs[1].voice.
|
141
|
+
expect(node_voice_pairs[0].voice).to eq(voices[0])
|
142
|
+
expect(node_voice_pairs[1].voice).to eq(voices[1])
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
describe "#definitions" do
|
147
147
|
it "should be itself if it is an instance of the klass" do
|
148
|
-
node =
|
149
|
-
node.add
|
150
|
-
node.
|
148
|
+
node = FactoryBot.build(:bar)
|
149
|
+
node.add FactoryBot.build(:note_set)
|
150
|
+
expect(node).to be_definition
|
151
151
|
|
152
|
-
node.definitions(Node::Bar).
|
152
|
+
expect(node.definitions(Node::Bar)).to eq([node])
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should include descendants which are instances of klass" do
|
156
|
-
node =
|
157
|
-
|
158
|
-
|
156
|
+
node = FactoryBot.build(:base, :children => [
|
157
|
+
FactoryBot.build(:bar, :children => [FactoryBot.build(:note_set)]),
|
158
|
+
FactoryBot.build(:bar, :children => [FactoryBot.build(:note_set)])
|
159
159
|
])
|
160
160
|
|
161
|
-
node.definitions(Node::Bar).
|
161
|
+
expect(node.definitions(Node::Bar).size).to eq(2)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
165
|
describe "#name" do
|
166
166
|
it "should be the given name, if available" do
|
167
|
-
|
167
|
+
expect(FactoryBot.build(:bar, :name => :Intro).name).to eq(:Intro)
|
168
168
|
end
|
169
169
|
|
170
170
|
it "should be based on the parent's name the node's class and id, if not available" do
|
171
|
-
child =
|
172
|
-
bar =
|
171
|
+
child = FactoryBot.build(:note_set)
|
172
|
+
bar = FactoryBot.build(:bar, :name => :Intro, :children => [child])
|
173
173
|
|
174
|
-
child.name.
|
174
|
+
expect(child.name).to eq("IntroNoteSetOne")
|
175
175
|
end
|
176
176
|
|
177
177
|
it "should be based on the node's class and id, if there's no parent and the there's no given name" do
|
178
|
-
child =
|
179
|
-
child.name.
|
178
|
+
child = FactoryBot.build(:note_set)
|
179
|
+
expect(child.name).to eq("NoteSetOne")
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
183
|
describe "#id" do
|
184
184
|
it "should be 1 by default" do
|
185
|
-
child =
|
186
|
-
child.id.
|
185
|
+
child = FactoryBot.build(:note_set)
|
186
|
+
expect(child.id).to eq(1)
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
190
|
describe "#id_as_word" do
|
191
191
|
it "should camelize if necessary" do
|
192
|
-
node =
|
193
|
-
node.id_as_word.
|
192
|
+
node = FactoryBot.build(:base, :id => 24)
|
193
|
+
expect(node.id_as_word).to eq("TwentyFour")
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
197
|
describe "#definition_name" do
|
198
198
|
it "should turn the name to a lilypond acceptable name" do
|
199
|
-
node =
|
200
|
-
node.definition_name.
|
199
|
+
node = FactoryBot.build(:base, :name => "Verse 1 line-2")
|
200
|
+
expect(node.definition_name).to eq("VerseOneLineTwo")
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'when a word of the name is already camelized' do
|
204
|
+
it 'should retain the camelization' do
|
205
|
+
node = FactoryBot.build(:base, :name => "Verse 1LineOne")
|
206
|
+
expect(node.definition_name).to eq("VerseOneLineOne")
|
207
|
+
end
|
201
208
|
end
|
202
209
|
end
|
203
210
|
|
204
211
|
describe "#descendants" do
|
205
212
|
it "should be itself if it is an instance of the klass" do
|
206
|
-
tab =
|
207
|
-
tab.descendants(Node::Tab).
|
213
|
+
tab = FactoryBot.build(:tab, :children => [FactoryBot.build(:bar)])
|
214
|
+
expect(tab.descendants(Node::Tab)).to eq([tab])
|
208
215
|
end
|
209
216
|
|
210
217
|
it "should include descendants which are instances of klass" do
|
211
|
-
tab =
|
212
|
-
|
213
|
-
|
218
|
+
tab = FactoryBot.build(:tab, :children => [
|
219
|
+
FactoryBot.build(:bar, :name => :Intro, :children => [
|
220
|
+
FactoryBot.build(:note_set)
|
214
221
|
])
|
215
222
|
])
|
216
223
|
|
217
|
-
tab.descendants(Node::Bar).
|
224
|
+
expect(tab.descendants(Node::Bar).size).to eq(1)
|
218
225
|
end
|
219
226
|
|
220
227
|
it "should follow the definitions of node references for descendants" do
|
221
|
-
tab =
|
222
|
-
|
228
|
+
tab = FactoryBot.build(:tab, :children => [
|
229
|
+
FactoryBot.build(:bar, :name => :Intro, :children => [FactoryBot.build(:note_set)]),
|
223
230
|
|
224
|
-
|
225
|
-
|
231
|
+
FactoryBot.build(:line, :name => 'Line 1', :children => [
|
232
|
+
FactoryBot.build(:bar, :name => :Intro , :children => [])
|
226
233
|
]),
|
227
234
|
|
228
|
-
|
229
|
-
|
235
|
+
FactoryBot.build(:stanza, :children => [
|
236
|
+
FactoryBot.build(:line, :name => 'Line 1', :children => [])
|
230
237
|
])
|
231
238
|
])
|
232
239
|
|
233
240
|
bar = tab.children[0]
|
234
241
|
|
235
242
|
stanza = tab.children[2]
|
236
|
-
stanza.descendants(Node::Bar).
|
243
|
+
expect(stanza.descendants(Node::Bar)).to eq([bar])
|
237
244
|
end
|
238
245
|
end
|
239
246
|
|
240
247
|
describe "#chorded" do
|
241
248
|
it "should return the chorded version of the node" do
|
242
|
-
node =
|
249
|
+
node = FactoryBot.build(:base)
|
243
250
|
chorded_version = node.chorded
|
244
|
-
chorded_version.node.
|
245
|
-
chorded_version.
|
251
|
+
expect(chorded_version.node).to eq(node)
|
252
|
+
expect(chorded_version).to be_a(Node::Base::ChordedVersion)
|
246
253
|
end
|
247
254
|
end
|
248
255
|
|
249
256
|
describe "#stanza_version" do
|
250
257
|
it "should be a stanza version of the node" do
|
251
|
-
node =
|
258
|
+
node = FactoryBot.build(:base)
|
252
259
|
stanza_version = node.stanza_version
|
253
|
-
stanza_version.node.
|
254
|
-
stanza_version.
|
260
|
+
expect(stanza_version.node).to eq(node)
|
261
|
+
expect(stanza_version).to be_a(Node::Base::StanzaVersion)
|
255
262
|
end
|
256
263
|
end
|
257
264
|
|
258
265
|
describe "#ancestor" do
|
259
266
|
it "should be the first ancestor of the node matching the node class" do
|
260
|
-
bar =
|
261
|
-
line =
|
262
|
-
stanza =
|
267
|
+
bar = FactoryBot.build(:bar)
|
268
|
+
line = FactoryBot.build(:line, :name => 'Intro', :children => [bar])
|
269
|
+
stanza = FactoryBot.build(:stanza, :name => 'Intro', :children => [line])
|
263
270
|
|
264
|
-
bar.ancestor(Node::Stanza).
|
271
|
+
expect(bar.ancestor(Node::Stanza)).to eq(stanza)
|
265
272
|
end
|
266
273
|
|
267
274
|
it "should be nil if there is no ancestor matching the node class" do
|
268
|
-
bar =
|
269
|
-
bar.ancestor(Node::Stanza).
|
275
|
+
bar = FactoryBot.build(:bar)
|
276
|
+
expect(bar.ancestor(Node::Stanza)).to be_nil
|
270
277
|
end
|
271
278
|
end
|
272
279
|
|
273
280
|
describe "#call_value" do
|
274
281
|
it "should be the call name by default" do
|
275
|
-
node =
|
282
|
+
node = FactoryBot.build(:base, :name => 'MyNode')
|
276
283
|
node_version = Node::Base::NodeVersion.new(:node => node)
|
277
|
-
node.call_value(node_version).
|
284
|
+
expect(node.call_value(node_version)).to eq('\nBaseMyNode')
|
278
285
|
end
|
279
286
|
end
|
280
287
|
end
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::ChordSet::ChordedVersion do
|
4
4
|
describe "#value" do
|
5
5
|
it "should be the chord set's value" do
|
6
|
-
chorded_version =
|
7
|
-
chorded_version.value.
|
6
|
+
chorded_version = FactoryBot.build(:chorded_chord_set, :node => FactoryBot.build(:chord_set, :name => :Am, :value => '4r-"Am" r r r'))
|
7
|
+
expect(chorded_version.value).to eq('4r-"Am" r r r')
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Line do
|
4
4
|
describe "#manual_break?" do
|
5
5
|
it "should be true by default" do
|
6
|
-
described_class.new.manual_break
|
6
|
+
expect(described_class.new.manual_break?).to be_truthy
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should be based on #manual_break field" do
|
10
10
|
line = described_class.new
|
11
11
|
line.manual_break = false
|
12
|
-
line.manual_break
|
12
|
+
expect(line.manual_break?).to be_falsy
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -3,12 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Repeat do
|
4
4
|
describe "#call_value" do
|
5
5
|
it "should be a call to lilypond's repeat command" do
|
6
|
-
repeat =
|
7
|
-
|
6
|
+
repeat = FactoryBot.build(:repeat, :value => 2, :children => [
|
7
|
+
FactoryBot.build(:bar)
|
8
8
|
])
|
9
9
|
|
10
10
|
version = Node::Base::NodeVersion.new(:node => repeat)
|
11
|
-
repeat.call_value(version).
|
11
|
+
expect(repeat.call_value(version)).to eq("\\repeat volta 2 { \\nBarRepeatOneBarOne }")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -3,34 +3,34 @@ require 'spec_helper'
|
|
3
3
|
describe Gitara::Node::Stanza do
|
4
4
|
describe "#heading_in_lilypond" do
|
5
5
|
it "should allow the stanza's name to be added as a heading to the lilypond template" do
|
6
|
-
stanza =
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
stanza = FactoryBot.build(:stanza, :name => "Verse 1", :children => [
|
7
|
+
FactoryBot.build(:line, :children => [
|
8
|
+
FactoryBot.build(:bar),
|
9
|
+
FactoryBot.build(:bar),
|
10
10
|
])
|
11
11
|
])
|
12
12
|
|
13
|
-
tab =
|
13
|
+
tab = FactoryBot.build(:tab, :time => '4/4', :children => [stanza])
|
14
14
|
|
15
|
-
stanza.heading_in_lilypond.
|
15
|
+
expect(stanza.heading_in_lilypond).to eq('r1^"Verse 1" r1')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#heading_for_first_bar" do
|
20
20
|
it "should be the time signature's rest bar value with the stanza name if the time signature will generate whole note bars" do
|
21
|
-
bar =
|
22
|
-
stanza =
|
23
|
-
tab =
|
21
|
+
bar = FactoryBot.build(:bar)
|
22
|
+
stanza = FactoryBot.build(:stanza, :name => 'Intro', :children => [bar])
|
23
|
+
tab = FactoryBot.build(:tab, :children => [stanza], :time => '4/4')
|
24
24
|
|
25
|
-
stanza.heading_for_first_bar.
|
25
|
+
expect(stanza.heading_for_first_bar).to eq('r1^"Intro"')
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should attach the stanza name to the first rest note if the time signature will not generate whole note bars" do
|
29
|
-
bar =
|
30
|
-
stanza =
|
31
|
-
tab =
|
29
|
+
bar = FactoryBot.build(:bar)
|
30
|
+
stanza = FactoryBot.build(:stanza, :name => 'Intro', :children => [bar])
|
31
|
+
tab = FactoryBot.build(:tab, :children => [stanza], :time => '3/4')
|
32
32
|
|
33
|
-
stanza.heading_for_first_bar.
|
33
|
+
expect(stanza.heading_for_first_bar).to eq('r4^"Intro" r4 r4')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|