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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -