@@ -676,15 +676,13 @@ class ::DummyIndexingModelForRecreate
676676 end
677677
678678 context 'when the index is not found' do
679+ let ( :logger ) { nil }
680+ let ( :transport ) do
681+ Elasticsearch ::Transport ::Client . new ( logger : logger )
682+ end
683+
679684 let ( :client ) do
680- double (
681- 'client' ,
682- indices : indices ,
683- transport : double (
684- 'transport' ,
685- double ( 'transport' , { logger : nil } )
686- )
687- )
685+ double ( 'client' , indices : indices , transport : transport )
688686 end
689687
690688 let ( :indices ) do
@@ -698,19 +696,17 @@ class ::DummyIndexingModelForRecreate
698696 end
699697
700698 context 'when the force option is true' do
701-
702699 it 'deletes the index without raising an exception' do
703700 expect ( DummyIndexingModelForRecreate . delete_index! ( force : true ) ) . to be_nil
704701 end
705702
706703 context 'when the client has a logger' do
707-
708704 let ( :logger ) do
709705 Logger . new ( STDOUT ) . tap { |l | l . level = Logger ::DEBUG }
710706 end
711707
712708 let ( :client ) do
713- double ( 'client' , indices : indices , transport : double ( ' transport' , { logger : logger } ) )
709+ double ( 'client' , indices : indices , transport : transport )
714710 end
715711
716712 it 'deletes the index without raising an exception' do
@@ -918,7 +914,11 @@ class ::DummyIndexingModelForRefresh
918914 end
919915
920916 let ( :client ) do
921- double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : nil } ) )
917+ double ( 'client' , indices : indices , transport : transport )
918+ end
919+
920+ let ( :transport ) do
921+ Elasticsearch ::Transport ::Client . new ( logger : nil )
922922 end
923923
924924 let ( :indices ) do
@@ -930,9 +930,7 @@ class ::DummyIndexingModelForRefresh
930930 end
931931
932932 context 'when the force option is true' do
933-
934933 context 'when the operation raises a NotFound exception' do
935-
936934 before do
937935 expect ( indices ) . to receive ( :refresh ) . and_raise ( NotFound )
938936 end
@@ -942,13 +940,16 @@ class ::DummyIndexingModelForRefresh
942940 end
943941
944942 context 'when the client has a logger' do
945-
946943 let ( :logger ) do
947944 Logger . new ( STDOUT ) . tap { |l | l . level = Logger ::DEBUG }
948945 end
949946
950947 let ( :client ) do
951- double ( 'client' , indices : indices , transport : double ( 'transport' , { logger : logger } ) )
948+ double ( 'client' , indices : indices , transport : transport )
949+ end
950+
951+ let ( :transport ) do
952+ Elasticsearch ::Transport ::Client . new ( logger : logger )
952953 end
953954
954955 it 'does not raise an exception' do
@@ -963,7 +964,6 @@ class ::DummyIndexingModelForRefresh
963964 end
964965
965966 context 'when the operation raises another type of exception' do
966-
967967 before do
968968 expect ( indices ) . to receive ( :refresh ) . and_raise ( Exception )
969969 end
@@ -977,7 +977,6 @@ class ::DummyIndexingModelForRefresh
977977 end
978978
979979 context 'when an index name is provided in the options' do
980-
981980 before do
982981 expect ( indices ) . to receive ( :refresh ) . with ( index : 'custom-foo' )
983982 end
0 commit comments