title: How to mock the create call for a new ActiveRecord object in RSpec?
body: <p>I have an ActiveRecord object User. In the app I am making I am using a single sign on gem, but I need to save some of the user data in our databse. My ApplicationController has this code:</p>
  
  <pre><code>def create_user
    User.create(name: current_user['name'], email: current_user['email'], company_id: current_user['id'])
  end
  </code></pre>
  
  <p>I need an RSpec test that mocks out the actual <code>create</code> call. I have tried </p>
  
  <pre><code>allow_any_instance_of(User).to receive(:create).with(any_args).and_return(user)
  </code></pre>
  
  <p>which returns an error saying "User does not implement create".</p>