One of the challenges I'm facing is with my Restangular call, which has a baseUrl configured in a specific file as http://localhost:3000/
. For example, a call like:
Restangular.all("awards").customPOST(award)
Actually makes a request to baseUrl+"awards"
When it comes to writing tests for this functionality, I find myself having to specifically define the URL each time, like so:
httpBackend.expectPOST("http://localhost:3000/awards")
This approach works fine, until the baseUrl
needs to be updated. Then, I have to go back and modify every instance where I've set an expectation.
I've been wondering if there's a way to configure the base URL for the expect method in some centralized configuration file. This would allow me to write expectations like:
httpBackend.expectPOST(baseUrl + "awards");
In turn, making any adjustments to the baseUrl seamless and avoiding the need to update all instances of the expect()
method individually?