rspectacles 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -19
- data/lib/rspectacles/adapter/batched_redis_logger.rb +34 -0
- data/lib/rspectacles/adapter/redis_logger.rb +29 -12
- data/lib/rspectacles/app.rb +9 -4
- data/lib/rspectacles/app/public/js/exampleStream.js +11 -5
- data/lib/rspectacles/app/public/js/script.js +2 -1
- data/lib/rspectacles/app/views/index.erb +1 -1
- data/lib/rspectacles/config.rb +22 -13
- data/lib/rspectacles/formatter/batched_redis.rb +19 -0
- data/lib/rspectacles/formatter/redis.rb +12 -5
- data/lib/rspectacles/version.rb +1 -1
- data/rspectacles.gemspec +2 -2
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 003d7cba8ab931d6de4f17920e73607ef342b36a
|
4
|
+
data.tar.gz: 816b05b8c5cfd7a43f8b48ca516ec319e5e073ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67f223e3cc98eb61f017226d41885b37d014c5f49b5fbb4df68db26d6252d8d49f4878a4980b533be433974930a2c199c36f619a5bda2ab36cf2882342deebed
|
7
|
+
data.tar.gz: b21d65f9c4bdc5b9372b3c4d1c58da21ba823b9bbccf31497863dc3ab47ac95a94d81b064604869c06aea9afb220f4318838ac6e8f41b700b6fc923c3b385acb
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspectacles (0.
|
5
|
-
em-hiredis (>= 0.
|
4
|
+
rspectacles (0.2.0)
|
5
|
+
em-hiredis (>= 0.3.0)
|
6
6
|
rake
|
7
7
|
redis
|
8
|
-
sinatra (
|
8
|
+
sinatra (>= 1.4.5)
|
9
9
|
thin (>= 1.5.1)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
daemons (1.
|
14
|
+
daemons (1.2.4)
|
15
15
|
diff-lcs (1.1.3)
|
16
|
-
em-hiredis (0.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
em-hiredis (0.3.1)
|
17
|
+
eventmachine (~> 1.0)
|
18
|
+
hiredis (~> 0.6.0)
|
19
|
+
eventmachine (1.2.3)
|
20
|
+
hiredis (0.6.1)
|
21
|
+
rack (1.6.8)
|
21
22
|
rack-protection (1.5.3)
|
22
23
|
rack
|
23
|
-
rake (
|
24
|
-
redis (3.
|
24
|
+
rake (12.0.0)
|
25
|
+
redis (3.3.3)
|
25
26
|
rspec (2.12.0)
|
26
27
|
rspec-core (~> 2.12.0)
|
27
28
|
rspec-expectations (~> 2.12.0)
|
@@ -30,15 +31,15 @@ GEM
|
|
30
31
|
rspec-expectations (2.12.1)
|
31
32
|
diff-lcs (~> 1.1.3)
|
32
33
|
rspec-mocks (2.12.2)
|
33
|
-
sinatra (1.4.
|
34
|
-
rack (~> 1.
|
34
|
+
sinatra (1.4.7)
|
35
|
+
rack (~> 1.5)
|
35
36
|
rack-protection (~> 1.4)
|
36
|
-
tilt (
|
37
|
-
thin (1.
|
38
|
-
daemons (>= 1.0.9)
|
39
|
-
eventmachine (>= 1.0.
|
40
|
-
rack (>= 1
|
41
|
-
tilt (
|
37
|
+
tilt (>= 1.3, < 3)
|
38
|
+
thin (1.7.0)
|
39
|
+
daemons (~> 1.0, >= 1.0.9)
|
40
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
41
|
+
rack (>= 1, < 3)
|
42
|
+
tilt (2.0.7)
|
42
43
|
|
43
44
|
PLATFORMS
|
44
45
|
ruby
|
@@ -46,3 +47,6 @@ PLATFORMS
|
|
46
47
|
DEPENDENCIES
|
47
48
|
rspec
|
48
49
|
rspectacles!
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
1.14.6
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rspectacles/adapter/redis_logger'
|
2
|
+
|
3
|
+
module RSpectacles
|
4
|
+
module Adapter
|
5
|
+
class BatchedRedisLogger < RedisLogger
|
6
|
+
def queued_messages
|
7
|
+
@queued_messages ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def stop
|
11
|
+
super
|
12
|
+
flush_queue
|
13
|
+
end
|
14
|
+
|
15
|
+
def batch_size
|
16
|
+
config.batch_size
|
17
|
+
end
|
18
|
+
|
19
|
+
def queue(message)
|
20
|
+
puts test_run_key, message
|
21
|
+
queued_messages << message
|
22
|
+
end
|
23
|
+
|
24
|
+
def flush_queue
|
25
|
+
queued_messages.each do |message|
|
26
|
+
redis.publish config.pubsub_channel_name, message
|
27
|
+
redis.lpush test_run_key, message
|
28
|
+
end
|
29
|
+
|
30
|
+
@queued_messages = []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -6,10 +6,11 @@ require 'json'
|
|
6
6
|
module RSpectacles
|
7
7
|
module Adapter
|
8
8
|
class RedisLogger
|
9
|
-
attr_reader :redis
|
9
|
+
attr_reader :redis, :test_run_key
|
10
10
|
|
11
|
-
def initialize
|
12
|
-
@redis = ::Redis.new host: uri.host, port: uri.port, password: uri.password
|
11
|
+
def initialize(test_run_key: nil)
|
12
|
+
@redis = ::Redis.new host: uri.host, port: uri.port, password: uri.password, username: uri.user
|
13
|
+
@test_run_key = test_run_key || config.last_run_primary_key
|
13
14
|
end
|
14
15
|
|
15
16
|
def config
|
@@ -24,25 +25,41 @@ module RSpectacles
|
|
24
25
|
redis.del config.last_run_primary_key
|
25
26
|
end
|
26
27
|
|
28
|
+
def stop
|
29
|
+
log 'status:stop'
|
30
|
+
end
|
31
|
+
|
32
|
+
def start
|
33
|
+
log 'status:start'
|
34
|
+
end
|
35
|
+
|
36
|
+
def message(text)
|
37
|
+
log "message:#{text}"
|
38
|
+
end
|
39
|
+
|
27
40
|
def log(message)
|
28
|
-
|
29
|
-
redis.lpush config.last_run_primary_key, message
|
41
|
+
queue "#{test_run_key}:#{message}"
|
30
42
|
end
|
31
43
|
|
32
44
|
def log_formatted(example)
|
33
45
|
message = format_example(example)
|
46
|
+
queue message
|
47
|
+
end
|
48
|
+
|
49
|
+
def queue(message)
|
34
50
|
redis.publish config.pubsub_channel_name, message
|
35
|
-
redis.lpush
|
51
|
+
redis.lpush test_run_key, message
|
36
52
|
end
|
37
53
|
|
38
54
|
def format_example(example)
|
39
55
|
{
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
56
|
+
rspec_run: test_run_key,
|
57
|
+
description: example.description,
|
58
|
+
full_description: example.full_description,
|
59
|
+
status: example.execution_result.status,
|
60
|
+
duration: example.execution_result.run_time,
|
61
|
+
file_path: example.metadata[:file_path],
|
62
|
+
line_number: example.metadata[:line_number]
|
46
63
|
}.to_json
|
47
64
|
end
|
48
65
|
end
|
data/lib/rspectacles/app.rb
CHANGED
@@ -26,10 +26,15 @@ module RSpectacles
|
|
26
26
|
end
|
27
27
|
|
28
28
|
uri = URI.parse config.redis_uri
|
29
|
-
redis = Redis.new host: uri.host, port: uri.port
|
29
|
+
redis = Redis.new host: uri.host, port: uri.port, password: uri.password, username: uri.user
|
30
30
|
|
31
31
|
# Routes
|
32
|
-
get '/' do
|
32
|
+
get '/watch/:key' do
|
33
|
+
erb :index
|
34
|
+
end
|
35
|
+
|
36
|
+
get '/watch' do
|
37
|
+
params['key'] = config.last_run_primary_key
|
33
38
|
erb :index
|
34
39
|
end
|
35
40
|
|
@@ -40,8 +45,8 @@ module RSpectacles
|
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
43
|
-
get '/last' do
|
44
|
-
redis.lrange(
|
48
|
+
get '/last/:key' do
|
49
|
+
redis.lrange(params['key'], 0, -1).to_json
|
45
50
|
end
|
46
51
|
|
47
52
|
# pubsub and streaming - EventMachine support only
|
@@ -2,7 +2,7 @@
|
|
2
2
|
define(['riffle'], function (riffle) {
|
3
3
|
'use strict';
|
4
4
|
|
5
|
-
return function streams(serverUri, ajaxUri) {
|
5
|
+
return function streams(serverUri, ajaxUri, currentRun) {
|
6
6
|
var stream = riffle.stream
|
7
7
|
, me
|
8
8
|
, serverEvents
|
@@ -12,6 +12,8 @@ define(['riffle'], function (riffle) {
|
|
12
12
|
, each
|
13
13
|
, stringEvents
|
14
14
|
, allEvents
|
15
|
+
, allExamples
|
16
|
+
, scopedExamples
|
15
17
|
, eventToString
|
16
18
|
;
|
17
19
|
|
@@ -70,12 +72,16 @@ define(['riffle'], function (riffle) {
|
|
70
72
|
stringEvents = eventToString.input(serverEvents);
|
71
73
|
ajaxEvents = each.input(ajaxStream(ajaxUri).invoke());
|
72
74
|
allEvents = stream().input(stringEvents, ajaxEvents);
|
75
|
+
allExamples = toJson.input(matching(/^\{/).input(allEvents));
|
76
|
+
scopedExamples = stream(function (o, i) {
|
77
|
+
if (i.rspec_run === currentRun) { o(i); }
|
78
|
+
}).input(allExamples);
|
73
79
|
|
74
80
|
return me = {
|
75
|
-
message: matching(
|
76
|
-
, start: matching(
|
77
|
-
, stop: matching(
|
78
|
-
, example: batched().input(
|
81
|
+
message: matching(new RegExp('^' + currentRun + ':message:')).input(stringEvents)
|
82
|
+
, start: matching(new RegExp('^' + currentRun + ':status:start')).input(stringEvents)
|
83
|
+
, stop: matching(new RegExp('^' + currentRun + ':status:stop')).input(stringEvents)
|
84
|
+
, example: batched().input(scopedExamples)
|
79
85
|
};
|
80
86
|
};
|
81
87
|
});
|
@@ -6,7 +6,8 @@ require(['chart', 'exampleStream'], function (chart, examples) {
|
|
6
6
|
bodyEl = document.querySelector('body')
|
7
7
|
, uri = bodyEl.dataset.streamUrl
|
8
8
|
, ajaxUri = bodyEl.dataset.lastUrl
|
9
|
-
,
|
9
|
+
, currentRun = bodyEl.dataset.currentRun
|
10
|
+
, streams = examples(uri, ajaxUri, currentRun)
|
10
11
|
, c = chart()
|
11
12
|
;
|
12
13
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<title>RSpectacles</title>
|
6
6
|
<link rel='stylesheet' href='<%= versioned_stylesheet 'style' %>' />
|
7
7
|
</head>
|
8
|
-
<body data-stream-url=<%= url '/stream' %> data-last-url=<%= url
|
8
|
+
<body data-stream-url=<%= url '/stream' %> data-last-url=<%= url "/last/#{params['key']}" %> data-current-run=<%= params['key'] %>>
|
9
9
|
<form>
|
10
10
|
<label><input type="radio" name="mode" value="size" checked> Time</label>
|
11
11
|
<label><input type="radio" name="mode" value="count"> Count</label>
|
data/lib/rspectacles/config.rb
CHANGED
@@ -1,32 +1,41 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
require 'yaml'
|
3
|
+
require 'erb'
|
3
4
|
|
4
5
|
module RSpectacles
|
5
6
|
class Config
|
6
7
|
def initialize
|
7
|
-
|
8
|
-
@opts = OpenStruct.new defaults.merge(user_options)
|
8
|
+
@opts = OpenStruct.new defaults.merge(yml || {})
|
9
9
|
end
|
10
10
|
|
11
11
|
def defaults
|
12
12
|
{
|
13
|
-
sinatra_port: 4567,
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
sinatra_port: ENV['RSPECTACLES_PORT'] || ENV['PORT'] || 4567,
|
14
|
+
batch_size: (ENV['RSPECTACLES_BATCH_SIZE'] || 100).to_i,
|
15
|
+
pubsub_channel_name: ENV['RSPECTACLES_CHANNEL'] || 'redis-rspec-examples',
|
16
|
+
last_run_primary_key: ENV['RSPECTACLES_LAST_RUN_KEY'] || 'redis-rspec-last-run',
|
17
|
+
redis_uri: ENV['RSPECTACLES_REDIS_URL'] || 'redis://127.0.0.1:6379/'
|
17
18
|
}
|
18
19
|
end
|
19
20
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
def method_missing(method, *args)
|
22
|
+
@opts.send method, *args
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def yml_path
|
28
|
+
if ENV['RSPECTACLES_CONFIG']
|
29
|
+
::File.expand_path(ENV['RSPECTACLES_CONFIG'])
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
28
|
-
def
|
29
|
-
|
33
|
+
def yml_exists?
|
34
|
+
yml_path && ::File.exist?(yml_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def yml
|
38
|
+
@yml ||= ::YAML.load(::ERB.new(IO.read(yml_path)).result) if yml_exists?
|
30
39
|
end
|
31
40
|
end
|
32
41
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rspectacles/adapter/batched_redis_logger'
|
2
|
+
require 'rspectacles/formatter/redis'
|
3
|
+
|
4
|
+
module RSpectacles
|
5
|
+
module Formatter
|
6
|
+
class BatchedRedis < RSpectacles::Formatter::Redis
|
7
|
+
RSpec::Core::Formatters.register self,
|
8
|
+
*%i(example_passed
|
9
|
+
example_failed
|
10
|
+
start
|
11
|
+
stop
|
12
|
+
message)
|
13
|
+
|
14
|
+
def logger
|
15
|
+
@logger ||= RSpectacles::Adapter::BatchedRedisLogger.new(test_run_key: current_run_key)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -16,20 +16,19 @@ module RSpectacles
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def logger
|
19
|
-
@logger ||= RSpectacles::Adapter::RedisLogger.new
|
19
|
+
@logger ||= RSpectacles::Adapter::RedisLogger.new(test_run_key: current_run_key)
|
20
20
|
end
|
21
21
|
|
22
22
|
def message(notification)
|
23
|
-
logger.
|
23
|
+
logger.message notification.message
|
24
24
|
end
|
25
25
|
|
26
26
|
def start(_)
|
27
|
-
logger.
|
28
|
-
logger.delete_last_log
|
27
|
+
logger.start
|
29
28
|
end
|
30
29
|
|
31
30
|
def stop(_)
|
32
|
-
logger.
|
31
|
+
logger.stop
|
33
32
|
end
|
34
33
|
|
35
34
|
def example_passed(notification)
|
@@ -43,6 +42,14 @@ module RSpectacles
|
|
43
42
|
def example_failed(notification)
|
44
43
|
logger.log_formatted notification.example
|
45
44
|
end
|
45
|
+
|
46
|
+
def current_run_key
|
47
|
+
ENV['CURRENT_RSPEC_RUN'] || config.last_run_primary_key
|
48
|
+
end
|
49
|
+
|
50
|
+
def config
|
51
|
+
RSpectacles.config
|
52
|
+
end
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
data/lib/rspectacles/version.rb
CHANGED
data/rspectacles.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency 'rspec'
|
24
24
|
s.add_dependency 'rake'
|
25
25
|
s.add_dependency 'thin', '>= 1.5.1'
|
26
|
-
s.add_dependency 'sinatra', '
|
26
|
+
s.add_dependency 'sinatra', '>= 1.4.5'
|
27
27
|
s.add_dependency 'redis'
|
28
|
-
s.add_dependency 'em-hiredis', '
|
28
|
+
s.add_dependency 'em-hiredis', '>= 0.3.0'
|
29
29
|
end
|
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.
|
4
|
+
version: 0.2.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:
|
11
|
+
date: 2017-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: sinatra
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.4.5
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.4.5
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: em-hiredis
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.3.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.3.0
|
97
97
|
description: Visualize rspec test running in the browser
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- bin/rspectacles
|
112
112
|
- config.ru
|
113
113
|
- lib/rspectacles.rb
|
114
|
+
- lib/rspectacles/adapter/batched_redis_logger.rb
|
114
115
|
- lib/rspectacles/adapter/redis_logger.rb
|
115
116
|
- lib/rspectacles/app.rb
|
116
117
|
- lib/rspectacles/app/helpers.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- lib/rspectacles/app/public/js/script.js
|
128
129
|
- lib/rspectacles/app/views/index.erb
|
129
130
|
- lib/rspectacles/config.rb
|
131
|
+
- lib/rspectacles/formatter/batched_redis.rb
|
130
132
|
- lib/rspectacles/formatter/legacy/redis.rb
|
131
133
|
- lib/rspectacles/formatter/redis.rb
|
132
134
|
- lib/rspectacles/version.rb
|
@@ -156,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
158
|
version: '0'
|
157
159
|
requirements: []
|
158
160
|
rubyforge_project: rspectacles
|
159
|
-
rubygems_version: 2.
|
161
|
+
rubygems_version: 2.6.11
|
160
162
|
signing_key:
|
161
163
|
specification_version: 4
|
162
164
|
summary: Visualize rspec test running in the browser
|