Permalink
Browse files

tapping script almost done

  • Loading branch information...
1 parent 5a7ed6c commit a3a493ebe778bd112a4c26847b2a2ee4809629b7 @HakubJozak committed Feb 13, 2012
Showing with 30 additions and 26 deletions.
  1. +30 −26 script/loop.rb
View
56 script/loop.rb
@@ -13,33 +13,37 @@
Capybara.app_host = 'http://localhost:8080'
Capybara.current_driver = :webkit
-#ready = Queue.new
tasks = []
-
-3.times do |i|
- tasks << fork do
- puts '1'
- # ready.pop
- name = "Igra Thread #{i}"
-
- visit '/games'
- puts '2'
- click_link 'Create'
- puts '3'
- fill_in 'Name', with: "#{name}"
- puts '4'
- click_button 'Create Game'
- puts '5'
-
- fill_in 'Cards', with: '15,Forest'
- click_button "Join '#{name}'"
- puts "Started #{name}"
+begin
+ 3.times do |i|
+ tasks << fork do
+ puts '1'
+ name = "Igra Thread #{i}"
+
+ visit '/games'
+ puts '2'
+ click_link 'Create'
+ puts '3'
+ fill_in 'Name', with: "#{name}"
+ puts '4'
+ click_button 'Create Game'
+ puts '5'
+
+ fill_in 'Cards', with: '15,Forest'
+ click_button "Join '#{name}'"
+ puts "Started #{name}"
+
+ 50.times do
+ sleep rand(4)
+ puts "Task #{i}: tapping card"
+
+ # page.execute_script("console.info('something');")
+ puts page.evaluate_script('Card.all.first().name()');
+ # tap card
+ end
+ end
end
+ensure
+ tasks.each { |t| Process.waitpid(t) }
end
-
-tasks.each { |t| Process.waitpid(t) }
-
-#ready.push(true)
-# tasks.each { |t| t.join }
-

0 comments on commit a3a493e

Please sign in to comment.