sbformat 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4d57ae8aa653d941b06b6c1b79ee8e26cdc222c
4
+ data.tar.gz: 4473ba167e61400b3b7e0afa8ecdeec94fa53c7b
5
+ SHA512:
6
+ metadata.gz: c51d4524b3bf6a3cc687b17cf5ad9c36483fc2ef0bb4002421d18b75c7e9518d9705a9765c4f346ed3cc20803c8e30b5ce392e8909a9bc95e504f191081cbebe
7
+ data.tar.gz: b1a41361e9cbbb44de6e5ee092bd7ad19b47cdcaf6f1ca41001bc801d4c2d76b5c543ce3b60e42ab340ede07c7a98f0e6ece2ff18a5d180d437ca9e021cf5cf3
@@ -0,0 +1,76 @@
1
+ require 'json'
2
+ require 'erb'
3
+ require 'fileutils'
4
+
5
+ class HtmlGenerator
6
+ def initialize data, externalDetails
7
+ @baseData = JSON.parse(data)
8
+ external = JSON.parse(externalDetails)
9
+ @externalDetails = external['userDetails']
10
+ end
11
+
12
+ def createHtml
13
+ summary = @baseData['summary']
14
+ currentTime = Time.now.strftime("%A, %b %d %Y %r %z")
15
+ suits = @baseData['suits']
16
+ groupNames = @baseData['groupNames']
17
+
18
+ footer = @externalDetails['footerMessage']
19
+ outPath = @externalDetails['outPath']
20
+ documentation = @externalDetails['documentation']
21
+
22
+ path = 'reports'
23
+
24
+ if(outPath != '')
25
+ path = outPath
26
+ end
27
+
28
+ Dir.mkdir(path) unless File.exists?(path)
29
+ Dir.mkdir(path + '/refs') unless File.exists?(path + '/refs')
30
+
31
+ cssFile = File.expand_path(File.dirname(__FILE__)) + "/refs/main.min.css"
32
+ jsFile = File.expand_path(File.dirname(__FILE__)) + "/refs/main.min.js"
33
+
34
+ File.open path + "/refs/main.min.css", "w" do |c|
35
+ c << IO.read(cssFile)
36
+ end
37
+
38
+ File.open path + "/refs/main.min.js", "w" do |c|
39
+ c << IO.read(jsFile)
40
+ end
41
+
42
+ templateFile = File.expand_path(File.dirname(__FILE__)) + "/index.erb"
43
+ File.open path + "/index.html", "w" do |f|
44
+ f << ERB.new(IO.read(templateFile), nil, '>', 'output').result(binding)
45
+ end
46
+
47
+ File.open path + "/summary.json", "w" do |f|
48
+ f.write summary.to_json
49
+ end
50
+
51
+ puts "\n"
52
+ puts "---------------------------------------------------------"
53
+ puts "Total Suits : #{summary['groupCount']}"
54
+ puts "Total Tests : #{summary['testCount']}"
55
+ puts "Total Passed : #{summary['passCount']}"
56
+ puts "Total Failed : #{summary['failureCount']}"
57
+ puts "Total Pending : #{summary['pendingCount']}"
58
+ puts "Total Time Taken : #{summary['duration']}"
59
+ puts "---------------------------------------------------------"
60
+
61
+ if(documentation)
62
+ puts "=====================Exceptions=========================="
63
+ cnt = 0
64
+ @baseData['failed'].each do |failedTest|
65
+ exMessage = failedTest['exception']['message'].gsub("\n","")
66
+ exType = failedTest['exception']['type']
67
+ puts "\n#{cnt + 1}. #{failedTest['fullName']}"
68
+ puts "Exception : #{exType}"
69
+ puts "Message : #{exMessage}"
70
+ cnt = cnt + 1
71
+ puts "\n"
72
+ end
73
+ puts "========================================================="
74
+ end
75
+ end
76
+ end
data/lib/index.erb ADDED
@@ -0,0 +1,160 @@
1
+ <html>
2
+ <head>
3
+ <title>Shreyas</title>
4
+ <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
5
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400" rel="stylesheet">
6
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
7
+ <link href="./refs/main.min.css" rel="stylesheet">
8
+ <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
9
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
10
+ <script src="./refs/main.min.js"></script>
11
+ <script>
12
+ $(document).ready(function(){
13
+ initialise('<%= groupNames %>');
14
+ });
15
+ </script>
16
+ </head>
17
+ <body>
18
+ <div id="holder">
19
+ <nav id="menuHeader" class="navbar navbar-default">
20
+ <div>
21
+ <div class="navbar-header">
22
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
23
+ <span class="sr-only">Toggle navigation</span>
24
+ <span class="icon-bar"></span>
25
+ <span class="icon-bar"></span>
26
+ <span class="icon-bar"></span>
27
+ </button>
28
+ <a class="navbar-brand" href="#" onClick="openNav()"><i class="material-icons md-18 slideSide">dehaze</i></a>
29
+ <p class="navbar-text" ><%= summary['projectName'] %></p>
30
+ </div>
31
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" >
32
+ <ul class="nav navbar-nav navbar-right">
33
+ <li><p class="navbar-text"><i class="material-icons md-18" >timer</i> <%= summary['duration'] %></p></li>
34
+ <li><p class="navbar-text"><i class="material-icons md-18" style="color: lightgreen">folder</i> <%= summary['groupCount'] %></p></li>
35
+ <li><p class="navbar-text"><i class="material-icons md-18" style="color: dodgerblue">library_books</i> <%= summary['testCount'] %></p></li>
36
+ <li><p class="navbar-text"><i class="material-icons md-18" style="color: #4CAF50">done</i> <%= summary['passCount'] %></p></li>
37
+ <li><p class="navbar-text"><i class="material-icons md-18" style="color: red">clear</i> <%= summary['failureCount'] %></p></li>
38
+ <li><p class="navbar-text"><i class="material-icons md-18" style="color: orange">pan_tool</i> <%=summary['pendingCount'] %></p></li>
39
+ </ul>
40
+ </div>
41
+ </div>
42
+ </nav>
43
+ <div id="mainBody" class="container-fluid">
44
+ <a href="#" class="goTop" onClick="navigateToTop()" style="display: none;"><i class="material-icons">publish</i></a>
45
+ <div id="main">
46
+ <% suits.each do |suit| %>
47
+ <div id="Main_<%= suit['group']%>" class="suitContainer">
48
+
49
+ <div class="container">
50
+ <div class="suitTitle"><%= suit['group']%></div>
51
+ <div class="suitDetails">
52
+ <div>
53
+ <ul class="list-inline">
54
+ <li><i class="material-icons md-18" style="color: dodgerblue">library_books</i> <%= suit['testCount']%></li>
55
+ <li><i class="material-icons md-18" style="color: #4CAF50">done</i> <%= suit['passedCount']%> </li>
56
+ <li><i class="material-icons md-18" style="color: red">clear</i> <%= suit['failedCount']%></li>
57
+ <li><i class="material-icons md-18" style="color: orange">warning</i> <%= suit['pendingCount']%></li>
58
+ <li><i class="material-icons md-18" style="color: #333">timer</i> <%= suit['totalTimeForSuit']%></li>
59
+ <li><i class="material-icons md-18" style="color: #666">location_on</i> <%= suit['location']%></li>
60
+ </ul>
61
+ </div>
62
+ </div>
63
+ <div class="col-sm-12 testContainer" >
64
+ <% suit['grpTests'].each do |test|%>
65
+ <div class=" row testDetail">
66
+ <div id="Boundary_<%= test['status']%>_<%= test['id']%>" class="col-sm-12 testBoundary anchorDiv" onClick="showErrorDetails(<%= test['id']%>, '<%= test['status']%>')">
67
+ <%if test['status'] == 'passed' %>
68
+ <div class="col-sm-10"><i class="material-icons md-24" style="color: #4CAF50">check_circle</i> <%= test['fullName']%></div>
69
+ <% elsif test['status'] == 'failed' %>
70
+ <div class="col-sm-10"><i class="material-icons md-24" style="color: red">error</i> <%= test['fullName']%></div>
71
+ <% elsif test['status'] == 'pending' %>
72
+ <div class="col-sm-10"><i class="material-icons md-24" style="color: orange">warning</i> <%= test['fullName']%></div>
73
+ <%end %>
74
+ <div class="col-sm-2 alignRight"><%= RSpec::Core::Formatters::Helpers.format_duration(test['runtime'].round(3))%> <i class="material-icons md-24" style="color: silver;">timer</i></div>
75
+ <%if test['status'] == 'failed'|| test['status'] == 'pending' %>
76
+ <div class="col-sm-12 exceptionDiv ">
77
+ <%if test['status'] == 'failed'%>
78
+ <div class="col-sm-12"><%= test['exception']['type'].split('::')[2]%>: <%= test['exception']['message']%></div>
79
+ <%end %>
80
+ </div>
81
+ <div>
82
+ <div id="Exception_<%= test['id']%>" class="col-sm-12 exceptionDiv">
83
+ <div class="well errorInfo">
84
+ <div><i class="material-icons">keyboard_arrow_right</i> Location &nbsp; : <%= suit['location']%></div>
85
+ <div><i class="material-icons">keyboard_arrow_right</i> Line No &nbsp;&nbsp; : <%= test['lineNo']%></div>
86
+ <%if test['status'] == 'failed'%><div><i class="material-icons">keyboard_arrow_right</i> Type &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <%= test['exception']['type'].split('::')[2]%></div><%end %>
87
+ <%if test['status'] == 'failed'%>
88
+ <div><i class="material-icons">keyboard_arrow_right</i> Message &nbsp;&nbsp; : <%= test['exception']['message']%></div>
89
+ <% elsif test['status'] == 'pending' %>
90
+ <div><i class="material-icons">keyboard_arrow_right</i> Message &nbsp;&nbsp; : <%= test['pendingMessage']%></div>
91
+ <%end %>
92
+ </div>
93
+ <%if test['status'] == 'failed'%>
94
+ <div class="well">
95
+ <div><%= test['exception']['backtrace'] %></div>
96
+ </div>
97
+ <%end %>
98
+ </div>
99
+ </div>
100
+ <%end %>
101
+ </div>
102
+ </div>
103
+ <%end %>
104
+ </div>
105
+ </div>
106
+ </div>
107
+ <%end %>
108
+ </div>
109
+ </div>
110
+ <div class="footer">
111
+ <div class="mainFooter"><%= footer%></div>
112
+ <div class="fixedFooter">&copy; Page generated by SbFormat</div> </div>
113
+
114
+ <!-- Side Menu Starts -->
115
+ <div id="slideMenu" class="sidenav">
116
+ <div>
117
+ <div class="col-sm-12 bottomBorder">
118
+ <div class="col-sm-9 sideNavHeading"><%= summary['projectName']%></div>
119
+ <div class="col-sm-3 anchorDiv" style="text-align: right;" onclick="closeNav()"><i class="material-icons md-24" style="color: red">clear</i></div>
120
+ <br/>
121
+ <div class="col-sm-12 sideNavSubHeading"><%= currentTime%></div>
122
+ </div> <!-- Main Heading Side Menu End -->
123
+ <div class="col-sm-12 bottomBorder"> <!-- Bottom Border Nav Settings starts -->
124
+ <div class="col-sm-12 navSettings">
125
+ <div class="col-sm-8 navSettingsText"><i class="material-icons md-18" style="color: #4CAF50">done</i> Show passed</div>
126
+ <div class="col-sm-4 navSettingsText anchorDiv" style="text-align: right;" onclick="toggleCheck('P')"><i id="chkPass" class="material-icons md-24" style="color: gray"></i></div>
127
+ </div>
128
+ <div class="col-sm-12 navSettings">
129
+ <div class="col-sm-8 navSettingsText"><i class="material-icons md-18" style="color: red">clear</i> Show failed</div>
130
+ <div class="col-sm-4 navSettingsText anchorDiv" style="text-align: right;" onclick="toggleCheck('F')"><i id="chkFail" class="material-icons md-24" style="color: gray"></i></div>
131
+ </div>
132
+ <div class="col-sm-12 navSettings">
133
+ <div class="col-sm-8 navSettingsText"><i class="material-icons md-18" style="color: orange">pan_tool</i> Show pending</div>
134
+ <div class="col-sm-4 navSettingsText anchorDiv" style="text-align: right;" onclick="toggleCheck('W')"><i id="chkPending" class="material-icons md-24" style="color: gray"></i></div>
135
+ </div>
136
+ </div> <!-- Bottom Border Nav Settings End -->
137
+ <div class="col-sm-12 bottomBorder"> <!-- Bottom Border Suits Names starts -->
138
+ <div>
139
+ <% suits.each do |suit| %>
140
+ <a href="#" class="col-sm-12 navSuits">
141
+
142
+ <%if suit['status'] == 'P' %>
143
+ <div class="col-sm-1 "><i class="material-icons md-18" style="color: #4CAF50">done_all</i></div>
144
+ <% elsif suit['status'] == 'F' %>
145
+ <div class="col-sm-1 "><i class="material-icons md-18" style="color: red">error</i></div>
146
+ <% elsif suit['status'] == 'W' || suit['status'] == 'FW' %>
147
+ <div class="col-sm-1 "><i class="material-icons md-18" style="color: orange">warning</i></div>
148
+ <%end %>
149
+ <div class="col-sm-10" onClick="navigateToSuit('<%= suit['group']%>')"><%= suit['group']%></div>
150
+
151
+ </a>
152
+ <%end %>
153
+ </div>
154
+ </div> <!-- Bottom Border Suits Names Ends -->
155
+ </div>
156
+ </div>
157
+ <!-- Side Menu Ends -->
158
+ </div>
159
+ </body>
160
+ </html>
@@ -0,0 +1 @@
1
+ #mainBody,body{background:#F2F2F2}.sidenav,.testDetail{border-right:1px solid #f5f5f5}body{font-family:'Open Sans',sans-serif;height:100%}#holder{min-height:100%;position:relative}#mainBody{padding-bottom:100px}.navbar-default .navbar-collapse,.navbar-header{background-color:#45555D}.container-fluid{background-color:#fff}.navbar-default .navbar-brand,.navbar-default .navbar-text,.slideSide,.slideSide:active,.slideSide:focus,.slideSide:hover{color:#fff}.material-icons{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga';vertical-align:middle}.material-icons.md-14{font-size:14px}.material-icons.md-18{font-size:18px}.material-icons.md-24{font-size:24px}.material-icons.md-36{font-size:36px}.material-icons.md-48{font-size:48px}#menuHeader:after{width:0;border-bottom:4px solid silver;-webkit-animation:transit 3s forwards;-webkit-animation-direction:right;animation:transit 2s forwards;animation-direction:right}@-webkit-keyframes transit{0%{width:0}100%{width:100%}}@keyframes transit{0%{width:0}100%{width:100%}}.footer{text-align:center;bottom:0;padding:10px;left:0;position:absolute;right:0}.fixedFooter{opacity:.3;font-size:12px;color:#111}.mainFooter{font-size:15px;color:#111}.suitDetails{padding-top:8px;color:#111;font-size:12px;text-align:left}.testContainer{box-shadow:10px 10px 5px #888}.suitTitle{font-weight:700;font-size:20px}.testDetail{border-left:1px solid #f5f5f5;border-bottom:1px solid #f5f5f5;background:#fff}.testDetail:first-child{border-top:1px solid #f5f5f5}.testBoundary{border-left:5px solid #fff;padding:15px 0}.testBoundary:hover{border-left:5px solid silver}.errorBoundary,.errorBoundary:hover{border-left:5px solid red}.warningBoundary,.warningBoundary:hover{border-left:5px solid orange}.alignRight{text-align:right}.alignLeft{text-align:left}.suitContainer{margin-top:40px}.exceptionDiv{padding-top:10px;padding-left:27px;color:red;font-size:13px}.well{margin-bottom:1px;background-color:gray;color:#fafad2;font-size:13px;font-family:consolas;border-radius:0}.goTop,.goTop:hover{color:#fff;text-decoration:none}.errorInfo div{border-bottom:1px solid #8C8C8C;padding:4px 0}.errorInfo div:last-child{border-bottom:none}.goTop{position:fixed;bottom:50px;right:.5em;background-color:rgba(0,0,0,.25);font-size:12px;padding:10px;display:none;margin:0}.goTop:hover{background-color:rgba(0,0,0,.6)}.sidenav{height:100%;width:0;position:fixed;z-index:1;top:0;left:0;background-color:#fff;overflow-x:hidden;padding-top:25px;transition:.5s}.bottomBorder{border-bottom:1px solid #f5f5f5;margin-bottom:10px;padding-bottom:10px}.sideNavHeading{overflow:hidden;font-size:20px}.sideNavSubHeading{color:silver;font-size:12px;text-align:left;font-weight:lighter}.navSettingsText,.navSuits{color:#a9a9a9;font-size:13px;padding:8px 0}.anchorDiv{cursor:pointer;cursor:hand}.navSettings{background:#f5f5f5}.navSettings:nth-child(even){background-color:#fff}.navSuits{display:block;transition:.3s;text-decoration:none}.navSuits:hover{color:red}@media screen and (max-height:450px){.sidenav{padding-top:15px}.sidenav a{font-size:18px}}
@@ -0,0 +1 @@
1
+ function initialise(a){$("#chkPass").text("radio_button_checked"),$("#chkFail").text("radio_button_checked"),$("#chkPending").text("radio_button_checked");var b=JSON.parse(a);for(console.log("suits: ",b),console.log("suits: ",b.length),i=0;i<b.length;i++){var c="#"+b[i]+"Accordion";console.log("acc: ",c),$(c).text("arrow_drop_down")}var d=$('[id^="Exception_"]').get();for(i=0;i<d.length;i++){var e="#"+d[i].id;$(e).hide()}$("html, body").animate({scrollTop:0},300),showToTopButton()}function showToTopButton(){$(window).scroll(function(){$(this).scrollTop()>200?$(".goTop").fadeIn(500):$(".goTop").fadeOut(500)})}function navigateToTop(){$(".goTop").click(function(a){$("html, body").animate({scrollTop:0},slow),a.preventDefault()})}function openNav(){$("#slideMenu").width(350)}function closeNav(){$("#slideMenu").width(0)}function toggleCheck(a){if(unCheckText="radio_button_unchecked",checkText="radio_button_checked","P"===a){var b=$('[id^="Boundary_passed_"]').get();if($("#chkPass").text()===checkText)for($("#chkPass").text(unCheckText),i=0;i<b.length;i++){var c="#"+b[i].id;$(c).hide("slow")}else for($("#chkPass").text(checkText),i=0;i<b.length;i++){var c="#"+b[i].id;$(c).show("slow")}}if("F"===a){var d=$('[id^="Boundary_failed_"]').get();if($("#chkFail").text()===checkText)for($("#chkFail").text(unCheckText),i=0;i<d.length;i++){var c="#"+d[i].id;$(c).hide("slow")}else for($("#chkFail").text(checkText),i=0;i<d.length;i++){var c="#"+d[i].id;$(c).show("slow")}}if("W"===a){var e=$('[id^="Boundary_pending_"]').get();if($("#chkPending").text()===checkText)for($("#chkPending").text(unCheckText),i=0;i<e.length;i++){var c="#"+e[i].id;$(c).hide("slow")}else for($("#chkPending").text(checkText),i=0;i<e.length;i++){var c="#"+e[i].id;$(c).show("slow")}}}function navigateToSuit(a){var b="#Main_"+a,c=0;c=110==$(b).offset().top?60:$(b).offset().top,$("html,body").animate({scrollTop:c},"slow"),closeNav()}function toggleAccordion(a){downArrow="arrow_drop_down",upArrow="arrow_drop_up";var b="#"+a+"Accordion";$(b).text()==downArrow?$(b).text(upArrow):$(b).text(downArrow)}function showErrorDetails(a,b){var c="#Exception_"+a,d="#Boundary_"+a;"failed"==b&&($(d).toggleClass("errorBoundary"),$(c).toggle()),"pending"==b&&($(d).toggleClass("warningBoundary"),$(c).toggle())}
data/lib/sbformat.rb ADDED
@@ -0,0 +1,237 @@
1
+ require 'json'
2
+ require_relative 'html_generator'
3
+
4
+ class SbFormat
5
+ attr_accessor :summary
6
+ RSpec::Core::Formatters.register self, :dump_summary, :close, :example_passed, :example_failed, :example_pending, :dump_pending, :dump_failures
7
+
8
+ def initialize output
9
+ @output = output
10
+ @testsb = []
11
+ @passed = []
12
+ @failed = []
13
+ @pending = []
14
+ @jsonOutput = {}
15
+ @projectName = 'SB'
16
+ @footerMessage = ''
17
+ @outPath = ''
18
+ @documentation = false
19
+ @count = 0
20
+
21
+ if File.exist?('.sbfrc')
22
+ begin
23
+ x = JSON.parse(IO.read('.sbfrc'))
24
+ if(x.has_key? 'project')
25
+ @projectName = x['project']
26
+ end
27
+
28
+ if(x.has_key? 'footer')
29
+ @footerMessage = x['footer']
30
+ end
31
+
32
+ if(x.has_key? 'outPath')
33
+ @outPath = x['outPath']
34
+ end
35
+
36
+ if(x.has_key? 'document')
37
+ @documentation = x['document'].eql?('true') ? true : false
38
+ end
39
+ rescue
40
+ puts 'rescue block'
41
+ end
42
+ else
43
+ puts false
44
+ end
45
+ end
46
+
47
+ def example_passed notification # ExampleNotification
48
+ test = {
49
+ group: notification.example.example_group,
50
+ name: notification.example.description,
51
+ fullName: notification.example.full_description,
52
+ status: notification.example.execution_result.status.to_s,
53
+ location: notification.example.location.split(":")[0],
54
+ lineNo: notification.example.location.split(":")[1],
55
+ runtime: notification.example.execution_result.run_time,
56
+ pendingMessage: notification.example.execution_result.pending_message,
57
+ id: @count + 1
58
+ }
59
+ @count = @count + 1
60
+ @testsb.push(test)
61
+ @passed.push(test)
62
+ print "."
63
+
64
+ end
65
+
66
+ def example_failed notification # FailedExampleNotification
67
+ test = {
68
+ group: notification.example.example_group,
69
+ name: notification.example.description,
70
+ fullName: notification.example.full_description,
71
+ status: notification.example.execution_result.status.to_s,
72
+ location: notification.example.location.split(":")[0],
73
+ lineNo: notification.example.location.split(":")[1],
74
+ runtime: notification.example.execution_result.run_time,
75
+ id: @count + 1,
76
+ exception: {
77
+ type: notification.example.exception.class,
78
+ message: notification.example.execution_result.exception.message,
79
+ backtrace: notification.example.exception.backtrace
80
+ },
81
+ pendingMessage: notification.example.execution_result.pending_message
82
+ }
83
+ @count = @count + 1
84
+ @testsb.push(test)
85
+ @failed.push(test)
86
+ print "F"
87
+ end
88
+
89
+ def example_pending notification # ExampleNotification
90
+ test = {
91
+ group: notification.example.example_group,
92
+ name: notification.example.description,
93
+ fullName: notification.example.full_description,
94
+ status: notification.example.execution_result.status.to_s,
95
+ location: notification.example.location.split(":")[0],
96
+ lineNo: notification.example.location.split(":")[1],
97
+ runtime: notification.example.execution_result.run_time,
98
+ pendingMessage: notification.example.execution_result.pending_message,
99
+ id: @count + 1
100
+ }
101
+ @count = @count + 1
102
+ @testsb.push(test)
103
+ @pending.push(test)
104
+ print "*"
105
+ end
106
+
107
+ def dump_summary notification # SummaryNotification
108
+ groupArray = @testsb.map{ |a|
109
+ {
110
+ group: a[:group].to_s.split('::')[2],
111
+ status: a[:status],
112
+ location: a[:location],
113
+ runtime: a[:runtime],
114
+ id: a[:id]
115
+ }
116
+ }
117
+
118
+
119
+ groupNames = groupArray.map{|a| a[:group]}.uniq
120
+ suits = groupNames.map do |g|
121
+ status = 'P'
122
+ passCount = 0;
123
+ failCount = 0;
124
+ pendCount = 0;
125
+ count = 0
126
+ totalTime = 0
127
+ location = ''
128
+ id = 0
129
+
130
+ groupArray.each do |c|
131
+ if c[:group] == g
132
+ count = count + 1
133
+ location = c[:location]
134
+ totalTime = totalTime + c[:runtime]
135
+ id = c[:id]
136
+
137
+ if c[:status] == 'pending'
138
+ pendCount = pendCount + 1
139
+
140
+ if status == 'P'
141
+ status = 'W'
142
+ elsif status == 'F'
143
+ status = 'FW'
144
+ end
145
+ elsif c[:status] == 'failed'
146
+ failCount = failCount + 1
147
+
148
+ if status == 'P'
149
+ status = 'F'
150
+ elsif status == 'W'
151
+ status = 'FW'
152
+ end
153
+ else
154
+ passCount = passCount + 1
155
+ end
156
+ end
157
+ end
158
+
159
+ groupTests = @testsb.select{|y| y[:group].to_s.split('::')[2] == g}
160
+
161
+ {
162
+ group: g,
163
+ status: status,
164
+ location: location,
165
+ testCount: count,
166
+ passedCount: passCount,
167
+ failedCount: failCount,
168
+ pendingCount: pendCount,
169
+ totalTimeForSuit: RSpec::Core::Formatters::Helpers.format_duration(totalTime.round(3)),
170
+ grpTests: groupTests,
171
+ id: id
172
+ }
173
+ end
174
+
175
+ summary = {
176
+ duration: RSpec::Core::Formatters::Helpers.format_duration(notification.duration.round(3)),
177
+ groupCount: suits.length,
178
+ testCount: notification.example_count,
179
+ pendingCount: notification.pending_count,
180
+ failureCount: notification.failure_count,
181
+ passCount: notification.example_count - ( notification.pending_count + notification.failure_count),
182
+ projectName: @projectName
183
+ }
184
+ # @output << "\n\nFinished in #{RSpec::Core::Formatters::Helpers.format_duration(notification.duration)}.\n"
185
+ jo = @jsonOutput
186
+ jo[:summary] = summary
187
+ jo[:allTests] = @testsb
188
+ jo[:pending] = @pending
189
+ jo[:failed] = @failed
190
+ jo[:passed] = @passed
191
+ jo[:suits] = suits
192
+ jo[:groupNames] = groupNames
193
+
194
+ externalDetails = {}
195
+ externalDetails[:userDetails] = {
196
+ projectName: @projectName,
197
+ footerMessage: @footerMessage,
198
+ outPath: @outPath,
199
+ documentation: @documentation
200
+ }
201
+ generator = HtmlGenerator.new(jo.to_json, externalDetails.to_json)
202
+ generator.createHtml
203
+
204
+ # @output << "Wrote the file in formattor/report.json"
205
+ end
206
+
207
+ def dump_failures notification # ExamplesNotification
208
+ # @output << "\nFAILING\n\t"
209
+ # # For every failed example...
210
+ # @output << notification.failed_examples.map do |example|
211
+ # # Extract the full description of the example
212
+
213
+ # full_description = example.full_description
214
+ # # Extract the example location in the file
215
+ # location = example.location
216
+ # #- #{example.execution_result.exception.message}
217
+
218
+ # "#{example.description} - #{full_description} - #{example.execution_result.status} - #{location} - #{example.example_group} - #{example.exception.class}"
219
+ # end.join("\n\n\t")
220
+ end
221
+
222
+ def dump_pending notification # ExamplesNotification
223
+ # @output << "\n\nPENDING:\n\t"
224
+
225
+ # @output << notification.pending_examples.map {|example| example.full_description + " - " + example.location + " - #{example.execution_result.pending_message}"}.join("\n\t")
226
+ end
227
+
228
+ def close notification # NullNotification
229
+ # ARGV.each do|a|
230
+ # puts "Argument: #{a}"
231
+ # end
232
+ end
233
+ end
234
+
235
+
236
+
237
+
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sbformat
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shreyas Bande
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.4'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.4'
47
+ description: Formats the rspec results beautifully in html
48
+ email: shreyas.bande@abc
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/html_generator.rb
54
+ - lib/index.erb
55
+ - lib/refs/main.min.css
56
+ - lib/refs/main.min.js
57
+ - lib/sbformat.rb
58
+ homepage: https://rubygems.org/gems/example
59
+ licenses:
60
+ - SB
61
+ metadata: {}
62
+ post_install_message: Thanks for installing!
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.10
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: SB Formatter
82
+ test_files: []