@@ -310,30 +310,47 @@ module ReactOnRails
310310      end 
311311
312312      describe  ".smart_trim"  do 
313-         it  "trims smartly"  do 
314-           s  =  "1234567890" 
315- 
316-           expect ( described_class . smart_trim ( s ,  -1 ) ) . to  eq ( "1234567890" ) 
317-           expect ( described_class . smart_trim ( s ,  0 ) ) . to  eq ( "1234567890" ) 
318-           expect ( described_class . smart_trim ( s ,  1 ) ) . to  eq ( "1#{ Utils ::TRUNCATION_FILLER }  ) 
319-           expect ( described_class . smart_trim ( s ,  2 ) ) . to  eq ( "1#{ Utils ::TRUNCATION_FILLER }  ) 
320-           expect ( described_class . smart_trim ( s ,  3 ) ) . to  eq ( "1#{ Utils ::TRUNCATION_FILLER }  ) 
321-           expect ( described_class . smart_trim ( s ,  4 ) ) . to  eq ( "12#{ Utils ::TRUNCATION_FILLER }  ) 
322-           expect ( described_class . smart_trim ( s ,  5 ) ) . to  eq ( "12#{ Utils ::TRUNCATION_FILLER }  ) 
323-           expect ( described_class . smart_trim ( s ,  6 ) ) . to  eq ( "123#{ Utils ::TRUNCATION_FILLER }  ) 
324-           expect ( described_class . smart_trim ( s ,  7 ) ) . to  eq ( "123#{ Utils ::TRUNCATION_FILLER }  ) 
325-           expect ( described_class . smart_trim ( s ,  8 ) ) . to  eq ( "1234#{ Utils ::TRUNCATION_FILLER }  ) 
326-           expect ( described_class . smart_trim ( s ,  9 ) ) . to  eq ( "1234#{ Utils ::TRUNCATION_FILLER }  ) 
327-           expect ( described_class . smart_trim ( s ,  10 ) ) . to  eq ( "1234567890" ) 
328-           expect ( described_class . smart_trim ( s ,  11 ) ) . to  eq ( "1234567890" ) 
313+         let ( :long_string )  {  "1234567890"  } 
314+ 
315+         context  "when FULL_TEXT_ERRORS is true"  do 
316+           before  {  ENV [ "FULL_TEXT_ERRORS" ]  =  "true"  } 
317+           after  {  ENV [ "FULL_TEXT_ERRORS" ]  =  nil  } 
318+ 
319+           it  "returns the full string regardless of length"  do 
320+             expect ( described_class . smart_trim ( long_string ,  5 ) ) . to  eq ( long_string ) 
321+           end 
322+ 
323+           it  "handles a hash without trimming"  do 
324+             hash  =  {  a : long_string  } 
325+             expect ( described_class . smart_trim ( hash ,  5 ) ) . to  eq ( hash . to_s ) 
326+           end 
329327        end 
330328
331-         it  "trims handles a hash"  do 
332-           s  =  {  a : "1234567890"  } 
329+         context  "when FULL_TEXT_ERRORS is not set"  do 
330+           before  {  ENV [ "FULL_TEXT_ERRORS" ]  =  nil  } 
331+ 
332+           it  "trims smartly"  do 
333+             expect ( described_class . smart_trim ( long_string ,  -1 ) ) . to  eq ( "1234567890" ) 
334+             expect ( described_class . smart_trim ( long_string ,  0 ) ) . to  eq ( "1234567890" ) 
335+             expect ( described_class . smart_trim ( long_string ,  1 ) ) . to  eq ( "1#{ Utils ::TRUNCATION_FILLER }  ) 
336+             expect ( described_class . smart_trim ( long_string ,  2 ) ) . to  eq ( "1#{ Utils ::TRUNCATION_FILLER }  ) 
337+             expect ( described_class . smart_trim ( long_string ,  3 ) ) . to  eq ( "1#{ Utils ::TRUNCATION_FILLER }  ) 
338+             expect ( described_class . smart_trim ( long_string ,  4 ) ) . to  eq ( "12#{ Utils ::TRUNCATION_FILLER }  ) 
339+             expect ( described_class . smart_trim ( long_string ,  5 ) ) . to  eq ( "12#{ Utils ::TRUNCATION_FILLER }  ) 
340+             expect ( described_class . smart_trim ( long_string ,  6 ) ) . to  eq ( "123#{ Utils ::TRUNCATION_FILLER }  ) 
341+             expect ( described_class . smart_trim ( long_string ,  7 ) ) . to  eq ( "123#{ Utils ::TRUNCATION_FILLER }  ) 
342+             expect ( described_class . smart_trim ( long_string ,  8 ) ) . to  eq ( "1234#{ Utils ::TRUNCATION_FILLER }  ) 
343+             expect ( described_class . smart_trim ( long_string ,  9 ) ) . to  eq ( "1234#{ Utils ::TRUNCATION_FILLER }  ) 
344+             expect ( described_class . smart_trim ( long_string ,  10 ) ) . to  eq ( "1234567890" ) 
345+             expect ( described_class . smart_trim ( long_string ,  11 ) ) . to  eq ( "1234567890" ) 
346+           end 
333347
334-           expect ( described_class . smart_trim ( s ,  9 ) ) . to  eq ( 
335-             "{:a=#{ Utils ::TRUNCATION_FILLER } \" }" 
336-           ) 
348+           it  "trims handles a hash"  do 
349+             s  =  {  a : "1234567890"  } 
350+             expect ( described_class . smart_trim ( s ,  9 ) ) . to  eq ( 
351+               "{:a=#{ Utils ::TRUNCATION_FILLER } \" }" 
352+             ) 
353+           end 
337354        end 
338355      end 
339356
0 commit comments