Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.