Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Stub un método dentro de otro método
module A module B class C def fun(github) return username end def gun(github) author=fun(github) #perfom some operation return count end end end

Quiero probar la función del arma, pero para obtener el valor del autor, es divertido llamar a la función. Ahora, no quiero llamar a esta función y, en su lugar, cerrarla.

Para lograr eso, escribí esta línea en la sección antes de hacer mientras probaba la función_1, pero no funciona.

 allow(A::B::C).to receive(:fun).and_return("username")

no puedo descifrar

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Ambos métodos son métodos de instancia, no métodos de clase, por lo tanto, debe agregar el método en la instancia.

Lo siguiente podría funcionar para usted:

 let(:abc) { A:BCnew } let(:github) { ... } before { allow(abc).to receive(:fun).and_return("username") } it "..." do expect(abc.fun(github)).to eq(...) expect(abc).to have_received(:fun).with(github) end
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!