Created
October 9, 2013 04:47
-
-
Save TrevMcKendrick/6896352 to your computer and use it in GitHub Desktop.
This file contains 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' | |
RSpec.configure do |config| | |
# Use color in STDOUT | |
config.color_enabled = true | |
# Use color not only in STDOUT but also in pagers and files | |
config.tty = true | |
# Use the specified formatter | |
config.formatter = :progress # :progress, :html, :textmate | |
end | |
#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 'should have a name when it gets initialized' do | |
new_song = Song.new("New song bitches!") | |
new_song.name.should == "New song bitches!" | |
end | |
end | |
describe Jukebox do | |
it 'should have songs when it gets initialized' do | |
new_jukebox = Jukebox.new(songs) | |
new_jukebox.songs.should == songs | |
end | |
describe "#on?" do | |
it 'should return true if the program is running' do | |
new_jukebox = Jukebox.new(songs) | |
new_jukebox.on?.should == true | |
end | |
end | |
describe "help" do | |
it 'should return instructions' do | |
new_jukebox = Jukebox.new(songs) | |
new_jukebox.help.should == "Please select help, list, exit, or play." | |
end | |
end | |
describe "command" do | |
it 'should return invalid command if the input is not valid' do | |
new_jukebox = Jukebox.new(songs) | |
new_jukebox.command("qwerqwerqwer").should == "invalid command" | |
end | |
end | |
describe "exit" do | |
it 'should turn off the box and thank the user for playing' do | |
new_jukebox = Jukebox.new(songs) | |
new_jukebox.exit.should == "Goodbye, thanks for listening!" | |
new_jukebox.on?.should == false | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment