Hi Paulo, I can't reproduce your issue. I ran your code (see this gist <https://gist.github.com/myronmarston/f2c5965da3c9a9989bb773f9b4e0d094> for the code I I'm running) and it passes as I would expect. If you want someone to look more into this, please provide:
- An explanation of what isn't working. "It does not work" is hard to interpret. Maybe it's just a misunderstanding. Tell us what behavior you expect, and what behavior you are seeing, and if there's an exception, please provide the stacktrace. - Some example code we can download and run to reproduce the issue. A gist like I provided is fine. Thanks, Myron On Thu, Feb 15, 2018 at 12:23 PM, Paulo Fabiano Langer < [email protected]> wrote: > Hi, guys! > > I'm struggling with a problem. > > Class X > def y > YAML.load_file(...) > end > end > > In my spec I have > > allow(YAML).to receive(:load_file).and_return(...) > expect(obj.y).to eq ... > > And it works! > > But, if I change the method to > > def self.y > ... > end > > and the expect to: > > expect(X.y)... > > > It does not work :( > > How can I make this stub and make it work with my class method? > > Thanks, > Paulo > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/rspec/46940dac-9fcc-4b6a-a6f2-7cfbbbe6e267%40googlegroups.com > <https://groups.google.com/d/msgid/rspec/46940dac-9fcc-4b6a-a6f2-7cfbbbe6e267%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/CADUxQmuU%2BF8HYsHQ-5h19BRYu9AaKxO%3DFL7mP8rDUVEXAk5pqg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
