require 'rails_helper' module Mks module Rate RSpec.describe UnitOfChargesController, type: :controller do routes { Mks::Rate::Engine.routes } before(:each) do u = create(:user) token = Mks::Auth::TokenAuth.issue(name: u.full_name, email: u.email, id: u.id) request.headers['Authorization'] = "Bearer #{token}" end describe 'GET #index' do it 'returns all unit of charges' do 3.times { create(:unit_of_charge) } get :index result = JSON(response.body) expect(result['data'].count).to eq(3) end end end end end