From 13efc9aca6574b1dc83d0021eb3814d737d0a411 Mon Sep 17 00:00:00 2001 From: Evan Sharp Date: Thu, 30 Jul 2015 16:43:54 -0400 Subject: [PATCH] Refactor Prawn::Text::Formatted::Arranger#preview_next_string specs --- spec/formatted_text_arranger_spec.rb | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/spec/formatted_text_arranger_spec.rb b/spec/formatted_text_arranger_spec.rb index 5d85ae3dd..95540d02c 100644 --- a/spec/formatted_text_arranger_spec.rb +++ b/spec/formatted_text_arranger_spec.rb @@ -36,25 +36,27 @@ expect(subject.unconsumed[3]).to eq(text: "world") end end -end -describe "Core::Text::Formatted::Arranger#preview_next_string" do - it "should not populate the consumed array" do - create_pdf - arranger = Prawn::Text::Formatted::Arranger.new(@pdf) - array = [{ :text => "hello" }] - arranger.format_array = array - arranger.preview_next_string - expect(arranger.consumed).to eq([]) - end - it "should not consumed array" do - create_pdf - arranger = Prawn::Text::Formatted::Arranger.new(@pdf) - array = [{ :text => "hello" }] - arranger.format_array = array - expect(arranger.preview_next_string).to eq("hello") + describe '#preview_next_string' do + context 'with a formatted array' do + let(:array) { [{text: 'hello' }] } + + before do + subject.format_array = array + end + + it 'does not populate the consumed array' do + subject.preview_next_string + expect(subject.consumed).to eq([]) + end + + it 'returns the text of the next unconsumed hash' do + expect(subject.preview_next_string).to eq("hello") + end + end end end + describe "Core::Text::Formatted::Arranger#next_string" do before(:each) do create_pdf