offshore 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/offshore/client/suite.rb +1 -1
- data/lib/offshore/client/test.rb +36 -14
- data/lib/offshore/version.rb +1 -1
- data/lib/offshore.rb +1 -12
- metadata +1 -1
data/lib/offshore/client/test.rb
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
module Offshore
|
2
2
|
class Test
|
3
|
+
|
4
|
+
def self.current
|
5
|
+
@test ||= Test.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.flush
|
9
|
+
if @test && @test.run? && !@test.stopped?
|
10
|
+
# run again because it crashed in execution
|
11
|
+
@test.stop
|
12
|
+
end
|
13
|
+
@test = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.start(example)
|
17
|
+
flush
|
18
|
+
current.start(example)
|
19
|
+
current
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.stop
|
23
|
+
current.stop
|
24
|
+
current
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
3
29
|
def uuid
|
4
30
|
@uid ||= rand(99999999).to_s
|
5
31
|
end
|
@@ -11,29 +37,25 @@ module Offshore
|
|
11
37
|
"#{uuid} #{name}"
|
12
38
|
end
|
13
39
|
|
14
|
-
def run!(example)
|
15
|
-
raise "already run test: #{get_name(@run_example)}" if @run_example
|
16
|
-
@run_example = example
|
17
|
-
end
|
18
|
-
|
19
40
|
def run?
|
20
41
|
!!@run_example
|
21
42
|
end
|
43
|
+
|
44
|
+
def stopped?
|
45
|
+
!!@stopped
|
46
|
+
end
|
22
47
|
|
23
48
|
def start(example=nil)
|
24
|
-
run
|
49
|
+
raise "already run test: #{get_name(@run_example)}" if @run_example
|
50
|
+
@run_example = example
|
25
51
|
Offshore.suite.all_hosts!(:test_start, get_name(example))
|
26
52
|
end
|
27
53
|
|
28
|
-
def stop
|
29
|
-
Offshore.suite.all_hosts!(:test_stop, get_name(example))
|
30
|
-
Offshore.send(:internal_test_ended)
|
31
|
-
end
|
32
|
-
|
33
|
-
def failed
|
54
|
+
def stop
|
34
55
|
raise "have not run!" unless @run_example
|
35
|
-
|
56
|
+
raise "already stopped!" if @stopped
|
57
|
+
@stopped = true
|
58
|
+
Offshore.suite.all_hosts!(:test_stop, get_name(@run_example))
|
36
59
|
end
|
37
|
-
|
38
60
|
end
|
39
61
|
end
|
data/lib/offshore/version.rb
CHANGED
data/lib/offshore.rb
CHANGED
@@ -10,18 +10,7 @@ module Offshore
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def test
|
13
|
-
|
14
|
-
# run again because it crashed in execution
|
15
|
-
@test.failed
|
16
|
-
end
|
17
|
-
@test ||= Test.new
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def internal_test_ended
|
23
|
-
# called from test.failed and test.stop
|
24
|
-
@test = nil
|
13
|
+
Offshore::Test
|
25
14
|
end
|
26
15
|
end
|
27
16
|
|