Created
October 9, 2013 04:16
-
-
Save sarony/6896143 to your computer and use it in GitHub Desktop.
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.rb' | |
| require_relative './song.rb' | |
| describe Song do | |
| it 'should create a new song with a name' do | |
| song=Song.new("Crazy") | |
| song.name.should eq("Crazy") | |
| song.name=("Pizza") | |
| song.name.should eq("Pizza") | |
| end | |
| end | |
| describe Jukebox do | |
| let(: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" | |
| ]} | |
| let(:song_objects){songs.collect do |song| song=Song.new(song) end} | |
| let(:jukebox) {Jukebox.new(song_objects)} | |
| it 'should be able to instantiate a new song' do | |
| jukebox.should be_a Jukebox | |
| jukebox.on?.should eq(true) | |
| end | |
| it 'should be on' do | |
| jukebox.on?.should eq(true) | |
| end | |
| it 'should give you help options' do | |
| jukebox.help.should eq("Please select help, list, exit, or play.") | |
| end | |
| it 'should detect incorrect commands' do | |
| jukebox.command("Coffee").should eq("invalid command") | |
| end | |
| it 'should call the help method' do | |
| jukebox.command("help").should | |
| eq("Please select help, list, exit, or play.") | |
| end | |
| it 'should call the play method' do jukebox.command("play The Cults - Abducted").should eq("now playing The Cults - Abducted") | |
| end | |
| it 'should list all the songs' do jukebox.list.should eq("1 The Phoenix - 1901\n""2 Tokyo Police Club - Wait Up\n""3 Sufjan Stevens - Too Much\n""4 The Naked and the Famous - Young Blood\n""5 (Far From) Home - Tiga\n""6 The Cults - Abducted\n""7 The Phoenix - Consolation Prizes\n") | |
| end | |
| it 'should exit the jukebox' do | |
| jukebox.exit.should eq("Goodbye, thanks for listening!") | |
| jukebox.on?.should eq(false) | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment