Created
October 9, 2013 13:11
-
-
Save rosiehoyem/6901028 to your computer and use it in GitHub Desktop.
Jukebox Rspec Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment