statt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -13
- data/lib/statt/motor.rb +63 -17
- data/spec/spec_helper.rb +17 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
= statt
|
2
|
-
Statt is
|
2
|
+
Statt is Selenium Testing All The Time. It's being built as a replacement for Webrat using Selenium servers organized in a grid, to speed up testing with multiple servers.
|
3
3
|
|
4
|
-
|
4
|
+
== Progress
|
5
5
|
|
6
|
-
|
7
|
-
-
|
8
|
-
-
|
9
|
-
- database setup using factory girl
|
10
|
-
- full api for selenium methods (cucumber steps)
|
6
|
+
So far, as of version 0.0.3:
|
7
|
+
- You can spawn a Hub, which stands in for the Remote Control server in a grid setup. This can only be started locally to minimize network latency contributing to slowing down the tests.
|
8
|
+
- You can spawn one to as many RC servers you need to do the job. In the future, you'll be able to specify the location of servers that are non-local, though you'll have to start them up yourself.
|
11
9
|
|
12
|
-
|
13
|
-
- optimizations for speed
|
14
|
-
- factory generation based on models
|
15
|
-
- dynamic test data inserted into tests based on factory setup
|
16
|
-
- model optimization hints
|
17
|
-
- multiple instances running simultaneously for further speed improvements
|
10
|
+
== TODO
|
18
11
|
|
12
|
+
- setting up the api for the selenium client, with the goal of replacing Webrat steps.
|
13
|
+
- algorithm for dealing with features that modify the database to ensure a clean state for tests that need it.
|
14
|
+
- cucumber integration (setup, teardown, tagging, database concurrency)
|
15
|
+
- minimize gem size (~7.8MB)
|
16
|
+
- wiki on how to set things up (Cucumber, DatabaseCleaner, Machinist).
|
17
|
+
- optimizations for speed.
|
19
18
|
|
20
19
|
== Note on Patches/Pull Requests
|
21
20
|
|
data/lib/statt/motor.rb
CHANGED
@@ -1,36 +1,82 @@
|
|
1
1
|
#!/usr/local/bin/ruby -w
|
2
2
|
|
3
|
-
# require "selenium"
|
4
|
-
require "test/unit"
|
5
|
-
# require "selenium/server_manager"
|
6
|
-
# require "selenium/selenium_server"
|
7
3
|
require "selenium/client/driver"
|
8
4
|
|
9
5
|
module Statt
|
10
6
|
class Motor
|
11
|
-
attr_accessor :rc
|
7
|
+
attr_accessor :rc
|
12
8
|
|
13
9
|
def initialize(options={})
|
10
|
+
|
14
11
|
options = { :hub_host => "localhost",
|
15
|
-
:hub_port => 4444
|
16
|
-
:rc_options =>
|
12
|
+
:hub_port => 4444,
|
13
|
+
:rc_options => {:host => "localhost", :port => 5555 } }.merge(options)
|
14
|
+
|
17
15
|
hub_options = { :host => options[:hub_host],
|
18
16
|
:port => options[:hub_port] }
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
|
18
|
+
# Start up Hub server in its own thread.
|
19
|
+
@hub_thread = Thread.new do
|
20
|
+
Thread.current[:hub] = SGrid::Hub.new(hub_options)
|
21
|
+
Thread.current[:hub].start
|
22
|
+
self.pass
|
23
|
+
end
|
24
|
+
|
25
|
+
@hub_thread[:hub].wait_until_up_and_running
|
26
|
+
|
27
|
+
# Start up the RC Servers, each within their own thread.
|
28
|
+
@rc_threads = []
|
29
|
+
@rc_threads << Thread.new do
|
30
|
+
rc_options = options[:rc_options]
|
31
|
+
if options[:rc_options].is_a?(Hash)
|
32
|
+
Thread.current[:server] = SGrid::RemoteControl.new(rc_options)
|
33
|
+
Thread.current[:server].start if rc_options[:host] == "localhost"
|
34
|
+
elsif options[:rc_options].is_a?(Array)
|
35
|
+
rc_options.each do |rc_option|
|
36
|
+
Thread.current[:server] = SGrid::RemoteControl.new(rc_option)
|
37
|
+
Thread.current[:server].start if rc_option[:host] == "localhost"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
raise Exception, "there was a problem starting the rc server(s)", caller
|
26
41
|
end
|
42
|
+
self.pass
|
27
43
|
end
|
44
|
+
|
28
45
|
end
|
29
|
-
|
30
|
-
def
|
31
|
-
|
46
|
+
|
47
|
+
def stop
|
48
|
+
Thread.new { shutdown_hub }
|
49
|
+
Thread.new { shutdown_rcs }
|
50
|
+
puts "Shutting down all servers "
|
32
51
|
end
|
33
52
|
|
53
|
+
def shutdown_hub
|
54
|
+
@hub_thread[:hub].shutdown
|
55
|
+
puts "."
|
56
|
+
end
|
57
|
+
|
58
|
+
def shutdown_rcs
|
59
|
+
@rc_threads.each do |thr|
|
60
|
+
thr[:server].shutdown
|
61
|
+
puts "."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# def start_hub
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# def start_rcs
|
69
|
+
# end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def hub
|
74
|
+
@hub_thread[:hub]
|
75
|
+
end
|
76
|
+
|
77
|
+
def rc_servers
|
78
|
+
@rc_threads.map {|thr| thr[:server] }
|
79
|
+
end
|
34
80
|
|
35
81
|
end
|
36
82
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
|
4
|
+
# --- Instructions ---
|
5
|
+
# - Sort through your spec_helper file. Place as much environment loading
|
6
|
+
# code that you don't normally modify during development in the
|
7
|
+
# Spork.prefork block.
|
8
|
+
# - Place the rest under Spork.each_run block
|
9
|
+
# - Any code that is left outside of the blocks will be ran during preforking
|
10
|
+
# and during each_run!
|
11
|
+
# - These instructions should self-destruct in 10 seconds. If they don't,
|
12
|
+
# feel free to delete them.
|
13
|
+
#
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
1
18
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
19
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
20
|
require 'statt'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- davidtrogers
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-24 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|