Skip to content

Commit 77f35c5

Browse files
srabuiniInsti
authored andcommitted
Possible changes in scale-generator (#418)
* Use % for all expected arrays * Use symbols in all scale names * Add BookKeeping::VERSION
1 parent 449d9e3 commit 77f35c5

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

exercises/scale-generator/example.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ def reorder_chromatic_scale
3434
chromatic_scale[index..-1] + chromatic_scale[0..index - 1]
3535
end
3636
end
37+
38+
module BookKeeping
39+
VERSION = 1
40+
end

exercises/scale-generator/scale_generator_test.rb

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_naming_scale
1414
def test_chromatic_scale
1515
skip
1616
chromatic = Scale.new('C', :chromatic)
17-
expected = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
17+
expected = %w(C C# D D# E F F# G G# A A# B)
1818
actual = chromatic.pitches
1919
assert_equal expected, actual
2020
end
@@ -46,15 +46,15 @@ def test_major_scale
4646
def test_another_major_scale
4747
skip
4848
major = Scale.new('G', :major, 'MMmMMMm')
49-
expected = ['G', 'A', 'B', 'C', 'D', 'E', 'F#']
49+
expected = %w(G A B C D E F#)
5050
actual = major.pitches
5151
assert_equal expected, actual
5252
end
5353

5454
def test_minor_scale
5555
skip
5656
minor = Scale.new('f#', :minor, 'MmMMmMM')
57-
expected = ['F#', 'G#', 'A', 'B', 'C#', 'D', 'E']
57+
expected = %w(F# G# A B C# D E)
5858
actual = minor.pitches
5959
assert_equal expected, actual
6060
end
@@ -86,7 +86,7 @@ def test_mixolydian_mode
8686
def test_lydian_mode
8787
skip
8888
lydian = Scale.new('a', :lydian, 'MMMmMMm')
89-
expected = ['A', 'B', 'C#', 'D#', 'E', 'F#', 'G#']
89+
expected = %w(A B C# D# E F# G#)
9090
actual = lydian.pitches
9191
assert_equal expected, actual
9292
end
@@ -109,7 +109,7 @@ def test_locrian_mode
109109

110110
def test_harmonic_minor
111111
skip
112-
harmonic_minor = Scale.new('d', 'harmonic_minor', 'MmMMmAm')
112+
harmonic_minor = Scale.new('d', :harmonic_minor, 'MmMMmAm')
113113
expected = %w(D E F G A Bb Db)
114114
actual = harmonic_minor.pitches
115115
assert_equal expected, actual
@@ -118,7 +118,7 @@ def test_harmonic_minor
118118
def test_octatonic
119119
skip
120120
octatonic = Scale.new('C', :octatonic, 'MmMmMmMm')
121-
expected = ['C', 'D', 'D#', 'F', 'F#', 'G#', 'A', 'B']
121+
expected = %w(C D D# F F# G# A B)
122122
actual = octatonic.pitches
123123
assert_equal expected, actual
124124
end
@@ -134,16 +134,38 @@ def test_hexatonic
134134
def test_pentatonic
135135
skip
136136
pentatonic = Scale.new('A', :pentatonic, 'MMAMA')
137-
expected = ['A', 'B', 'C#', 'E', 'F#']
137+
expected = %w(A B C# E F#)
138138
actual = pentatonic.pitches
139139
assert_equal expected, actual
140140
end
141141

142142
def test_enigmatic
143143
skip
144144
enigmatic = Scale.new('G', :enigma, 'mAMMMmM')
145-
expected = ['G', 'G#', 'B', 'C#', 'D#', 'F', 'F#']
145+
expected = %w(G G# B C# D# F F#)
146146
actual = enigmatic.pitches
147147
assert_equal expected, actual
148148
end
149+
150+
# Problems in exercism evolve over time, as we find better ways to ask
151+
# questions.
152+
# The version number refers to the version of the problem you solved,
153+
# not your solution.
154+
#
155+
# Define a constant named VERSION inside of the top level BookKeeping
156+
# module, which may be placed near the end of your file.
157+
#
158+
# In your file, it will look like this:
159+
#
160+
# module BookKeeping
161+
# VERSION = 1 # Where the version number matches the one in the test.
162+
# end
163+
#
164+
# If you are curious, read more about constants on RubyDoc:
165+
# http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
166+
167+
def test_bookkeeping
168+
skip
169+
assert_equal 1, BookKeeping::VERSION
170+
end
149171
end

0 commit comments

Comments
 (0)