spec/greenjaguar_spec.rb in greenjaguar-0.0.5 vs spec/greenjaguar_spec.rb in greenjaguar-0.0.6

- old
+ new

@@ -13,11 +13,11 @@ after do WebMock.reset! end - it '#run should call the passed code block 4 times' do + it 'should call the passed code block 4 times' do policy = @object_under_test.build_policy do times 3 end expect do @@ -26,11 +26,11 @@ end end.to raise_error assert_requested :get, "http://www.example.com", :times => 4 end - it '#run should call the passed code block only 1 time if successful response is received' do + it 'should call the passed code block only 1 time if successful response is received' do @stub = stub_request(:get, "http://www.example.com") policy = @object_under_test.build_policy do times 3 end @@ -39,11 +39,11 @@ Net::HTTP.get_response(URI.parse("http://www.example.com")) end assert_requested :get, "http://www.example.com", :times => 1 end - it '#run should raise the error once retrying is completed' do + it 'should raise the error once retrying is completed' do policy = @object_under_test.build_policy do times 3 end expect do @@ -51,11 +51,11 @@ Net::HTTP.get_response(URI.parse("http://www.example.com")) end end.to raise_error end - it '#run should call the passed code block 4 times according to fibonacci sequence' do + it 'should call the passed code block 4 times according to fibonacci sequence' do policy = @object_under_test.build_policy do times 3 with_strategy :fibonacci measure_time_in :ms end @@ -66,11 +66,11 @@ end end.to raise_error assert_requested :get, "http://www.example.com", :times => 4 end - it '#run should call the passed code block 4 times according to fixed interval strategy' do + it 'should call the passed code block 4 times according to fixed interval strategy' do policy = @object_under_test.build_policy do times 3 with_strategy :fixed_interval, 2 measure_time_in :ms end @@ -81,11 +81,11 @@ end end.to raise_error assert_requested :get, "http://www.example.com", :times => 4 end - it '#run should call the passed code block 4 times according to exponential backoff sequence' do + it 'should call the passed code block 4 times according to exponential backoff sequence' do policy = @object_under_test.build_policy do times 5 with_strategy :exponential_backoff measure_time_in :ms end @@ -96,11 +96,11 @@ end end.to raise_error assert_requested :get, "http://www.example.com", :times => 6 end - it '#run does not call the passed code block if exception is not part of allowed exception(s)' do + it 'does not call the passed code block if exception is not part of allowed exception(s)' do @stub = stub_request(:get, "www.example.com").to_raise(RegexpError) policy = @object_under_test.build_policy do times 5 with_strategy :fibonacci only_on_exceptions [ZeroDivisionError] @@ -112,11 +112,11 @@ end end.to raise_error assert_requested :get, "http://www.example.com", :times => 1 end - it '#run should call the passed code block if exception is part of allowed exception(s)' do + it 'should call the passed code block if exception is part of allowed exception(s)' do @stub = stub_request(:get, "http://www.example.com").to_raise(ZeroDivisionError) policy = @object_under_test.build_policy do times 10 with_strategy :fibonacci @@ -130,18 +130,28 @@ end end.to raise_error assert_requested :get, "http://www.example.com", :times => 11 end - it '#run should not raise the error if set to fail silently' do + it 'should not raise the error if set to fail silently' do policy = @object_under_test.build_policy do times 3 fail_silently end @object_under_test.robust_retry(policy) do Net::HTTP.get_response(URI.parse("http://www.example.com")) end + end + + it 'should use default strategy when none is specified' do + policy = @object_under_test.build_policy do + times 3 + measure_time_in :ms + fail_silently + end + + expect(policy.strategy.class).to eql(Greenjaguar::Strategies::DefaultWaitStrategy) end end end \ No newline at end of file