On Github keathley / quick-check-talk
Growing Object-Oriented Software Guided by Tests
Lets build an music player
describe "POST #queue" do it "should add the track to the queue and alert clients of change" do id = 1337 track = instance_double("Track", :id => id) expect(Track).to receive(:find).with(id).and_return(track) expect(Queue).to receive(:add_track).with(track).and_return 1 expect(Broadcast).to receive(:broadcast) post '/queue', :id => id end end
class App < Sinatra::Base post "/queue" do @track = Track.find(params[:id]) Queue.add_track(@track) Broadcast.send('/songs', @track) end end
describe "POST #queue" do it "should add the track to the queue and alert clients of change" do id = 1337 track = instance_double("Track", :id => id) expect(Track).to receive(:find).with(id).and_return(track) expect(Queue).to receive(:add_track).with(track).and_return 1 expect(Broadcast).to receive(:broadcast) post '/queue', :id => id end end
class App < Sinatra::Base post "/queue" do @track = Track.find(params[:id]) Queue.add_track(@track) Broadcast.send('/songs', @track) end end
A way of saying what this thing should do
Generate fake data for testing
Help narrow down failing cases