require 'spec_helper'

describe SQL::Generator::Buffer, '#content' do
  subject { object.content }

  let(:object) { described_class.new }

  shared_examples_for 'buffer content' do
    it 'should contain expected content' do
      should eql(expected_content)
    end

    its(:frozen?) { should be(true) }

    it 'should return fresh string copies' do
      first  = object.content
      second = object.content
      expect(first).to eql(second)
      expect(first).to_not be(second)
    end
  end

  context 'with empty buffer' do
    let(:expected_content) { '' }
    
    it_should_behave_like 'buffer content'
  end

  context 'with filled buffer' do
    before do
      object.append('foo')
    end
    let(:expected_content) { 'foo' }

    it_should_behave_like 'buffer content'
  end
end

require 'spec_helper'

describe SQL::Generator::Buffer, '#content' do
  subject { object.content }

  let(:object) { described_class.new }

  shared_examples_for 'buffer content' do
    it 'should contain expected content' do
      should eql(expected_content)
    end

    it { should be_frozen }

    it 'should return fresh string copies' do
      first  = object.content
      second = object.content
      expect(first).to eql(second)
      expect(first).to_not be(second)
    end
  end

  context 'with empty buffer' do
    let(:expected_content) { '' }

    it_should_behave_like 'buffer content'
  end

  context 'with filled buffer' do
    before do
      object.append('foo')
    end

    let(:expected_content) { 'foo' }

    it_should_behave_like 'buffer content'
  end
end

Simplify and clean up a bit buffer/content spec
Simplify and clean up a bit buffer/content spec
