I want to test logs method and I don't know why I've got an error wrong number of arguments (given 1, expected 2)
class which I want to test:
class LogAdminData
def initialize(admin_obj:, type:, old_data:, new_data:)
@type = type
@old_data = old_data
@new_data = new_data.except(%w[created_at updated_at])
@admin_email = admin_obj.email
@admin_role = admin_obj.role
end
def call
log_admin_data!
end
private
attr_reader :type, :old_data, :new_data, :admin_email, :admin_role
def log_admin_data!
AdminPanelLog.update(
admin_email: admin_email,
admin_role: admin_role,
type: type,
new_data: new_data,
old_data: old_data,
)
end
end
and those are the specs:
RSpec.describe LogAdminData do
include_context 'with admin_user form'
let(:type) { 'Update attributes' }
let!(:admin_user) { create :admin_user, :super_admin }
describe '.call' do
subject(:admin_logs) do
described_class.new(
admin_obj: admin_user,
type: type,
old_data: admin_user_form,
new_data: admin_user_form,
).call
end
it { is_expected.to be_successful }
end
end
I thought the issue is in call method so I've changed log_admin_data!
and passed all arguments from attr_reader
but that wasn't the issue.