Sha256: 65eb7ab149ac7a0a81043015ee99e2a8ec197e9cddacde697a25deb1a445d4a5

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe Gitolite::DirtyProxy do

  it "should create a new instance given valid attributes" do
    expect(Gitolite::DirtyProxy.new([])).to_not be_nil
  end


  let(:target) { ['foo', 'bar'] }
  let(:proxy) { Gitolite::DirtyProxy.new(target) }


  describe 'delegating to the target object' do
    it 'should act as instance of the target' do
      expect(proxy).to be_instance_of target.class
    end

    it 'should respond to all methods of the target' do
      expect(proxy).to respond_to(*target.methods)
    end

    it 'should equal the target' do
      expect(proxy).to eql(target)
    end
  end


  describe 'dirty checking methods' do
    it 'should respond to clean_up!' do
      expect(proxy.respond_to?(:clean_up!)).to be true
    end

    it 'should respond to dirty?' do
      expect(proxy.respond_to?(:dirty?)).to be true
    end

    context 'when just initialized' do
      it 'should be clean' do
        expect(proxy.dirty?).to be false
      end
    end

    shared_examples 'dirty? clean_up!' do
      it 'should be dirty' do
        expect(proxy.dirty?).to be true
      end

      it 'should be clean again after clean_up!' do
        proxy.clean_up!
        expect(proxy.dirty?).to be false
      end
    end

    context 'when target object has changed directly' do
      before(:each) { proxy << 'baz' }
      include_examples 'dirty? clean_up!'
    end

    context 'when target object has changed in depth' do
      before(:each) { proxy[0] << 'ooo' }
      include_examples 'dirty? clean_up!'
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jbox-gitolite-1.2.7 spec/unit_tests/dirty_proxy_spec.rb
jbox-gitolite-1.2.6 spec/dirty_proxy_spec.rb
jbox-gitolite-1.2.5 spec/dirty_proxy_spec.rb
jbox-gitolite-1.2.4 spec/dirty_proxy_spec.rb
jbox-gitolite-1.2.3 spec/dirty_proxy_spec.rb