Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Created October 18, 2012 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/3911139 to your computer and use it in GitHub Desktop.
Save cmilfont/3911139 to your computer and use it in GitHub Desktop.
Can i TDD My Spikes?
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe GraduationsController do
describe "GET belts" do
before do
@belts = []
7.times {|n| @belts << FactoryGirl.create(:belt, :name => "#{n} belt" )}
Belt.stub(:all).and_return @belts
end
it "should list all belts" do
get :belts, :format => :json
assigns[:belts].should == @belts
assigns[:belts].should have(7).belts
end
end
describe "POST create" do
before do
@graduation = Graduation.new :id => 1
@belt = Belt.new :id => 1
@graduation.stub(:belt_to).and_return @belt
controller.stub_chain(:current_user, :profile, :graduate_your_student).and_return(@graduation)
end
# @graduation = current_user.profile.graduate_your_student params[:student_id], params[:belt_id]
# respond_with @graduation, :include => :belt_to
it "graduate your student" do
post :create, :format => :json, :student_id => 1, :belt_id => 1
assigns[:graduation].should == @graduation
assigns[:graduation].belt_to.should == @belt
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment