require 'rails_helper' module Mks module Rate RSpec.describe ServiceRatesController, 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 equipment rates' do 3.times { create(:service_rate) } get :index result = JSON.parse(response.body) expect(result['data'].count).to eq(3) end end describe 'GET #working_rates' do it 'Returns all working rates' do 3.times { create(:service_rate) } get :working_rates result = JSON(response.body) expect(result.count).to eq 3 expect(result[0].count).to eq 9 end end end end end