test/searcher_test.rb in inquisitio-0.1.7 vs test/searcher_test.rb in inquisitio-0.2.0
- old
+ new
@@ -209,21 +209,32 @@
def test_search_raises_exception_when_response_not_200
Excon.stub({}, {:body => 'Bad Happened', :status => 500})
searcher = Searcher.where('Star Wars')
+ searcher.instance_variable_set(:@failed_attempts, 3)
assert_raises(InquisitioError, "Search failed with status code 500") do
searcher.search
end
end
def test_search_raises_exception_when_excon_exception_thrown
Excon.stub({}, lambda { |_| raise Excon::Errors::Timeout})
searcher = Searcher.where('Star Wars')
+ searcher.instance_variable_set(:@failed_attempts, 3)
assert_raises(InquisitioError) do
+ searcher.search
+ end
+ end
+
+ def test_search_retries_when_failed_attempts_under_limit
+ Excon.expects(:get).raises(Excon::Errors::Timeout).times(3)
+
+ searcher = Searcher.where('Star Wars')
+ assert_raises(InquisitioError, "Search failed with status code 500") do
searcher.search
end
end
def test_that_iterating_calls_results