test/example_threaded_test.rb in surrounded-0.8.2 vs test/example_threaded_test.rb in surrounded-0.8.3
- old
+ new
@@ -1,31 +1,25 @@
require 'test_helper'
class ThreadedContext
extend Surrounded::Context
- def initialize(leader, members)
- role_names = [:leader, :members]
- role_players = [leader, members]
+ initialize :leader, :members
- role_names.concat(members.map{|member| :"member_#{member.object_id}" })
- role_players.concat(members)
-
- map_roles(role_names.zip(role_players))
-
- end
- private_attr_reader :leader, :members
-
trigger :meet do
- result = []
- result << leader.greet
- result << members.concurrent_map do |member|
- result << member.greet
- end
- result.flatten.join(' ')
+ leader.welcome
end
module Leader
+ def welcome
+ result = []
+ result << leader.greet
+ result << members.concurrent_map do |member|
+ result << member.greet
+ end
+ result.flatten.join(' ')
+ end
+
def greet
"Hello everyone. I am #{name}"
end
end
\ No newline at end of file