test/surrounded_context_test.rb in surrounded-0.9.7 vs test/surrounded_context_test.rb in surrounded-0.9.8

- old
+ new

@@ -213,9 +213,35 @@ it 'applies a provided block to the instance' do assert_equal 'yup', context.instance_variable_get(:@defined_by_initializer_block) end end +class BareObjectContext + extend Surrounded::Context + + def initialize(number, string, user) + map_roles(:number => number, :string => string, :user => user) + end + private_attr_reader :number, :string, :user + + role :user do + def output + [number.to_s, string, name].join(' - ') + end + end + + trigger :output do + user.output + end +end + +describe Surrounded::Context, 'skips affecting non-surrounded objects' do + it 'works with non-surrounded objects' do + context = BareObjectContext.new(123,'hello', User.new('Jim')) + assert_equal '123 - hello - Jim', context.output + end +end + class CollectionContext extend Surrounded::Context initialize :members, :others