How to Stub IP in RSpec 3?
Often when you are writing unit tests, you want to stub your IP address. Some of the uses cases could be – you are checking if IP is within the certain range. In this quick tutorial I want to show you how to stub ip in RSpec 3.x , and how it is different from stubbing IP using RSpec 2.x.
For RSpec 2.x stubbing IP would look like this:
However, if you try to do it in RSpec 3.x, it will give you an error since ‘any_instance‘ syntax is deprecated.
Comments
Post a Comment