# Pickaxe code error

**URL:** <https://www.ruby-forum.com/t/pickaxe-code-error/97170>\
**Category:** Ruby\
**Created:** [July 5, 2006, 1:35pm UTC](https://www.ruby-forum.com/t/pickaxe-code-error/97170 "2006-07-05T13:35:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [July 5, 2006, 1:35pm UTC](https://www.ruby-forum.com/t/pickaxe-code-error/97170/1 "2006-07-05T13:35:22Z")

</div>

Not sure what’s going on with some code in Programming Ruby, it’s  
early on where a SongList container is being created and test units  
are run.  
I’m receiving this error:

1. Error:  
test\_delete(TestSongList):  
NameError: uninitialized constant TestSongList::Song  
pickaxe\_SongListContainer.rb:52:in `test\_delete’

the rb:52 won’t be right as I’ve put notes in comments between the  
code, which I’m stripping here. Perhaps someone is familiar with  
example. I checked errata with no luck…TIA

require ‘test/unit’

class SongList  
def initialize  
@songs = Array.new  
end

def append(song)  
#songs.push(song)  
self  
end

def delete\_first  
@songs.shift  
end

def delete\_last  
@songs.pop  
end

def   
@songs[index]  
end  
end

class TestSongList \< Test::Unit::TestCase  
def test\_delete  
list = SongList.new  
s1 = Song.new(‘title1’, ‘artist1’, 1)  
s2 = Song.new(‘title2’, ‘artist2’, 2)  
s3 = Song.new(‘title3’, ‘artist3’, 3)  
s4 = Song.new(‘title4’, ‘artist4’, 4)

```
list.append(s1).append(s2).append(s3).append(s4)

assert_equal(s1, list[0])
assert_equal(s3, list[2])
assert_nil(list[9])

assert_equal(s1, list.delete_first)
assert_equal(s2, list.delete_first)
assert_equal(s4, list.delete_last)
assert_equal(s3, list.delete_last)
assert_nil(list.delete_last)

```

end  
end

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [July 5, 2006, 1:38pm UTC](https://www.ruby-forum.com/t/pickaxe-code-error/97170/2 "2006-07-05T13:38:36Z")

</div>

Just realized that this needed to be in with the rest of the previous  
jukebox code.  
Sorry - ignore.

Stuart

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [July 5, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/pickaxe-code-error/97170/3 "2006-07-05T14:23:13Z")

</div>

Back again on this one, still getting a test delete failure.

1. Failure:  
test\_delete(TestSongList) [pickaxe\_p23.rb:137]:  
\<#\<Song:0x28a2d58 @artist=“artist1”, @duration=1, @name=“title1”\>\>  
expected but was  
.

Not sure what this means exactly?

Anyone else have this issue or remember the section of the book ?

Stuart

1 tests, 1 assertions, 1 failures, 0 errors

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [July 5, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/pickaxe-code-error/97170/4 "2006-07-05T16:09:20Z")

</div>

stuart fellowes wrote:

> Back again on this one, still getting a test delete failure.
> 
> 1. Failure:  
> test\_delete(TestSongList) [pickaxe\_p23.rb:137]:  
> \<#\<Song:0x28a2d58 @artist=“artist1”, @duration=1, @name=“title1”\>\>  
> expected but was  
> .
> 
> Not sure what this means exactly?
> 
> Anyone else have this issue or remember the section of the book ?
> 
> Stuart
> 
> 1 tests, 1 assertions, 1 failures, 0 errors

you have the following:  
def append(song)  
#songs.push(song)  
self  
end

Note that the line to push the song onto the list is commented out.  
Looks like you hit # instead of @

cheers

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [July 5, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/pickaxe-code-error/97170/5 "2006-07-05T16:26:44Z")

</div>

Yep, that was the error! Thank you…much obliged!

Stuart
