How to create a learning curve for train and test sets from Carey

I have created a gbm model in caret. I wish to plot a learning curve with performance metric (AUC/ROC in my case) on y axis and 1:n.trees on x axis. I want to get performance values on both train and test set for every tree created by gbm. Which is possible in gbm package (n.trees = 1:n.trees in predict.gbm()), but for some reason I can not reproduce the example in caret.