Sha256: 49f5d61de9096fd12292c0f7219020060a13e31050e56888bf203bf2c300cff2

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe RSpecCandy::Helpers::DisposableCopy do

  describe Class do

    describe '.disposable_copy' do

      it 'should return a class' do
        Model.disposable_copy.should be_a(Class)
      end

      it 'should return a class with the same name as the original class' do
        Model.disposable_copy.name.should == 'Model'
      end

      it 'should return a class that instantiates objects that are also instances of the original class' do
        instance = Model.disposable_copy.new
        instance.should be_a(Model)
      end

      it 'should return a class that can be modified without changing the original class' do
        copy = Model.disposable_copy
        copy.class_eval do
          def foo
          end
        end
        copy.new.should respond_to(:foo)
        Model.new.should_not respond_to(:foo)
      end

      it 'should take a block with is evaluated in the context of the disposable class' do
        copy = Model.disposable_copy do
          def foo
          end
        end
        copy.new.should respond_to(:foo)
        Model.new.should_not respond_to(:foo)
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec_candy-0.1.1 spec/shared/rspec_candy/helpers/disposable_copy_spec.rb
rspec_candy-0.1.0 spec/shared/rspec_candy/helpers/disposable_copy_spec.rb