Sha256: b8a50a690c2ed2d2ba259c4d608e081b747485003e2d2b79851f039e9121383a
Contents?: true
Size: 888 Bytes
Versions: 3
Compression:
Stored size: 888 Bytes
Contents
require 'test_helper' describe Surrounded::Context, 'reusing context object' do let(:user){ User.new("Jim") } let(:other_user){ User.new("Guille") } let(:context){ TestContext.new(user, other_user) } it 'allows rebinding new players' do expect(context.access_other_object).must_equal 'Guille' context.rebind(user: User.new('Amy'), other_user: User.new('Elizabeth')) expect(context.access_other_object).must_equal 'Elizabeth' end it 'clears internal storage when rebinding' do originals = context.instance_variables.map{|var| context.instance_variable_get(var) } context.rebind(user: User.new('Amy'), other_user: User.new('Elizabeth')) new_ivars = context.instance_variables.map{|var| context.instance_variable_get(var) } originals.zip(new_ivars).each do |original_ivar, new_ivar| expect(original_ivar).wont_equal new_ivar end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
surrounded-0.9.11 | test/context_reuse_test.rb |
surrounded-0.9.10 | test/context_reuse_test.rb |
surrounded-0.9.9 | test/context_reuse_test.rb |