spec/macros4cuke/templating/engine_spec.rb in macros4cuke-0.5.03 vs spec/macros4cuke/templating/engine_spec.rb in macros4cuke-0.5.06

- old
+ new

@@ -63,75 +63,75 @@ sample_text = 'Mary has a little lamb' result = Engine.parse(sample_text) # Expectation: an array with one couple: # [:static, the source text] - expect(result).to have(1).items + expect(result.size).to eq(1) expect(result[0]).to eq([:static, sample_text]) end it 'should parse a text line that consists of just a tag' do sample_text = '<some_tag>' result = Engine.parse(sample_text) # Expectation: an array with one couple: # [:static, the source text] - expect(result).to have(1).items + expect(result.size).to eq(1) expect(result[0]).to eq([:dynamic, strip_chevrons(sample_text)]) end it 'should parse a text line with a tag at the start' do sample_text = '<some_tag>some text' result = Engine.parse(sample_text) # Expectation: an array with two couples: # [dynamic, 'some_tag'][:static, some text] - expect(result).to have(2).items + expect(result.size).to eq(2) expect(result[0]).to eq([:dynamic, 'some_tag']) expect(result[1]).to eq([:static, 'some text']) end it 'should parse a text line with a tag at the end' do sample_text = 'some text<some_tag>' result = Engine.parse(sample_text) # Expectation: an array with two couples: # [:static, some text] [dynamic, 'some_tag'] - expect(result).to have(2).items + expect(result.size).to eq(2) expect(result[0]).to eq([:static, 'some text']) expect(result[1]).to eq([:dynamic, 'some_tag']) end it 'should parse a text line with a tag in the middle' do sample_text = 'begin <some_tag> end' result = Engine.parse(sample_text) # Expectation: an array with three couples: - expect(result).to have(3).items + expect(result.size).to eq(3) expect(result[0]).to eq([:static, 'begin ']) expect(result[1]).to eq([:dynamic, 'some_tag']) expect(result[2]).to eq([:static, ' end']) end it 'should parse a text line with two tags in the middle' do sample_text = 'begin <some_tag>middle<another_tag> end' result = Engine.parse(sample_text) # Expectation: an array with items couples: - expect(result).to have(5).items - expect(result[0]).to eq([:static , 'begin ']) + expect(result.size).to eq(5) + expect(result[0]).to eq([:static, 'begin ']) expect(result[1]).to eq([:dynamic, 'some_tag']) - expect(result[2]).to eq([:static , 'middle']) + expect(result[2]).to eq([:static, 'middle']) expect(result[3]).to eq([:dynamic, 'another_tag']) - expect(result[4]).to eq([:static, ' end']) + expect(result[4]).to eq([:static, ' end']) # Case: two consecutive tags sample_text = 'begin <some_tag><another_tag> end' result = Engine.parse(sample_text) # Expectation: an array with four couples: - expect(result).to have(4).items + expect(result.size).to eq(4) expect(result[0]).to eq([:static, 'begin ']) expect(result[1]).to eq([:dynamic, 'some_tag']) expect(result[2]).to eq([:dynamic, 'another_tag']) expect(result[3]).to eq([:static, ' end']) end @@ -139,20 +139,20 @@ it 'should parse a text line with escaped chevrons' do sample_text = 'Mary has a \<little\> lamb' result = Engine.parse(sample_text) # Expectation: an array with one couple: [:static, the source text] - expect(result).to have(1).items + expect(result.size).to eq(1) expect(result[0]).to eq([:static, sample_text]) end it 'should parse a text line with escaped chevrons in a tag' do sample_text = 'begin <some_\<\\>weird\>_tag> end' result = Engine.parse(sample_text) # Expectation: an array with three couples: - expect(result).to have(3).items + expect(result.size).to eq(3) expect(result[0]).to eq([:static, 'begin ']) expect(result[1]).to eq([:dynamic, 'some_\<\\>weird\>_tag']) expect(result[2]).to eq([:static, ' end']) end @@ -161,18 +161,18 @@ error_message = "Missing closing chevron '>'." expect { Engine.parse(sample_text) }.to raise_error( StandardError, error_message) end - it 'should complain if a text misses an opening chevron' do + it 'should complain if a text misses an opening chevron' do sample_text = 'begin <some_tag> > end' error_message = "Missing opening chevron '<'." expect { Engine.parse(sample_text) }.to raise_error( StandardError, error_message) end - it 'should complain if a text has nested opening chevrons' do + it 'should complain if a text has nested opening chevrons' do sample_text = 'begin <<some_tag> > end' error_message = "Nested opening chevron '<'." expect { Engine.parse(sample_text) }.to raise_error( StandardError, error_message) end @@ -307,10 +307,10 @@ it 'should render conditional sections' do instance = Engine.new(sophisticated_template) locals = { 'firstname' => 'Anon', - 'lastname' => 'Eemoos' , + 'lastname' => 'Eemoos', 'birthdate' => '1976-04-21' } rendered_text = instance.render(Object.new, locals) expected = <<-SNIPPET When I fill in "firstname" with "Anon"