I have an app calling an API which can take quite a while to respond (upwards of 10 seconds at times). I have taken steps to make this non blocking and show loading icons, however when I run the site locally the response time is very fast so I can't test whether my loading ui is working. Is there a good way to mock this in Rails?
Asked
Active
Viewed 403 times
1 Answers
1
Add sleep
to your controller actions, something like
def show
if Rails.env.development?
#Makes the request pause 5 seconds
sleep 5
end
...
end

dimuch
- 12,728
- 2
- 39
- 23
-
Yeah I was doing this. The problem is that it totally blocks the server, so other parts will need to come down but will be blocked as the thread is sleeping – cmwright Jun 19 '12 at 14:03
-
@cmwright yeah, but that's exactly whats going to happen in production with the long response time, right? – Jesse Wolgamott Jun 19 '12 at 14:12
-
Seems you have several ajax calls run simultaneously. The only way to test it I see is adding delay and using multi-threaded dev server, like unicorn http://stackoverflow.com/questions/10097101/rails-development-server-pdfkit-and-multithread – dimuch Jun 19 '12 at 14:40