With the newer, non-monkey patching syntax, you would do: allow(dbl).to receive(:raise_then_return) do @counter = @counter.to_i.succ raise RuntimeError if @counter < 2 "foo"end
On Tue, Mar 28, 2017 at 1:31 PM, Joery Moinsen <[email protected]> wrote: > Hello, how can i stub methods with the newer syntax? My current stub looks > like > > dbl.stub(:raise_then_return) do > @counter = @counter.to_i.succ > raise RuntimeError if @counter < 2 > return "foo" > end > > > and i get a deprecation warning > > Deprecation Warnings: > > Using `stub` from rspec-mocks' old `:should` syntax without explicitly > enabling the syntax is deprecated. Use the new `:expect` syntax or > explicitly enable `:should` instead. > > The doc on Method stubs (https://www.relishapp.com/ > rspec/rspec-mocks/v/2-3/docs/method-stubs) has no equivalent for Rspec 3.5 > > > What is the preferred way to express my stub? I need a method that raises on > first call and then returns something on the second call. > > > Many thanks for considering my request. > > > -- > 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/eb57df04-8ab3-4503-8c4e-89ab5c468e4a%40googlegroups.com > <https://groups.google.com/d/msgid/rspec/eb57df04-8ab3-4503-8c4e-89ab5c468e4a%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/CADUxQmsy%3D8Fqktd8voYmTMV7Oa%2BSar7jDiXzTpXeymF2OB6hOA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
