Created
March 28, 2019 11:40
-
-
Save MaryKuz/91edf81f4b4f9df1876cece1a833c766 to your computer and use it in GitHub Desktop.
Write the test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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