sapphire 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sapphire/DSL/Scenarios/Problematic.rb +29 -0
- data/lib/sapphire/DSL/Scenarios/background.rb +35 -33
- data/lib/sapphire/DSL/Scenarios/finally.rb +35 -33
- data/lib/sapphire/DSL/Scenarios/given.rb +63 -57
- data/lib/sapphire/DSL/Scenarios/scenario.rb +57 -53
- data/lib/sapphire/DSL/Scenarios/then.rb +36 -34
- data/lib/sapphire/DSL/Scenarios/when.rb +51 -47
- data/lib/sapphire/TeamCity/TeamCityReporter.rb +5 -0
- data/lib/sapphire/Testing/ConsoleReporter.rb +12 -0
- data/lib/sapphire/Testing/Executable.rb +42 -36
- data/lib/sapphire/Testing/HtmlReporter.rb +8 -0
- data/lib/sapphire/Testing/Reporter.rb +1 -0
- data/lib/sapphire/Testing/ResultTree.rb +45 -44
- data/lib/sapphire/version.rb +1 -1
- metadata +9 -8
@@ -0,0 +1,29 @@
|
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Scenarios
|
4
|
+
def Problematic(text)
|
5
|
+
Problematic.new text
|
6
|
+
end
|
7
|
+
|
8
|
+
class Problematic
|
9
|
+
|
10
|
+
attr_reader :text
|
11
|
+
attr_reader :and
|
12
|
+
|
13
|
+
def initialize(text)
|
14
|
+
@text = text
|
15
|
+
@and = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_and(text, &block)
|
19
|
+
self.and << Then.new(text, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
self.text
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,34 +1,36 @@
|
|
1
|
-
class Background
|
2
|
-
include Sapphire::Testing::Executable
|
3
|
-
|
4
|
-
attr_reader :value
|
5
|
-
attr_reader :text
|
6
|
-
attr_reader :block
|
7
|
-
attr_reader :parent
|
8
|
-
attr_reader :results
|
9
|
-
attr_reader :and
|
10
|
-
|
11
|
-
def initialize(parent, pre, text, &block)
|
12
|
-
@block = block
|
13
|
-
@value = text
|
14
|
-
@text = pre + text.to_s
|
15
|
-
@parent = parent
|
16
|
-
@results = []
|
17
|
-
@and = []
|
18
|
-
end
|
19
|
-
|
20
|
-
def AddResult(result)
|
21
|
-
result.item = self
|
22
|
-
@results << result
|
23
|
-
self.parent.result.AddChild(result)
|
24
|
-
end
|
25
|
-
|
26
|
-
def add_and(pre, text, &block)
|
27
|
-
if(self.value.is_a? Pending)
|
28
|
-
self.and << And.new(self, Pending.new(pre + text), &block)
|
29
|
-
|
30
|
-
self.and << And.new(self, pre + text, &block)
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
class Background
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :text
|
6
|
+
attr_reader :block
|
7
|
+
attr_reader :parent
|
8
|
+
attr_reader :results
|
9
|
+
attr_reader :and
|
10
|
+
|
11
|
+
def initialize(parent, pre, text, &block)
|
12
|
+
@block = block
|
13
|
+
@value = text
|
14
|
+
@text = pre + text.to_s
|
15
|
+
@parent = parent
|
16
|
+
@results = []
|
17
|
+
@and = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def AddResult(result)
|
21
|
+
result.item = self
|
22
|
+
@results << result
|
23
|
+
self.parent.result.AddChild(result)
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_and(pre, text, &block)
|
27
|
+
if(self.value.is_a? Pending)
|
28
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
29
|
+
elsif(self.value.is_a? Problematic)
|
30
|
+
self.and << And.new(self, Problematic.new(pre + text), &block)
|
31
|
+
else
|
32
|
+
self.and << And.new(self, pre + text, &block)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
34
36
|
end
|
@@ -1,34 +1,36 @@
|
|
1
|
-
class Finally
|
2
|
-
include Sapphire::Testing::Executable
|
3
|
-
|
4
|
-
attr_reader :value
|
5
|
-
attr_reader :block
|
6
|
-
attr_reader :text
|
7
|
-
attr_reader :and
|
8
|
-
attr_reader :parent
|
9
|
-
attr_reader :results
|
10
|
-
|
11
|
-
def initialize(parent, text, &block)
|
12
|
-
@value = text
|
13
|
-
@text = text.to_s
|
14
|
-
@block = block
|
15
|
-
@and = []
|
16
|
-
@parent = parent
|
17
|
-
@results = []
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_and(pre, text, &block)
|
21
|
-
if(self.value.is_a? Pending)
|
22
|
-
self.and << And.new(self, Pending.new(pre + text), &block)
|
23
|
-
|
24
|
-
self.and << And.new(self, pre + text, &block)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
self
|
32
|
-
|
33
|
-
|
1
|
+
class Finally
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :block
|
6
|
+
attr_reader :text
|
7
|
+
attr_reader :and
|
8
|
+
attr_reader :parent
|
9
|
+
attr_reader :results
|
10
|
+
|
11
|
+
def initialize(parent, text, &block)
|
12
|
+
@value = text
|
13
|
+
@text = text.to_s
|
14
|
+
@block = block
|
15
|
+
@and = []
|
16
|
+
@parent = parent
|
17
|
+
@results = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_and(pre, text, &block)
|
21
|
+
if(self.value.is_a? Pending)
|
22
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
23
|
+
elsif(self.value.is_a? Problematic)
|
24
|
+
self.and << And.new(self, Problematic.new(pre + text), &block)
|
25
|
+
else
|
26
|
+
self.and << And.new(self, pre + text, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def AddResult(result)
|
31
|
+
result.item = self
|
32
|
+
@results << result
|
33
|
+
self.parent.AddResult(result)
|
34
|
+
end
|
35
|
+
|
34
36
|
end
|
@@ -1,58 +1,64 @@
|
|
1
|
-
class Given
|
2
|
-
include Sapphire::Testing::Executable
|
3
|
-
|
4
|
-
attr_reader :value
|
5
|
-
attr_reader :text
|
6
|
-
attr_reader :block
|
7
|
-
attr_reader :finally
|
8
|
-
attr_reader :when
|
9
|
-
attr_reader :and
|
10
|
-
attr_reader :parent
|
11
|
-
attr_reader :results
|
12
|
-
|
13
|
-
def initialize(parent, pre, text, &block)
|
14
|
-
@value = text
|
15
|
-
@text = pre + text.to_s
|
16
|
-
@block = block
|
17
|
-
@when = []
|
18
|
-
@and = []
|
19
|
-
@parent = parent
|
20
|
-
@results = []
|
21
|
-
end
|
22
|
-
|
23
|
-
def add_when(pre, text, &block)
|
24
|
-
if(self.value.is_a? Pending)
|
25
|
-
@when << When.new(self, pre, Pending.new(text), &block)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@finally = finally
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
1
|
+
class Given
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_reader :text
|
6
|
+
attr_reader :block
|
7
|
+
attr_reader :finally
|
8
|
+
attr_reader :when
|
9
|
+
attr_reader :and
|
10
|
+
attr_reader :parent
|
11
|
+
attr_reader :results
|
12
|
+
|
13
|
+
def initialize(parent, pre, text, &block)
|
14
|
+
@value = text
|
15
|
+
@text = pre + text.to_s
|
16
|
+
@block = block
|
17
|
+
@when = []
|
18
|
+
@and = []
|
19
|
+
@parent = parent
|
20
|
+
@results = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_when(pre, text, &block)
|
24
|
+
if(self.value.is_a? Pending)
|
25
|
+
@when << When.new(self, pre, Pending.new(text), &block)
|
26
|
+
elsif(self.value.is_a? Problematic)
|
27
|
+
@when << When.new(self, pre, Problematic.new(text), &block)
|
28
|
+
else
|
29
|
+
x = When.new(self, pre, text, &block)
|
30
|
+
@when << x
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def last_when()
|
35
|
+
@when.last
|
36
|
+
end
|
37
|
+
|
38
|
+
def add_finally(finally)
|
39
|
+
if(self.value.is_a? Pending)
|
40
|
+
@finally = Finally.new(self, Pending.new(finally.text), &block)
|
41
|
+
elsif(self.value.is_a? Problematic)
|
42
|
+
@finally = Finally.new(self, Problematic.new(finally.text), &block)
|
43
|
+
else
|
44
|
+
@finally = finally
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_and(pre, text, &block)
|
49
|
+
if(self.value.is_a? Pending)
|
50
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
51
|
+
elsif(self.value.is_a? Problematic)
|
52
|
+
self.and << And.new(self, Problematic.new(pre + text), &block)
|
53
|
+
else
|
54
|
+
self.and << And.new(self, pre + text, &block)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def AddResult(result)
|
59
|
+
result.item = self
|
60
|
+
@results << result
|
61
|
+
self.parent.result.AddChild(result)
|
62
|
+
end
|
63
|
+
|
58
64
|
end
|
@@ -1,53 +1,57 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module DSL
|
3
|
-
module Scenarios
|
4
|
-
class Scenario
|
5
|
-
include Sapphire::Testing::TestRunnerAdapter
|
6
|
-
|
7
|
-
attr_reader :block
|
8
|
-
attr_reader :value
|
9
|
-
attr_reader :text
|
10
|
-
attr_reader :givens
|
11
|
-
attr_reader :backgrounds
|
12
|
-
attr_reader :result
|
13
|
-
attr_accessor :file_name
|
14
|
-
|
15
|
-
def initialize(text, &block)
|
16
|
-
@value = text
|
17
|
-
@text = text.to_s
|
18
|
-
@block = block
|
19
|
-
@givens = []
|
20
|
-
@backgrounds = []
|
21
|
-
@result = Testing::ScenarioResult.new(text)
|
22
|
-
@file_name = ""
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_given(given)
|
26
|
-
if(self.value.is_a? Pending)
|
27
|
-
@givens << Given.new(self, "", Pending.new(given.text), &block)
|
28
|
-
|
29
|
-
@givens << given
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@backgrounds << background
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
1
|
+
module Sapphire
|
2
|
+
module DSL
|
3
|
+
module Scenarios
|
4
|
+
class Scenario
|
5
|
+
include Sapphire::Testing::TestRunnerAdapter
|
6
|
+
|
7
|
+
attr_reader :block
|
8
|
+
attr_reader :value
|
9
|
+
attr_reader :text
|
10
|
+
attr_reader :givens
|
11
|
+
attr_reader :backgrounds
|
12
|
+
attr_reader :result
|
13
|
+
attr_accessor :file_name
|
14
|
+
|
15
|
+
def initialize(text, &block)
|
16
|
+
@value = text
|
17
|
+
@text = text.to_s
|
18
|
+
@block = block
|
19
|
+
@givens = []
|
20
|
+
@backgrounds = []
|
21
|
+
@result = Testing::ScenarioResult.new(text)
|
22
|
+
@file_name = ""
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_given(given)
|
26
|
+
if(self.value.is_a? Pending)
|
27
|
+
@givens << Given.new(self, "", Pending.new(given.text), &block)
|
28
|
+
elsif(self.value.is_a? Problematic)
|
29
|
+
@givens << Given.new(self, "", Problematic.new(given.text), &block)
|
30
|
+
else
|
31
|
+
@givens << given
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def last_given
|
36
|
+
@givens.last
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_background(background)
|
40
|
+
if(self.value.is_a? Pending)
|
41
|
+
@backgrounds << Background.new(self, "", Pending.new(background.text), &block)
|
42
|
+
elsif(self.value.is_a? Problematic)
|
43
|
+
@backgrounds << Background.new(self, "", Problematic.new(background.text), &block)
|
44
|
+
else
|
45
|
+
@backgrounds << background
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def last_background
|
50
|
+
@backgrounds.last
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -1,35 +1,37 @@
|
|
1
|
-
class Then
|
2
|
-
include Sapphire::Testing::Executable
|
3
|
-
|
4
|
-
attr_reader :value
|
5
|
-
attr_accessor :text
|
6
|
-
attr_reader :block
|
7
|
-
attr_reader :and
|
8
|
-
attr_reader :parent
|
9
|
-
attr_reader :results
|
10
|
-
|
11
|
-
def initialize(parent, pre, text, &block)
|
12
|
-
@block = block
|
13
|
-
@value = text
|
14
|
-
@text = pre + text.to_s
|
15
|
-
@and = []
|
16
|
-
@parent = parent
|
17
|
-
@results = []
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_and(pre, text, &block)
|
21
|
-
if(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
self
|
33
|
-
|
34
|
-
|
1
|
+
class Then
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_accessor :text
|
6
|
+
attr_reader :block
|
7
|
+
attr_reader :and
|
8
|
+
attr_reader :parent
|
9
|
+
attr_reader :results
|
10
|
+
|
11
|
+
def initialize(parent, pre, text, &block)
|
12
|
+
@block = block
|
13
|
+
@value = text
|
14
|
+
@text = pre + text.to_s
|
15
|
+
@and = []
|
16
|
+
@parent = parent
|
17
|
+
@results = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_and(pre, text, &block)
|
21
|
+
if(self.value.instance_of? Pending)
|
22
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
23
|
+
elsif(self.value.instance_of? Problematic)
|
24
|
+
self.and << And.new(self, Problematic.new(pre + text), &block)
|
25
|
+
else
|
26
|
+
x = And.new(self, text, &block)
|
27
|
+
self.and << x
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def AddResult(result)
|
32
|
+
result.item = self
|
33
|
+
@results << result
|
34
|
+
self.parent.results.last.AddChild(result)
|
35
|
+
end
|
36
|
+
|
35
37
|
end
|
@@ -1,48 +1,52 @@
|
|
1
|
-
class When
|
2
|
-
include Sapphire::Testing::Executable
|
3
|
-
|
4
|
-
attr_reader :value
|
5
|
-
attr_accessor :text
|
6
|
-
attr_reader :block
|
7
|
-
attr_reader :then
|
8
|
-
attr_reader :and
|
9
|
-
attr_reader :parent
|
10
|
-
attr_reader :results
|
11
|
-
|
12
|
-
def initialize(parent, pre, text, &block)
|
13
|
-
@block = block
|
14
|
-
@value = text
|
15
|
-
@text = pre + text.to_s
|
16
|
-
@then = []
|
17
|
-
@and = []
|
18
|
-
@parent = parent
|
19
|
-
@results = []
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_then(pre, text, &block)
|
23
|
-
if(self.value.is_a? Pending)
|
24
|
-
@then << Then.new(self, pre, Pending.new(text), &block)
|
25
|
-
|
26
|
-
@then << Then.new(self, pre, text, &block)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
self.and << And.new(self, pre + text, &block)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
1
|
+
class When
|
2
|
+
include Sapphire::Testing::Executable
|
3
|
+
|
4
|
+
attr_reader :value
|
5
|
+
attr_accessor :text
|
6
|
+
attr_reader :block
|
7
|
+
attr_reader :then
|
8
|
+
attr_reader :and
|
9
|
+
attr_reader :parent
|
10
|
+
attr_reader :results
|
11
|
+
|
12
|
+
def initialize(parent, pre, text, &block)
|
13
|
+
@block = block
|
14
|
+
@value = text
|
15
|
+
@text = pre + text.to_s
|
16
|
+
@then = []
|
17
|
+
@and = []
|
18
|
+
@parent = parent
|
19
|
+
@results = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_then(pre, text, &block)
|
23
|
+
if(self.value.is_a? Pending)
|
24
|
+
@then << Then.new(self, pre, Pending.new(text), &block)
|
25
|
+
elsif(self.value.is_a? Problematic)
|
26
|
+
@then << Then.new(self, pre, Problematic.new(text), &block)
|
27
|
+
else
|
28
|
+
@then << Then.new(self, pre, text, &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_and(pre, text, &block)
|
33
|
+
if(self.value.is_a? Pending)
|
34
|
+
self.and << And.new(self, Pending.new(pre + text), &block)
|
35
|
+
elsif(self.value.is_a? Problematic)
|
36
|
+
self.and << And.new(self, Problematic.new(pre + text), &block)
|
37
|
+
else
|
38
|
+
self.and << And.new(self, pre + text, &block)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def last_then
|
43
|
+
@then.last
|
44
|
+
end
|
45
|
+
|
46
|
+
def AddResult(result)
|
47
|
+
result.item = self
|
48
|
+
@results << result
|
49
|
+
self.parent.results.last.AddChild(result)
|
50
|
+
end
|
51
|
+
|
48
52
|
end
|
@@ -150,6 +150,11 @@ module Sapphire
|
|
150
150
|
log(@message_factory.create_suite_finished("Finally")) if test.item.is_a? Finally
|
151
151
|
end
|
152
152
|
|
153
|
+
def TestProblematic(test)
|
154
|
+
log(@message_factory.create_test_ignored(test.text, "Problematic"))
|
155
|
+
log(@message_factory.create_suite_finished("Finally")) if test.item.is_a? Finally
|
156
|
+
end
|
157
|
+
|
153
158
|
def TestingComplete()
|
154
159
|
|
155
160
|
end
|
@@ -7,6 +7,7 @@ module Sapphire
|
|
7
7
|
@passing_count = 0
|
8
8
|
@failing_count = 0
|
9
9
|
@pending_count = 0
|
10
|
+
@problematic_count = 0
|
10
11
|
@test_count = 0
|
11
12
|
@output = $stdout
|
12
13
|
end
|
@@ -34,6 +35,10 @@ module Sapphire
|
|
34
35
|
@output.puts result.text.colorize :yellow
|
35
36
|
Indent(depth+1)
|
36
37
|
@output.puts " ## Not Yet Implemented ##"
|
38
|
+
elsif result.type == 'problematic'
|
39
|
+
@output.puts result.text.colorize :orange
|
40
|
+
Indent(depth+1)
|
41
|
+
@output.puts " ## Problematic ##"
|
37
42
|
else
|
38
43
|
@output.puts result.text.colorize :red
|
39
44
|
if result.messages.is_a? Array
|
@@ -82,6 +87,12 @@ module Sapphire
|
|
82
87
|
@output.print "*".colorize :yellow
|
83
88
|
end
|
84
89
|
|
90
|
+
def TestProblematic(test)
|
91
|
+
@problematic_count = @problematic_count + 1
|
92
|
+
Add test
|
93
|
+
@output.print "P".colorize :orange
|
94
|
+
end
|
95
|
+
|
85
96
|
def Add(r)
|
86
97
|
result_passes = r.type == "pass"
|
87
98
|
|
@@ -112,6 +123,7 @@ module Sapphire
|
|
112
123
|
@output.puts "Passing: " + @passing_count.to_s.colorize(:green)
|
113
124
|
@output.puts "Failing: " + @failing_count.to_s.colorize(:red)
|
114
125
|
@output.puts "Pending: " + @pending_count.to_s.colorize(:yellow)
|
126
|
+
@output.puts "Problematic: " + @problematic_count.to_s.colorize(:orange)
|
115
127
|
end
|
116
128
|
|
117
129
|
def Output(result, depth)
|
@@ -1,36 +1,42 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module Testing
|
3
|
-
module Executable
|
4
|
-
def execute()
|
5
|
-
start = Time.now
|
6
|
-
Report do |x| x.TestStarted(self) end
|
7
|
-
begin
|
8
|
-
if(self.value.is_a? Pending)
|
9
|
-
result = ResultTree.new(self.text, TestResult.new("pending", self, "Pending", "", Time.now - start))
|
10
|
-
self.AddResult(result)
|
11
|
-
Report do |x| x.TestPending(result) end
|
12
|
-
return
|
13
|
-
end
|
14
|
-
self.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
module Sapphire
|
2
|
+
module Testing
|
3
|
+
module Executable
|
4
|
+
def execute()
|
5
|
+
start = Time.now
|
6
|
+
Report do |x| x.TestStarted(self) end
|
7
|
+
begin
|
8
|
+
if(self.value.is_a? Pending)
|
9
|
+
result = ResultTree.new(self.text, TestResult.new("pending", self, "Pending", "", Time.now - start))
|
10
|
+
self.AddResult(result)
|
11
|
+
Report do |x| x.TestPending(result) end
|
12
|
+
return
|
13
|
+
end
|
14
|
+
if(self.value.is_a? Problematic)
|
15
|
+
result = ResultTree.new(self.text, TestResult.new("problematic", self, "Problematic", "", Time.now - start))
|
16
|
+
self.AddResult(result)
|
17
|
+
Report do |x| x.TestProblematic(result) end
|
18
|
+
return
|
19
|
+
end
|
20
|
+
self.block.call
|
21
|
+
result = ResultTree.new(self.text, TestResult.new("pass", self, "Success", "", Time.now - start))
|
22
|
+
self.AddResult(result)
|
23
|
+
Report do |x| x.TestPassed(result) end
|
24
|
+
rescue => msg
|
25
|
+
stack = msg.backtrace
|
26
|
+
message = msg.messages if (msg.is_a? ExpectationException)
|
27
|
+
message ||= msg.message
|
28
|
+
result = ResultTree.new(self.text, TestResult.new("fail", self, message, stack, Time.now - start))
|
29
|
+
self.AddResult(result)
|
30
|
+
Report do |x| x.TestFailed(result) end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def Report(&block)
|
35
|
+
$reporters.each do |reporter|
|
36
|
+
block.call reporter
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -8,6 +8,7 @@ module Sapphire
|
|
8
8
|
@passing_count = 0
|
9
9
|
@failing_count = 0
|
10
10
|
@pending_count = 0
|
11
|
+
@problematic_count = 0
|
11
12
|
@test_count = 0
|
12
13
|
@output = $stdout
|
13
14
|
end
|
@@ -58,11 +59,18 @@ module Sapphire
|
|
58
59
|
@output.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{test.text} (PENDING: ### Not Yet Implemented ###)</span></dd>"
|
59
60
|
end
|
60
61
|
|
62
|
+
def TestProblematic(test)
|
63
|
+
@output.puts " <script type=\"text/javascript\">makeOrange('rspec-header');</script>" unless @header_red
|
64
|
+
@output.puts " <script type=\"text/javascript\">makeOrange('example_group_#{@example_group_number}');</script>" unless @example_group_red
|
65
|
+
@output.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{test.text} (PROBLEMATIC: ### Problematic ###)</span></dd>"
|
66
|
+
end
|
67
|
+
|
61
68
|
def TestingComplete
|
62
69
|
@end = Time.now
|
63
70
|
|
64
71
|
totals = "#{@test_count} example#{'s' unless @test_count == 1}, #{@failure_count} failure#{'s' unless @failure_count == 1}"
|
65
72
|
totals << ", #{@pending_count} pending" if @pending_count > 0
|
73
|
+
totals << ", #{@problematic_count} problematic" if @problematic_count > 0
|
66
74
|
|
67
75
|
@output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{(@end - @start).round(2).to_s} seconds</strong>\";</script>"
|
68
76
|
@output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
|
@@ -1,44 +1,45 @@
|
|
1
|
-
module Sapphire
|
2
|
-
module Testing
|
3
|
-
class ResultTree
|
4
|
-
|
5
|
-
attr_accessor :results
|
6
|
-
attr_accessor :type
|
7
|
-
attr_accessor :text
|
8
|
-
attr_accessor :messages
|
9
|
-
attr_accessor :stack
|
10
|
-
attr_accessor :time
|
11
|
-
attr_accessor :parent
|
12
|
-
attr_accessor :item
|
13
|
-
|
14
|
-
def initialize(text, result)
|
15
|
-
|
16
|
-
@type = 'pass'
|
17
|
-
@time = 0
|
18
|
-
|
19
|
-
if(result != nil)
|
20
|
-
self.type = result.type
|
21
|
-
@iconCls = "accept" if result.type == "pass"
|
22
|
-
@iconCls = "delete" if result.type == "fail"
|
23
|
-
@iconCls = "error" if result.type == "pending"
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
@
|
31
|
-
@
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
1
|
+
module Sapphire
|
2
|
+
module Testing
|
3
|
+
class ResultTree
|
4
|
+
|
5
|
+
attr_accessor :results
|
6
|
+
attr_accessor :type
|
7
|
+
attr_accessor :text
|
8
|
+
attr_accessor :messages
|
9
|
+
attr_accessor :stack
|
10
|
+
attr_accessor :time
|
11
|
+
attr_accessor :parent
|
12
|
+
attr_accessor :item
|
13
|
+
|
14
|
+
def initialize(text, result)
|
15
|
+
|
16
|
+
@type = 'pass'
|
17
|
+
@time = 0
|
18
|
+
|
19
|
+
if(result != nil)
|
20
|
+
self.type = result.type
|
21
|
+
@iconCls = "accept" if result.type == "pass"
|
22
|
+
@iconCls = "delete" if result.type == "fail"
|
23
|
+
@iconCls = "error" if result.type == "pending"
|
24
|
+
@iconCls = "error" if result.type == "problematic"
|
25
|
+
@time = result.execution_time
|
26
|
+
@expanded = true
|
27
|
+
@messages = result.messages
|
28
|
+
@stack = result.stack
|
29
|
+
end
|
30
|
+
@text = text
|
31
|
+
@results = []
|
32
|
+
@leaf = true
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def AddChild(node)
|
37
|
+
node.parent = self
|
38
|
+
@results << node
|
39
|
+
@leaf = false
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
data/lib/sapphire/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sapphire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-06 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9944292 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9944292
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9944040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9944040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Platform
|
38
|
-
requirement: &
|
38
|
+
requirement: &9943788 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9943788
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/sapphire/DSL/Scenarios/given.rb
|
125
125
|
- lib/sapphire/DSL/Scenarios/Is.rb
|
126
126
|
- lib/sapphire/DSL/Scenarios/Pending.rb
|
127
|
+
- lib/sapphire/DSL/Scenarios/Problematic.rb
|
127
128
|
- lib/sapphire/DSL/Scenarios/runner.rb
|
128
129
|
- lib/sapphire/DSL/Scenarios/scenario.rb
|
129
130
|
- lib/sapphire/DSL/Scenarios/then.rb
|