ruby - Rspec Class any_instance expects method_name - where it is documented? -



ruby - Rspec Class any_instance expects method_name - where it is documented? -

i've stumbled upon next piece of code in rspec test , must more or less figured out can't find relevant sources prove it. please point me gem or docs describe:

describe somemodule::salesforce::lead before somemodule::salesforce::lead.any_instance.expects(:materialize) end ... end

it seems :each illustration in spec sets expectation on instance of class described above receive phone call :materialize method and redefines method do nothing . lastly part seems crucial because avoids connecting salesforce in test environment can't find confirmation this.

any_instance documented under working legacy code

you right in both sets expectation , stubs out original method on given instance of class.

previous versions of rspec accomplish monkeypatch ruby core classes (object , baseobject)

rspec 3 has new syntax not rely on monkeypatching:

before expect_any_instance_of(somemodule::salesforce).to receive(:materialize) end

ruby rspec mocking

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -