Sha256: 590dcc856611e4c33ea8db53c50e558144af2b3a7ce3adfd5b8ae927dada0cac

Contents?: true

Size: 968 Bytes

Versions: 33

Compression:

Stored size: 968 Bytes

Contents

require 'spec_helper'

module Startback
  describe Context, "dup" do

    let(:context) {
      SubContext.new.tap{|s| s.foo = "bar" }
    }

    class ContextRelatedAbstraction

      def initialize(context)
        @context = context
      end
      attr_reader :context

    end

    it 'yields a dup of the original context' do
      seen = false
      got = context.dup{|x|
        seen = x
        expect(x).not_to be(context)
      }
      expect(seen).to be(got)
      expect(got).to be_a(SubContext)
      expect(got).not_to be(context)
      expect(got.foo).to eql("bar")
    end

    it 'cleans all factored cache' do
      cra = context.factor(ContextRelatedAbstraction)
      expect(cra).to be_a(ContextRelatedAbstraction)
      cra2 = context.factor(ContextRelatedAbstraction)
      expect(cra2).to be(cra)
      cra3 = context.dup.factor(ContextRelatedAbstraction)
      expect(cra3).not_to be(cra)
      expect(cra3).not_to be(cra2)
    end

  end
end

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
startback-1.0.3 spec/unit/context/test_dup.rb
startback-1.0.2 spec/unit/context/test_dup.rb
startback-1.0.1 spec/unit/context/test_dup.rb
startback-1.0.0 spec/unit/context/test_dup.rb
startback-0.19.4 spec/unit/context/test_dup.rb
startback-0.19.3 spec/unit/context/test_dup.rb
startback-0.19.1 spec/unit/context/test_dup.rb
startback-0.19.0 spec/unit/context/test_dup.rb
startback-0.18.2 spec/unit/context/test_dup.rb
startback-0.18.1 spec/unit/context/test_dup.rb
startback-0.18.0 spec/unit/context/test_dup.rb
startback-0.17.4 spec/unit/context/test_dup.rb
startback-0.17.3 spec/unit/context/test_dup.rb
startback-0.17.2 spec/unit/context/test_dup.rb
startback-0.17.1 spec/unit/context/test_dup.rb
startback-0.17.0 spec/unit/context/test_dup.rb
startback-0.16.0 spec/unit/context/test_dup.rb
startback-0.15.5 spec/unit/context/test_dup.rb
startback-0.15.4 spec/unit/context/test_dup.rb
startback-0.15.3 spec/unit/context/test_dup.rb