Skip to content

Instantly share code, notes, and snippets.

@rosiehoyem
Created October 13, 2013 17:24
Show Gist options
  • Save rosiehoyem/6964875 to your computer and use it in GitHub Desktop.
Save rosiehoyem/6964875 to your computer and use it in GitHub Desktop.
Jukebox Rspec code coverage lab
require 'simplecov'
SimpleCov.start
require 'json'
require 'rspec'
require_relative 'jukebox'
require_relative 'song'
#use this song data for your tests
songs = [
"The Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"The Phoenix - Consolation Prizes"
]
describe Song do
it "can be initialized" do
Song.new("Name").should be_an_instance_of(Song)
end
it "should have a name" do
song = Song.new("song name")
song.name.should eq("song name")
end
end
describe Jukebox do
# let(:jukebox) { Jukebox.new("songs") }
it "can be initialized" do
Jukebox.new("songs").should be_an_instance_of(Jukebox)
end
it "should have a songs" do
jukebox = Jukebox.new("songs")
jukebox.songs.should eq("songs")
end
it "should be on" do
jukebox = Jukebox.new("songs")
jukebox.on?.should eq(true)
end
describe'Jukebox'#help
it "should say 'Please select help, list, exit, or play.'" do
jukebox = Jukebox.new("songs")
jukebox.help.should eq("Please select help, list, exit, or play.")
end
describe'Jukebox'#exit
it "should turn off" do
jukebox = Jukebox.new("songs")
# jukebox.exit.should eq(false)
jukebox.exit.should eq("Goodbye, thanks for listening!")
end
describe'Jukebox'#list
it "should turn return a list of songs" do
jukebox = Jukebox.new(songs)
jukebox.list.should eq(
"1 The Phoenix - 1901",
"2 Tokyo Police Club - Wait Up",
"3 Sufjan Stevens - Too Much",
"4 The Naked and the Famous - Young Blood",
"5 (Far From) Home - Tiga",
"6 The Cults - Abducted",
"7 The Phoenix - Consolation Prizes")
end
end
# describe "with songs" do
# let(:artist) { Artist.new }
# let(:song) { Song.new }
# it "has songs" do
# artist.songs = []
# artist.songs.should eq([])
# end
# it "can have a song added" do
# artist.add_song(song)
# artist.songs.should include(song)
# end
# it "knows how many songs it has" do
# artist.songs = [song, Song.new]
# artist.songs.count.should eq(2)
# end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment