Sha256: 224920353e36785422fb133773f149096f525f22dacc2885f14eaa1d8c8be03e

Contents?: true

Size: 1.2 KB

Versions: 164

Compression:

Stored size: 1.2 KB

Contents

require 'rails_helper'
require 'rack/test'

RSpec.describe Api::UsersController, type: :controller do
  describe 'POST /api/users' do
    describe 'with required parameters' do
      it 'creates a user' do
        post :create, params: { login: 'alice', password: 'foobar' }
        expect(response.status).to eq(201)
      end
      describe 'with object-style parameters' do
        it 'creates a user' do
          post :create, params: { user: { login: 'alice', password: 'foobar' } }
          expect(response.status).to eq(201)
        end
      end
    end
    describe 'with a missing parameter' do
      it 'reports error 422' do
        post :create, params: {}
        expect(response.status).to eq(422)
      end
    end
  end
  describe 'GET /api/users' do
    before do
      post :create, params: { login: 'alice' }
    end
    it 'lists the users' do
      get :index, params: {}
      users = JSON.parse(response.body)
      expect(users.map { |r| r['login'] }).to include('alice')
    end
    describe 'with a custom header' do
      it 'lists the users' do
        request.headers['X-Sandwich'] = 'turkey'
        get :index, params: {}
        expect(response.status).to eq(200)
      end
    end
  end
end

Version data entries

164 entries across 82 versions & 1 rubygems

Version Path
appmap-0.83.4 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.4 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.3 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.3 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.2 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.2 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.1 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.1 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.0 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.83.0 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.82.0 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.82.0 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.81.1 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.81.1 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.81.0 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.81.0 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.80.2 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.80.2 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.80.1 spec/fixtures/rails5_users_app/spec/controllers/users_controller_api_spec.rb
appmap-0.80.1 spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb