ruby on rails - Setting a variable when a stubbed method is called in RSpec -
in 1 of tests want perform before :all
action, , need want test method not called in before :all
action. there way this?
e.g. want able to:
before :all @bar_called = false # set @bar_called true if bar called on instance of class foo do_other_stuff end
and then, in 1 of specs later on, expect @bar_called == false
you implement mock block, set @bar_called
.
expect(obj).to receive(:my_method) { @bar_called = true }
now, may want consider setting expectation on mock/stub instead
expect(obj).to receive(:my_method).exactly(0).times
Comments
Post a Comment