Recently I've been testing some stuff behind Doorkeeper and I needed to mock Doorkeeper token to return a stub. In older Doorkeeper versions it was done like this:

stub_prs = {
  :accessible? => true,
  :resource_owner_id => (user.nil? ? @user.id : user.id),
  :expired? => false
}
Doorkeeper::AccessToken.expects(:find_by_token).returns(stub(stub_prs))

However in a new Doorkeeper version, the've changed something and my mockings stopped working. So if you use newest Doorkeeper version, the mock should look like this:

stub_prs = {
  :accessible? => true,
  :resource_owner_id => (user.nil? ? @user.id : user.id),
  :expired? => false
}.merge(params)
@controller.expects(:doorkeeper_token).returns(stub(stub_prs)).at_least_once