test/example_proxy_test.rb in surrounded-0.9.0 vs test/example_proxy_test.rb in surrounded-0.9.1

- old
+ new

@@ -8,18 +8,27 @@ interface :admin do def some_admin_method "hello from #{name}, the admin interface!" end + + def talking_to_others + task.name + end end + wrap :task do end trigger :do_something do admin.some_admin_method end + trigger :talking do + admin.talking_to_others + end + trigger :admin_name do admin.name end trigger :admin_missing_method do @@ -32,12 +41,15 @@ describe ProxyContext do let(:user){ ProxyUser.new('Jim') } + let(:task){ + OpenStruct.new(name: 'GTD') + } let(:context){ - ProxyContext.new(user, Object.new) + ProxyContext.new(user, task) } it 'proxys methods between objects and its interface' do assert_equal 'hello from Jim, the admin interface!', context.do_something end @@ -47,7 +59,11 @@ it 'passes missing methods up the ancestry of the object' do err = ->{ context.admin_missing_method }.must_raise(NoMethodError) assert_match 'ProxyUser name="Jim"', err.message + end + + it 'allows access to other objects in the context' do + assert_equal 'GTD', context.talking end end