sapphire 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sapphire +3 -3
- data/lib/sapphire.rb +2 -2
- data/lib/sapphire/DSL/TestPlans/TestPlan.rb +2 -1
- data/lib/sapphire/TeamCity/TeamCityReporter.rb +4 -0
- data/lib/sapphire/Testing/ConsoleReporter.rb +87 -26
- data/lib/sapphire/Testing/Executable.rb +3 -3
- data/lib/sapphire/Testing/HtmlReporter.rb +268 -16
- data/lib/sapphire/Testing/Reporter.rb +0 -127
- data/lib/sapphire/version.rb +1 -1
- metadata +8 -8
data/bin/sapphire
CHANGED
@@ -3,7 +3,7 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
|
3
3
|
require 'sapphire'
|
4
4
|
include Sapphire::Sapphire
|
5
5
|
|
6
|
-
reporter =
|
6
|
+
reporter = ConsoleReporter.new()
|
7
7
|
|
8
8
|
ARGV.each do |arg|
|
9
9
|
if !arg.end_with? ".rb"
|
@@ -20,7 +20,7 @@ if Runner.instance.test_plans.count > 0
|
|
20
20
|
else
|
21
21
|
Runner.instance.scenarios.each do |scenario|
|
22
22
|
scenario.execute reporter
|
23
|
+
reporter.TestingComplete
|
24
|
+
reporter.OutputResults
|
23
25
|
end
|
24
26
|
end
|
25
|
-
|
26
|
-
reporter.OutputResults
|
data/lib/sapphire.rb
CHANGED
@@ -11,7 +11,7 @@ require 'colorize'
|
|
11
11
|
require File.expand_path(File.dirname(__FILE__) +'/sapphire/Strategies/Strategy.rb', __FILE__)
|
12
12
|
require File.expand_path(File.dirname(__FILE__) +'/sapphire/Testing/Reporter.rb', __FILE__)
|
13
13
|
Dir[File.dirname(__FILE__) + '/sapphire/Testing/*.rb'].each {|file| require file }
|
14
|
-
Dir[File.dirname(__FILE__) + '/sapphire/TeamCity/*.rb'].each {|file| require file }
|
14
|
+
#Dir[File.dirname(__FILE__) + '/sapphire/TeamCity/*.rb'].each {|file| require file }
|
15
15
|
Dir[File.dirname(__FILE__) + '/sapphire/Configuration/*.rb'].each {|file| require file }
|
16
16
|
Dir[File.dirname(__FILE__) + '/sapphire/WebAbstractions/Controls/Base/*.rb'].each {|file| require file }
|
17
17
|
Dir[File.dirname(__FILE__) + '/sapphire/WebAbstractions/Controls/*.rb'].each {|file| require file }
|
@@ -39,7 +39,7 @@ module Sapphire
|
|
39
39
|
include JobAbstractions
|
40
40
|
include WebAbstractions
|
41
41
|
include Testing
|
42
|
-
include Testing::TeamCity
|
42
|
+
#include Testing::TeamCity
|
43
43
|
include UI
|
44
44
|
end
|
45
45
|
end
|
@@ -3,7 +3,7 @@ module Sapphire
|
|
3
3
|
module TestPlans
|
4
4
|
|
5
5
|
def TestPlan(text, &block)
|
6
|
-
reporter =
|
6
|
+
reporter = ConsoleReporter.new()
|
7
7
|
Runner.instance.add_test_plan(TestPlan.new(text, reporter, &block))
|
8
8
|
end
|
9
9
|
|
@@ -51,6 +51,7 @@ module Sapphire
|
|
51
51
|
@reporter.BeginTesting
|
52
52
|
$stdout.puts ""
|
53
53
|
@block.call
|
54
|
+
@reporter.TestingComplete
|
54
55
|
@reporter.OutputResults
|
55
56
|
end
|
56
57
|
end
|
@@ -2,6 +2,28 @@ module Sapphire
|
|
2
2
|
module Testing
|
3
3
|
class ConsoleReporter < Reporter
|
4
4
|
|
5
|
+
def initialize
|
6
|
+
@not_passing = {}
|
7
|
+
@passing_count = 0
|
8
|
+
@failing_count = 0
|
9
|
+
@pending_count = 0
|
10
|
+
@test_count = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def ScenarioStart(scenario)
|
14
|
+
$stdout.puts scenario.file_name + ": "
|
15
|
+
end
|
16
|
+
|
17
|
+
def ScenarioComplete(scenario)
|
18
|
+
$stdout.puts ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def Indent(depth)
|
22
|
+
(1..depth).each do
|
23
|
+
$stdout.print "\t"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
5
27
|
def PrintItem(result, depth)
|
6
28
|
Indent(depth)
|
7
29
|
|
@@ -34,57 +56,96 @@ module Sapphire
|
|
34
56
|
end
|
35
57
|
end
|
36
58
|
|
37
|
-
def
|
59
|
+
def InsertLineBreak()
|
38
60
|
$stdout.puts ""
|
39
61
|
end
|
40
62
|
|
41
|
-
def
|
42
|
-
|
63
|
+
def TestStarted(test)
|
64
|
+
@test_count = @test_count + 1
|
43
65
|
end
|
44
66
|
|
45
|
-
def
|
46
|
-
|
67
|
+
def TestPassed(test)
|
68
|
+
@passing_count = @passing_count + 1
|
69
|
+
$stdout.print ".".green
|
47
70
|
end
|
48
71
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
$stdout.
|
53
|
-
$stdout.puts "Passing: " + self.passing_count.to_s.green
|
54
|
-
$stdout.puts "Failing: " + self.failing_count.to_s.red
|
55
|
-
$stdout.puts "Pending: " + self.pending_count.to_s.yellow
|
72
|
+
def TestFailed(test)
|
73
|
+
@failing_count = @failing_count + 1
|
74
|
+
Add test
|
75
|
+
$stdout.print "F".red
|
56
76
|
end
|
57
77
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
78
|
+
def TestPending(test)
|
79
|
+
@pending_count = @pending_count + 1
|
80
|
+
Add test
|
81
|
+
$stdout.print "*".yellow
|
82
|
+
end
|
83
|
+
|
84
|
+
def Add(r)
|
85
|
+
result_passes = r.type == "pass"
|
86
|
+
|
87
|
+
if !result_passes and (r.item.is_a? Given or r.item.is_a? When or r.item.is_a? Background)
|
88
|
+
@not_passing = @not_passing.merge({ r => r })
|
89
|
+
elsif !result_passes and (r.item.is_a? And or r.item.parent.is_a? Given)
|
90
|
+
@not_passing = @not_passing.merge({ r.parent => r.parent })
|
91
|
+
elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? When)
|
92
|
+
@not_passing = @not_passing.merge({ r.parent => r.parent })
|
93
|
+
elsif !result_passes and (r.item.is_a? Then)
|
94
|
+
@not_passing = @not_passing.merge({ r.parent => r.parent })
|
95
|
+
elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? Then)
|
96
|
+
@not_passing = @not_passing.merge({ r.parent.parent => r.parent.parent })
|
61
97
|
end
|
98
|
+
|
62
99
|
end
|
63
100
|
|
64
|
-
def
|
101
|
+
def OutputResults()
|
65
102
|
$stdout.puts ""
|
66
|
-
end
|
67
103
|
|
68
|
-
|
104
|
+
@not_passing.keys.each do |key|
|
105
|
+
self.PrintResult @not_passing[key]
|
106
|
+
end
|
69
107
|
|
108
|
+
$stdout.puts ""
|
109
|
+
$stdout.puts "Finished in " + (@end - @start).round(2).to_s + " seconds."
|
110
|
+
$stdout.puts "Test Count: " + @test_count.to_s
|
111
|
+
$stdout.puts "Passing: " + @passing_count.to_s.green
|
112
|
+
$stdout.puts "Failing: " + @failing_count.to_s.red
|
113
|
+
$stdout.puts "Pending: " + @pending_count.to_s.yellow
|
70
114
|
end
|
71
115
|
|
72
|
-
def
|
73
|
-
|
74
|
-
end
|
116
|
+
def Output(result, depth)
|
75
117
|
|
76
|
-
|
118
|
+
self.PrintItem(result, depth)
|
77
119
|
|
120
|
+
result.results.each do |sub_result|
|
121
|
+
self.Output(sub_result, depth+1)
|
122
|
+
end
|
78
123
|
end
|
79
124
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
125
|
+
def PrintResult(entry)
|
126
|
+
if entry.item.is_a? Background
|
127
|
+
self.InsertLineBreak
|
128
|
+
self.Output entry, 0
|
129
|
+
self.InsertLineBreak
|
130
|
+
elsif entry.item.is_a? Given
|
131
|
+
self.InsertLineBreak
|
132
|
+
self.Output entry, 1
|
133
|
+
self.InsertLineBreak
|
134
|
+
elsif entry.item.is_a? When
|
135
|
+
self.PrintItem entry.parent, 0
|
136
|
+
self.Output entry, 1
|
137
|
+
self.InsertLineBreak
|
138
|
+
else
|
139
|
+
self.PrintResult entry.parent
|
140
|
+
end
|
84
141
|
end
|
85
142
|
|
86
143
|
def BeginTesting
|
144
|
+
@start = DateTime.now
|
145
|
+
end
|
87
146
|
|
147
|
+
def TestingComplete
|
148
|
+
@end = DateTime.now
|
88
149
|
end
|
89
150
|
|
90
151
|
end
|
@@ -8,20 +8,20 @@ module Sapphire
|
|
8
8
|
if(self.value.is_a? Pending)
|
9
9
|
result = ResultTree.new(self.text, TestResult.new("pending", self, "Pending", "", Time.now - start))
|
10
10
|
self.AddResult(result)
|
11
|
-
reporter.
|
11
|
+
reporter.TestPending result
|
12
12
|
return
|
13
13
|
end
|
14
14
|
self.block.call
|
15
15
|
result = ResultTree.new(self.text, TestResult.new("pass", self, "Success", "", Time.now - start))
|
16
16
|
self.AddResult(result)
|
17
|
-
reporter.
|
17
|
+
reporter.TestPassed result
|
18
18
|
rescue => msg
|
19
19
|
stack = msg.backtrace
|
20
20
|
message = msg.messages if (msg.is_a? ExpectationException)
|
21
21
|
message ||= msg.message
|
22
22
|
result = ResultTree.new(self.text, TestResult.new("fail", self, message, stack, Time.now - start))
|
23
23
|
self.AddResult(result)
|
24
|
-
reporter.
|
24
|
+
reporter.TestFailed result
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -2,49 +2,301 @@ module Sapphire
|
|
2
2
|
module Testing
|
3
3
|
class HtmlReporter < Reporter
|
4
4
|
|
5
|
-
def
|
6
|
-
|
5
|
+
def initialize()
|
6
|
+
@failures = []
|
7
|
+
@example_group_number = 0
|
8
|
+
@passing_count = 0
|
9
|
+
@failing_count = 0
|
10
|
+
@pending_count = 0
|
11
|
+
@test_count = 0
|
7
12
|
end
|
8
13
|
|
9
|
-
def
|
14
|
+
def TestStarted(test)
|
10
15
|
|
11
16
|
end
|
12
17
|
|
13
|
-
def
|
14
|
-
|
18
|
+
def TestPassed(test)
|
19
|
+
@passing_count = @passing_count + 1
|
20
|
+
$stdout.puts " <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{test.text}</span></dd>"
|
15
21
|
end
|
16
22
|
|
17
|
-
def
|
23
|
+
def TestFailed(test)
|
18
24
|
|
19
|
-
|
25
|
+
failure_style = 'failed'
|
26
|
+
$stdout.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
|
27
|
+
@header_red = true
|
28
|
+
$stdout.puts " <script type=\"text/javascript\">makeRed('example_group_#{@example_group_number}');</script>" unless @example_group_red
|
29
|
+
@example_group_red = true
|
30
|
+
$stdout.puts " <dd class=\"spec #{failure_style}\">"
|
31
|
+
$stdout.puts " <span class=\"failed_spec_name\">#{test.text}</span>"
|
32
|
+
$stdout.puts " <div class=\"failure\" id=\"failure_#{@test_count}\">"
|
20
33
|
|
21
|
-
|
34
|
+
if test.messages.is_a? Array
|
35
|
+
message_block = ""
|
36
|
+
test.messages.each do |message|
|
37
|
+
message_block += message + "<br>"
|
38
|
+
end
|
39
|
+
$stdout.puts " <div class=\"message\"><pre>#{message_block}</pre></div>"
|
40
|
+
else
|
41
|
+
$stdout.puts " <div class=\"message\"><pre>#{test.messages}</pre></div>"
|
42
|
+
end
|
22
43
|
|
23
|
-
|
44
|
+
test.stack.each do |line|
|
45
|
+
if (!line.include? "sapphire")
|
46
|
+
$stdout.puts " <div class=\"backtrace\"><pre>#{line}</pre></div>"
|
47
|
+
end
|
48
|
+
end
|
24
49
|
|
25
|
-
|
50
|
+
$stdout.puts " </div>"
|
51
|
+
$stdout.puts " </dd>"
|
52
|
+
end
|
26
53
|
|
54
|
+
def TestPending(test)
|
55
|
+
$stdout.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
|
56
|
+
$stdout.puts " <script type=\"text/javascript\">makeYellow('example_group_#{@example_group_number}');</script>" unless @example_group_red
|
57
|
+
$stdout.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{test.text} (PENDING: ### Not Yet Implemented ###)</span></dd>"
|
27
58
|
end
|
28
59
|
|
29
|
-
def
|
60
|
+
def TestingComplete
|
61
|
+
@end = Time.now
|
62
|
+
|
63
|
+
totals = "#{@test_count} example#{'s' unless @test_count == 1}, #{@failure_count} failure#{'s' unless @failure_count == 1}"
|
64
|
+
totals << ", #{@pending_count} pending" if @pending_count > 0
|
30
65
|
|
66
|
+
$stdout.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{(@end - @start).round(2).to_s} seconds</strong>\";</script>"
|
67
|
+
$stdout.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
|
68
|
+
$stdout.puts "</div>"
|
69
|
+
$stdout.puts "</div>"
|
70
|
+
$stdout.puts "</body>"
|
71
|
+
$stdout.puts "</html>"
|
31
72
|
end
|
32
73
|
|
33
|
-
def
|
74
|
+
def BeginTesting
|
75
|
+
@start = Time.now
|
76
|
+
$stdout.puts html_header
|
77
|
+
$stdout.puts report_header
|
78
|
+
end
|
34
79
|
|
80
|
+
def ScenarioStart(scenario)
|
81
|
+
@example_group_red = false
|
82
|
+
@example_group_number += 1
|
83
|
+
unless @example_group_number == 1
|
84
|
+
$stdout.puts " </dl>"
|
85
|
+
$stdout.puts "</div>"
|
86
|
+
end
|
87
|
+
$stdout.puts "<div class=\"example_group\">"
|
88
|
+
$stdout.puts " <dl>"
|
89
|
+
$stdout.puts " <dt id=\"example_group_#{@example_group_number}\">#{scenario.text}</dt>"
|
35
90
|
end
|
36
91
|
|
37
|
-
def
|
92
|
+
def OutputResults()
|
38
93
|
|
39
94
|
end
|
40
95
|
|
41
|
-
def
|
96
|
+
def ScenarioComplete(scenario)
|
42
97
|
|
43
98
|
end
|
44
99
|
|
45
|
-
def
|
100
|
+
def html_header
|
101
|
+
<<-EOF
|
102
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
103
|
+
<!DOCTYPE html
|
104
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
105
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
106
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
107
|
+
<head>
|
108
|
+
<title>RSpec results</title>
|
109
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
110
|
+
<meta http-equiv="Expires" content="-1" />
|
111
|
+
<meta http-equiv="Pragma" content="no-cache" />
|
112
|
+
<style type="text/css">
|
113
|
+
body {
|
114
|
+
margin: 0;
|
115
|
+
padding: 0;
|
116
|
+
background: #fff;
|
117
|
+
font-size: 80%;
|
118
|
+
}
|
119
|
+
</style>
|
120
|
+
<script type="text/javascript">
|
121
|
+
// <![CDATA[
|
122
|
+
#{global_scripts}
|
123
|
+
// ]]>
|
124
|
+
</script>
|
125
|
+
<style type="text/css">
|
126
|
+
#{global_styles}
|
127
|
+
</style>
|
128
|
+
</head>
|
129
|
+
<body>
|
130
|
+
EOF
|
131
|
+
end
|
46
132
|
|
47
|
-
|
133
|
+
def report_header
|
134
|
+
<<-EOF
|
135
|
+
<div class="rspec-report">
|
136
|
+
|
137
|
+
<div id="rspec-header">
|
138
|
+
<div id="label">
|
139
|
+
<h1>RSpec Code Examples</h1>
|
140
|
+
</div>
|
141
|
+
|
142
|
+
<div id="summary">
|
143
|
+
<p id="totals"> </p>
|
144
|
+
<p id="duration"> </p>
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
|
148
|
+
<div class="results">
|
149
|
+
EOF
|
150
|
+
end
|
151
|
+
|
152
|
+
def global_scripts
|
153
|
+
<<-EOF
|
154
|
+
function moveProgressBar(percentDone) {
|
155
|
+
document.getElementById("rspec-header").style.width = percentDone +"%";
|
156
|
+
}
|
157
|
+
function makeRed(element_id) {
|
158
|
+
document.getElementById(element_id).style.background = '#C40D0D';
|
159
|
+
document.getElementById(element_id).style.color = '#FFFFFF';
|
160
|
+
}
|
161
|
+
|
162
|
+
function makeYellow(element_id) {
|
163
|
+
if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
|
164
|
+
{
|
165
|
+
document.getElementById(element_id).style.background = '#FAF834';
|
166
|
+
document.getElementById(element_id).style.color = '#000000';
|
167
|
+
}
|
168
|
+
else
|
169
|
+
{
|
170
|
+
document.getElementById(element_id).style.background = '#FAF834';
|
171
|
+
document.getElementById(element_id).style.color = '#000000';
|
172
|
+
}
|
173
|
+
}
|
174
|
+
EOF
|
175
|
+
end
|
176
|
+
|
177
|
+
def global_styles
|
178
|
+
<<-EOF
|
179
|
+
#rspec-header {
|
180
|
+
background: #65C400; color: #fff; height: 4em;
|
181
|
+
}
|
182
|
+
|
183
|
+
.rspec-report h1 {
|
184
|
+
margin: 0px 10px 0px 10px;
|
185
|
+
padding: 10px;
|
186
|
+
font-family: "Lucida Grande", Helvetica, sans-serif;
|
187
|
+
font-size: 1.8em;
|
188
|
+
position: absolute;
|
189
|
+
}
|
190
|
+
|
191
|
+
#summary {
|
192
|
+
margin: 0; padding: 5px 10px;
|
193
|
+
font-family: "Lucida Grande", Helvetica, sans-serif;
|
194
|
+
text-align: right;
|
195
|
+
top: 0px;
|
196
|
+
right: 0px;
|
197
|
+
float:right;
|
198
|
+
}
|
199
|
+
|
200
|
+
#summary p {
|
201
|
+
margin: 0 0 0 2px;
|
202
|
+
}
|
203
|
+
|
204
|
+
#summary #totals {
|
205
|
+
font-size: 1.2em;
|
206
|
+
}
|
207
|
+
|
208
|
+
.example_group {
|
209
|
+
margin: 0 10px 5px;
|
210
|
+
background: #fff;
|
211
|
+
}
|
212
|
+
|
213
|
+
dl {
|
214
|
+
margin: 0; padding: 0 0 5px;
|
215
|
+
font: normal 11px "Lucida Grande", Helvetica, sans-serif;
|
216
|
+
}
|
217
|
+
|
218
|
+
dt {
|
219
|
+
padding: 3px;
|
220
|
+
background: #65C400;
|
221
|
+
color: #fff;
|
222
|
+
font-weight: bold;
|
223
|
+
}
|
224
|
+
|
225
|
+
dd {
|
226
|
+
margin: 5px 0 5px 5px;
|
227
|
+
padding: 3px 3px 3px 18px;
|
228
|
+
}
|
229
|
+
|
230
|
+
dd.spec.passed {
|
231
|
+
border-left: 5px solid #65C400;
|
232
|
+
border-bottom: 1px solid #65C400;
|
233
|
+
background: #DBFFB4; color: #3D7700;
|
234
|
+
}
|
235
|
+
|
236
|
+
dd.spec.failed {
|
237
|
+
border-left: 5px solid #C20000;
|
238
|
+
border-bottom: 1px solid #C20000;
|
239
|
+
color: #C20000; background: #FFFBD3;
|
240
|
+
}
|
241
|
+
|
242
|
+
dd.spec.not_implemented {
|
243
|
+
border-left: 5px solid #FAF834;
|
244
|
+
border-bottom: 1px solid #FAF834;
|
245
|
+
background: #FCFB98; color: #131313;
|
246
|
+
}
|
247
|
+
|
248
|
+
dd.spec.pending_fixed {
|
249
|
+
border-left: 5px solid #0000C2;
|
250
|
+
border-bottom: 1px solid #0000C2;
|
251
|
+
color: #0000C2; background: #D3FBFF;
|
252
|
+
}
|
253
|
+
|
254
|
+
.backtrace {
|
255
|
+
color: #000;
|
256
|
+
font-size: 12px;
|
257
|
+
}
|
258
|
+
|
259
|
+
a {
|
260
|
+
color: #BE5C00;
|
261
|
+
}
|
262
|
+
|
263
|
+
/* Ruby code, style similar to vibrant ink */
|
264
|
+
.ruby {
|
265
|
+
font-size: 12px;
|
266
|
+
font-family: monospace;
|
267
|
+
color: white;
|
268
|
+
background-color: black;
|
269
|
+
padding: 0.1em 0 0.2em 0;
|
270
|
+
}
|
271
|
+
|
272
|
+
.ruby .keyword { color: #FF6600; }
|
273
|
+
.ruby .constant { color: #339999; }
|
274
|
+
.ruby .attribute { color: white; }
|
275
|
+
.ruby .global { color: white; }
|
276
|
+
.ruby .module { color: white; }
|
277
|
+
.ruby .class { color: white; }
|
278
|
+
.ruby .string { color: #66FF00; }
|
279
|
+
.ruby .ident { color: white; }
|
280
|
+
.ruby .method { color: #FFCC00; }
|
281
|
+
.ruby .number { color: white; }
|
282
|
+
.ruby .char { color: white; }
|
283
|
+
.ruby .comment { color: #9933CC; }
|
284
|
+
.ruby .symbol { color: white; }
|
285
|
+
.ruby .regex { color: #44B4CC; }
|
286
|
+
.ruby .punct { color: white; }
|
287
|
+
.ruby .escape { color: white; }
|
288
|
+
.ruby .interp { color: white; }
|
289
|
+
.ruby .expr { color: white; }
|
290
|
+
|
291
|
+
.ruby .offending { background-color: gray; }
|
292
|
+
.ruby .linenum {
|
293
|
+
width: 75px;
|
294
|
+
padding: 0.1em 1em 0.2em 0;
|
295
|
+
color: #000000;
|
296
|
+
background-color: #FFFBD3;
|
297
|
+
}
|
298
|
+
EOF
|
299
|
+
end
|
48
300
|
end
|
49
301
|
end
|
50
302
|
end
|
@@ -8,133 +8,6 @@ module Sapphire
|
|
8
8
|
attr_reader :pending_count
|
9
9
|
attr_reader :time
|
10
10
|
|
11
|
-
def OutputResults()
|
12
|
-
|
13
|
-
self.GatherResults
|
14
|
-
|
15
|
-
not_passing = self.GetNotPassing
|
16
|
-
|
17
|
-
self.PrintHeader
|
18
|
-
|
19
|
-
not_passing.keys.each do |key|
|
20
|
-
self.PrePrint
|
21
|
-
self.PrintResult not_passing[key]
|
22
|
-
self.PostPrint
|
23
|
-
end
|
24
|
-
|
25
|
-
self.PrintFooter
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def Output(result, depth)
|
30
|
-
|
31
|
-
self.PrintItem(result, depth)
|
32
|
-
|
33
|
-
result.results.each do |sub_result|
|
34
|
-
self.Output(sub_result, depth+1)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def PrintResult(entry)
|
39
|
-
if entry.item.is_a? Given or entry.item.is_a? Background
|
40
|
-
self.InsertLineBreak
|
41
|
-
self.Output entry, 0
|
42
|
-
self.InsertLineBreak
|
43
|
-
elsif entry.item.is_a? When
|
44
|
-
self.PrintItem entry.parent, 0
|
45
|
-
self.Output entry, 1
|
46
|
-
self.InsertLineBreak
|
47
|
-
else
|
48
|
-
self.PrintResult entry.parent
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def GatherResults()
|
53
|
-
@test_count = 0
|
54
|
-
@passing_count = 0
|
55
|
-
@failing_count = 0
|
56
|
-
@pending_count = 0
|
57
|
-
@time = 0
|
58
|
-
|
59
|
-
Runner.instance.scenarios.each do |scenario|
|
60
|
-
item = scenario.result
|
61
|
-
@time += item.time
|
62
|
-
item.results.each do |result|
|
63
|
-
output = self.Count result
|
64
|
-
@test_count += output[:tests]
|
65
|
-
@passing_count += output[:passing]
|
66
|
-
@failing_count += output[:failing]
|
67
|
-
@pending_count += output[:pending]
|
68
|
-
@time += result.time
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def Count(result)
|
74
|
-
test_count = 1
|
75
|
-
passing_count = 0
|
76
|
-
failing_count = 0
|
77
|
-
pending_count = 0
|
78
|
-
|
79
|
-
if result.type == 'pass'
|
80
|
-
passing_count += 1
|
81
|
-
elsif result.type == 'pending'
|
82
|
-
pending_count += 1
|
83
|
-
else
|
84
|
-
failing_count += 1
|
85
|
-
end
|
86
|
-
|
87
|
-
result.results.each do |sub_result|
|
88
|
-
output = self.Count(sub_result)
|
89
|
-
|
90
|
-
test_count += output[:tests]
|
91
|
-
passing_count += output[:passing]
|
92
|
-
failing_count += output[:failing]
|
93
|
-
pending_count += output[:pending]
|
94
|
-
end
|
95
|
-
|
96
|
-
{ :tests => test_count, :passing => passing_count, :failing => failing_count, :pending => pending_count }
|
97
|
-
end
|
98
|
-
|
99
|
-
def GetNotPassing
|
100
|
-
|
101
|
-
results = {}
|
102
|
-
|
103
|
-
Runner.instance.scenarios.each do |scenario|
|
104
|
-
results = results.merge(self.RecurseResult(scenario.result))
|
105
|
-
end
|
106
|
-
|
107
|
-
results
|
108
|
-
end
|
109
|
-
|
110
|
-
def RecurseResult(result)
|
111
|
-
results = {}
|
112
|
-
|
113
|
-
result.results.each do |r|
|
114
|
-
result_passes = r.type == "pass"
|
115
|
-
if !result_passes and (r.item.is_a? Given or r.item.is_a? When or r.item.is_a? Background)
|
116
|
-
results = results.merge({ r => r })
|
117
|
-
next
|
118
|
-
elsif !result_passes and (r.item.is_a? And or r.item.parent.is_a? Given)
|
119
|
-
results = results.merge({ r.parent => r.parent })
|
120
|
-
next
|
121
|
-
elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? When)
|
122
|
-
results = results.merge({ r.parent => r.parent })
|
123
|
-
next
|
124
|
-
elsif !result_passes and (r.item.is_a? Then)
|
125
|
-
results = results.merge({ r.parent => r.parent })
|
126
|
-
next
|
127
|
-
elsif !result_passes and (r.item.is_a? And and r.parent.item.is_a? Then)
|
128
|
-
results = results.merge({ r.parent.parent => r.parent.parent })
|
129
|
-
next
|
130
|
-
else
|
131
|
-
results = results.merge(self.RecurseResult(r))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
results
|
136
|
-
end
|
137
|
-
|
138
11
|
end
|
139
12
|
end
|
140
13
|
end
|
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.4.
|
4
|
+
version: 0.4.1
|
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: 2011-
|
12
|
+
date: 2011-10-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &9401868 !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: *9401868
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &9401592 !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: *9401592
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: win32console
|
38
|
-
requirement: &
|
38
|
+
requirement: &9401244 !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: *9401244
|
47
47
|
description: An automated web acceptance test framework for non-technical resources
|
48
48
|
using selenium-wedriver.
|
49
49
|
email:
|