Skip to content

Instantly share code, notes, and snippets.

@MaryKuz
Created March 28, 2019 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryKuz/91edf81f4b4f9df1876cece1a833c766 to your computer and use it in GitHub Desktop.
Save MaryKuz/91edf81f4b4f9df1876cece1a833c766 to your computer and use it in GitHub Desktop.
Write the test
require 'rails_helper'
RSpec.describe Api::UsersController, type: :controller do
it { should route(:post, 'api/user').to(action: :create) }
describe '#create.json' do
let(:params) do
{
name: 'Test name',
email: 'test@test.com',
password: '12345678',
password_confirmation: '12345678'
}
end
let(:user) { stub_model User }
before { expect(User).to receive(:new).with(params).and_return(user) }
before { expect(user).to receive(:save!) }
before { post :create, user: params, format: :json }
it { should render_template :create }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment