We obtain accurate eigenvalues of the one-dimensional Schr\"{o}dinger equation with a Hamiltonian of the form $H_{g}=H+g\delta (x)$, where $\delta (x)$ is the Dirac delta function. We show that the well known Rayleigh-Ritz variational method is a suitable approach provided that the basis set takes into account the effect of the Dirac delta on the wavefunction. Present analysis may be suitable for an introductory course on quantum mechanics to illustrate the application of the Rayleigh-Ritz variational method to a problem where the boundary conditions play a relevant role and have to be introduced carefully into the trial function. Besides, the examples are suitable for motivating the students to resort to any computer-algebra software in order to calculate the required integrals and solve the secular equations.