rspectacles 0.0.9 → 0.1.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/rspectacles/adapter/redis_logger.rb +50 -0
- data/lib/rspectacles/app/public/js/chart.js +15 -2
- data/lib/rspectacles/app/views/index.erb +3 -0
- data/lib/rspectacles/formatter/legacy/redis.rb +48 -0
- data/lib/rspectacles/formatter/redis.rb +46 -0
- data/lib/rspectacles/version.rb +1 -1
- metadata +5 -3
- data/lib/rspectacles/redis_formatter.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f024e91d28c10cfdbd896b30f6c9e31f2959fc1
|
4
|
+
data.tar.gz: f20a35bf4feb597b6e614cfd2f74374580826fa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e36dda6c4ad7c39d0158bfe42c35126b47619866775b795f3f264738f865cc7e5d15ae9a5d716fa686d4c24fc7e455be7464754eb522344fe6d78e2df8eab87a
|
7
|
+
data.tar.gz: de35af08da4c23bf202eb08a048fd4188905fb4fea8d46f13900a89b74559d278e4b862065239d742f309eb89c4b847257fe36caa841969c65a428d906d7e35a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,8 +20,8 @@ Or in your Gemfile:
|
|
20
20
|
|
21
21
|
Then add the formatter to your .rspec file:
|
22
22
|
|
23
|
-
--require
|
24
|
-
--format RSpectacles::
|
23
|
+
--require rspectacles/formatter/redis
|
24
|
+
--format RSpectacles::Formatter::Redis
|
25
25
|
|
26
26
|
--format progress # or whatever other formatters you want to use
|
27
27
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rspectacles/config'
|
2
|
+
require 'redis'
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module RSpectacles
|
7
|
+
module Adapter
|
8
|
+
class RedisLogger
|
9
|
+
attr_reader :redis
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@redis = ::Redis.new host: uri.host, port: uri.port, password: uri.password
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
RSpectacles.config
|
17
|
+
end
|
18
|
+
|
19
|
+
def uri
|
20
|
+
@uri ||= URI.parse config.redis_uri
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete_last_log
|
24
|
+
redis.del config.last_run_primary_key
|
25
|
+
end
|
26
|
+
|
27
|
+
def log(message)
|
28
|
+
redis.publish config.pubsub_channel_name, message
|
29
|
+
redis.lpush config.last_run_primary_key, message
|
30
|
+
end
|
31
|
+
|
32
|
+
def log_formatted(example)
|
33
|
+
message = format_example(example)
|
34
|
+
redis.publish config.pubsub_channel_name, message
|
35
|
+
redis.lpush config.last_run_primary_key, message
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_example(example)
|
39
|
+
{
|
40
|
+
:description => example.description,
|
41
|
+
:full_description => example.full_description,
|
42
|
+
:status => example.execution_result.status,
|
43
|
+
:duration => example.execution_result.run_time,
|
44
|
+
:file_path => example.metadata[:file_path],
|
45
|
+
:line_number => example.metadata[:line_number]
|
46
|
+
}.to_json
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -53,6 +53,15 @@ define(['jquery', 'pathtree', 'mustache'], function ($, PathTree, Mustache) {
|
|
53
53
|
};
|
54
54
|
}
|
55
55
|
|
56
|
+
function secToMin(time) {
|
57
|
+
var pad = function (val) { return ('00' + val).slice(-2); }
|
58
|
+
, min = parseInt(time / 60)
|
59
|
+
, sec = parseInt(time % 60)
|
60
|
+
;
|
61
|
+
|
62
|
+
return pad(min) + ':' + pad(sec);
|
63
|
+
}
|
64
|
+
|
56
65
|
function showDetails() {
|
57
66
|
var data = showDetails.current
|
58
67
|
, mappedData = $.extend({
|
@@ -60,14 +69,18 @@ define(['jquery', 'pathtree', 'mustache'], function ($, PathTree, Mustache) {
|
|
60
69
|
, line_number: ''
|
61
70
|
, status: ''
|
62
71
|
, duration: ''
|
63
|
-
, time_or_count: options.isCount ? 'Examples' : '
|
72
|
+
, time_or_count: options.isCount ? 'Examples' : 'ms'
|
73
|
+
, minutes: ''
|
64
74
|
, value: null
|
65
75
|
}, data)
|
66
76
|
, map
|
67
77
|
;
|
68
78
|
|
69
79
|
if (mappedData.value) {
|
70
|
-
!options.isCount
|
80
|
+
if (!options.isCount) {
|
81
|
+
mappedData.minutes = secToMin(mappedData.value);
|
82
|
+
mappedData.value = parseInt(mappedData.value * 1000);
|
83
|
+
}
|
71
84
|
}
|
72
85
|
|
73
86
|
$('.example-wrapper').html(Mustache.render(tmpl, mappedData));
|
@@ -19,10 +19,13 @@
|
|
19
19
|
<li class='{{ status }}'><span id='status'>{{ status }}</span></li>
|
20
20
|
<li><strong>Description:</strong></li>
|
21
21
|
<li class='name'>{{ name }}</li>
|
22
|
+
{{# file_path }}
|
22
23
|
<li><strong>File:</strong></li>
|
23
24
|
<li>{{ file_path }}:<span id='line_number'>{{ line_number }}</span></li>
|
25
|
+
{{/ file_path }}
|
24
26
|
<li>
|
25
27
|
<span id='value'>{{ value }}</span> <span id='time_or_count'> {{ time_or_count }}</span>
|
28
|
+
<span id='minutes'>{{# minutes }} ({{ minutes }}) {{/ minutes }}</span>
|
26
29
|
</li>
|
27
30
|
</ul>
|
28
31
|
</script>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rspec/core/formatters/base_formatter'
|
2
|
+
require 'rspectacles/adapter/redis_logger'
|
3
|
+
|
4
|
+
module RSpectacles
|
5
|
+
module Formatter
|
6
|
+
module Legacy
|
7
|
+
class Redis < RSpec::Core::Formatters::BaseFormatter
|
8
|
+
def initialize(_)
|
9
|
+
end
|
10
|
+
|
11
|
+
def logger
|
12
|
+
@logger ||= RSpectacles::Adapter::RedisLogger.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def message(message)
|
16
|
+
logger.log "message:#{message}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def start(example_count)
|
20
|
+
logger.log 'status:start'
|
21
|
+
logger.delete_last_log
|
22
|
+
end
|
23
|
+
|
24
|
+
def stop
|
25
|
+
logger.log 'status:stop'
|
26
|
+
end
|
27
|
+
|
28
|
+
def example_started(example)
|
29
|
+
end
|
30
|
+
|
31
|
+
def example_passed(example)
|
32
|
+
logger.log_formatted example
|
33
|
+
end
|
34
|
+
|
35
|
+
def example_pending(example)
|
36
|
+
logger.log_formatted example
|
37
|
+
end
|
38
|
+
|
39
|
+
def example_failed(example)
|
40
|
+
logger.log_formatted example
|
41
|
+
end
|
42
|
+
|
43
|
+
def close
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rspectacles/adapter/redis_logger'
|
2
|
+
|
3
|
+
module RSpectacles
|
4
|
+
module Formatter
|
5
|
+
class Redis
|
6
|
+
RSpec::Core::Formatters.register self,
|
7
|
+
*%i(example_passed
|
8
|
+
example_failed
|
9
|
+
start
|
10
|
+
stop
|
11
|
+
message)
|
12
|
+
|
13
|
+
def initialize(_)
|
14
|
+
end
|
15
|
+
|
16
|
+
def logger
|
17
|
+
@logger ||= RSpectacles::Adapter::RedisLogger.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def message(notification)
|
21
|
+
logger.log "message:#{notification.message}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def start(_)
|
25
|
+
logger.log 'status:start'
|
26
|
+
logger.delete_last_log
|
27
|
+
end
|
28
|
+
|
29
|
+
def stop(_)
|
30
|
+
logger.log 'status:stop'
|
31
|
+
end
|
32
|
+
|
33
|
+
def example_passed(notification)
|
34
|
+
logger.log_formatted notification.example
|
35
|
+
end
|
36
|
+
|
37
|
+
def example_pending(notification)
|
38
|
+
logger.log_formatted notification.example
|
39
|
+
end
|
40
|
+
|
41
|
+
def example_failed(notification)
|
42
|
+
logger.log_formatted notification.example
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/rspectacles/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspectacles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Wheeler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- bin/rspectacles
|
112
112
|
- config.ru
|
113
113
|
- lib/rspectacles.rb
|
114
|
+
- lib/rspectacles/adapter/redis_logger.rb
|
114
115
|
- lib/rspectacles/app.rb
|
115
116
|
- lib/rspectacles/app/helpers.rb
|
116
117
|
- lib/rspectacles/app/public/css/style.css
|
@@ -126,7 +127,8 @@ files:
|
|
126
127
|
- lib/rspectacles/app/public/js/script.js
|
127
128
|
- lib/rspectacles/app/views/index.erb
|
128
129
|
- lib/rspectacles/config.rb
|
129
|
-
- lib/rspectacles/
|
130
|
+
- lib/rspectacles/formatter/legacy/redis.rb
|
131
|
+
- lib/rspectacles/formatter/redis.rb
|
130
132
|
- lib/rspectacles/version.rb
|
131
133
|
- rspectacles.gemspec
|
132
134
|
- spec/javascripts/resources/qunit.css
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'rspec/core/formatters/base_formatter'
|
2
|
-
require 'rspectacles/config'
|
3
|
-
require 'ostruct'
|
4
|
-
require 'redis'
|
5
|
-
require 'uri'
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
module RSpectacles
|
9
|
-
class RedisFormatter < RSpec::Core::Formatters::BaseFormatter
|
10
|
-
attr_accessor :redis
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def config
|
14
|
-
RSpectacles.config
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(output)
|
19
|
-
uri = URI.parse config.redis_uri
|
20
|
-
self.redis = Redis.new host: uri.host, port: uri.port, password: uri.password
|
21
|
-
end
|
22
|
-
|
23
|
-
def message(message)
|
24
|
-
log "message:#{message}"
|
25
|
-
end
|
26
|
-
|
27
|
-
def start(example_count)
|
28
|
-
log 'status:start'
|
29
|
-
redis.del config.last_run_primary_key
|
30
|
-
end
|
31
|
-
|
32
|
-
def stop
|
33
|
-
log 'status:stop'
|
34
|
-
end
|
35
|
-
|
36
|
-
def example_started(example)
|
37
|
-
end
|
38
|
-
|
39
|
-
def example_passed(example)
|
40
|
-
log_formatted example
|
41
|
-
end
|
42
|
-
|
43
|
-
def example_pending(example)
|
44
|
-
log_formatted example
|
45
|
-
end
|
46
|
-
|
47
|
-
def example_failed(example)
|
48
|
-
log_formatted example
|
49
|
-
end
|
50
|
-
|
51
|
-
def close
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def config
|
57
|
-
self.class.config
|
58
|
-
end
|
59
|
-
|
60
|
-
def log(message)
|
61
|
-
redis.publish config.pubsub_channel_name, message
|
62
|
-
redis.lpush config.last_run_primary_key, message
|
63
|
-
end
|
64
|
-
|
65
|
-
def log_formatted(example)
|
66
|
-
message = format_example(example)
|
67
|
-
redis.publish config.pubsub_channel_name, message
|
68
|
-
redis.lpush config.last_run_primary_key, message
|
69
|
-
end
|
70
|
-
|
71
|
-
def format_example(example)
|
72
|
-
{
|
73
|
-
:description => example.description,
|
74
|
-
:full_description => example.full_description,
|
75
|
-
:status => example.execution_result[:status],
|
76
|
-
:duration => example.execution_result[:run_time],
|
77
|
-
:file_path => example.metadata[:file_path],
|
78
|
-
:line_number => example.metadata[:line_number]
|
79
|
-
}.to_json
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|