Skip to content

Instantly share code, notes, and snippets.

@TrevMcKendrick
Created October 11, 2013 15:57
Show Gist options
  • Save TrevMcKendrick/6937279 to your computer and use it in GitHub Desktop.
Save TrevMcKendrick/6937279 to your computer and use it in GitHub Desktop.
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