Sha256: ce1a406a5aa6e8b39011b2d1d8e6b95d4d287e71e4eef3b69bee41a8f0ecde0a
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require 'test_helper' class CollectionContext extend Surrounded::Context initialize :members, :others trigger :get_members_count do members.member_count end trigger :get_member_show do members.map(&:show).join(', ') end role :members do def member_count size end end role :member do def show "member show" end end role :others do; end role :other do; end end describe Surrounded::Context, 'auto-assigning roles for collections' do let(:member_one){ User.new('Jim') } let(:member_two){ User.new('Amy') } let(:members){ [member_one, member_two] } let(:other_one){ User.new('Guille') } let(:other_two){ User.new('Jason') } let(:others){ [other_one, other_two] } let(:context){ CollectionContext.new(members: members, others: others) } it 'assigns the collection role to collections' do assert_equal members.size, context.get_members_count end it 'assigns a defined role to each item in a role player collection' do assert_equal "member show, member show", context.get_member_show end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
surrounded-1.1.0 | test/collection_role_players_test.rb |
surrounded-1.0.0 | test/collection_role_players_test.rb |