ruby on rails - Is it possible to return the method from a stub? -
i'm not sure it's best title it's hard explain i'll put code.
class bar include errors def self.foo raise_error("something") puts "should not go here" end end
and i've spec:
it "" stub(bar.new).raise_error { return } end
i want how return method on foo scope, give me "unexpected return"
would unstub
method?
yes possible https://www.relishapp.com/rspec/rspec-mocks/docs/method-stubs/stub-on-any-instance-of-a-class#any-instance-unstub
mymodel.any_instance.stub(:my_method) mymodel.any_instance.unstub(:my_method)
Comments
Post a Comment