I'm using Rubymotion and trying to write a test for an API method eg.
it "should call the api and return a result" do
Omapi.now do |response|
response.should.be.kind_of(Hash)
resume
end
wait {}
end
and the method I'm calling
def now(&callback)
AFMotion::JSON.get(MY_URL) do |result|
callback.call result
end
end
Whether Im using AFMotion, Elevate or Bubblewrap, or different publicly available test endpoints - I always have the same response. ie. The api returns a result correctly but the test fails anyway with a timeout error.
#<AFMotion::HTTPResult:0x10d43e460 @operation=#<AFHTTPRequestOperation:0x114415c60> @object=[{"result"=>"ok"}] @error=nil>
[FAILED - timeout exceeded: omapi - should call the api]
Bacon::Error: timeout exceeded: omapi - should call the api
spec.rb:404:in block in postponed_block_timeout_exceeded': omapi - should call the api
spec.rb:459:in
execute_block'
spec.rb:404:in `postponed_block_timeout_exceeded'
Is there any way to increase the timeout that the error refers to ?
Thanks
Try using the wait_max
helper.
it "should call the api and return a result" do
Omapi.now do |response|
response.should.be.kind_of(Hash)
resume
end
wait_max 20.0 {} # 20 seconds maximum
end