lib/soaspec/wait.rb in soaspec-0.2.2 vs lib/soaspec/wait.rb in soaspec-0.2.3

- old
+ new

@@ -17,27 +17,24 @@ # @return [Object] the result of the block # def self.until(opts = {}) timeout = opts.fetch(:timeout, DEFAULT_TIMEOUT) ignored = Array(opts[:ignore] || NoElementAtPath) + interval = opts.fetch(:interval, DEFAULT_INTERVAL) end_time = Time.now + timeout last_error = nil until Time.now > end_time begin result = yield return result if result rescue *ignored => last_error # swallowed end - sleep opts.fetch(:interval, DEFAULT_INTERVAL) + sleep interval end - msg = if opts[:message] - opts[:message].dup - else - "timed out after #{timeout} seconds" - end + msg = opts[:message] ? opts[:message].dup : "timed out after #{timeout} seconds with interval of #{interval}" msg << " (#{last_error.message})" if last_error raise Soaspec::TimeOutError, msg end end end \ No newline at end of file