You can try this. I am assuming that you are using factory_girl
. You can write the other test by returning a different user for current_user
describe "show" do
it "should use FooSerializer to serialize if the logged in user is the same as params user" do
user = FactoryGirl.create(:user)
controller.stub(:current_user).and_return(user)
FooSerializer.any_instance.should_receive(:to_json).and_return("{\"key\": \"value\"")
get :show, :id => user.id
response.should be_success
end
end