rspectacles 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6653939a622672aca5f1ba7cfe228433e1056f18
4
- data.tar.gz: b632f93328bcdf27d1839f86a5b4e43d620fe031
3
+ metadata.gz: bed36b5ed54e49e097fc5acd5c1f76a9c38f871b
4
+ data.tar.gz: fe4eb46b844447fefc22fcbf47262003f4603123
5
5
  SHA512:
6
- metadata.gz: 05fd61772ac500b9f30ecb9e50072a32fa9992e4875a950d3e2c602550d4148f76ed02cb36b57eff283016383df93604f773343cdc476d5c498f9266a76e08f3
7
- data.tar.gz: e619166af089ccb6d118240e4c8cfa41696f845b45216bee0aaacd4c9effcbafedd65d32f8cdb60c9fed544768ff7ccab975e52f7d16626f40e28ddf1efc9935
6
+ metadata.gz: d42a3ef4e41aed539941636df7ad9424a569c872c2ee70bd151746ad4b2e16027662688fea01aac6e3ecd2f4154792bbe347b178df38ae13ca5931a6f15b4ef2
7
+ data.tar.gz: 4694609c39573db2cd5d222f9ba6cf135e9c016962dd9bd15934e77e30eb33e9e6966daa8632e3b8f00f534f3c971856d4781b644d58c305bcda2872d6995842
data/.jshintrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "laxcomma": true
3
+ }
data/Gemfile.lock CHANGED
@@ -1,28 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspectacles (0.2.2)
5
- em-hiredis (>= 0.3.0)
4
+ rspectacles (0.3.0)
5
+ httparty
6
+ pg
6
7
  rake
7
- redis
8
8
  sinatra (>= 1.4.5)
9
+ sinatra-activerecord
9
10
  thin (>= 1.5.1)
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
15
+ activemodel (5.1.3)
16
+ activesupport (= 5.1.3)
17
+ activerecord (5.1.3)
18
+ activemodel (= 5.1.3)
19
+ activesupport (= 5.1.3)
20
+ arel (~> 8.0)
21
+ activesupport (5.1.3)
22
+ concurrent-ruby (~> 1.0, >= 1.0.2)
23
+ i18n (~> 0.7)
24
+ minitest (~> 5.1)
25
+ tzinfo (~> 1.1)
26
+ arel (8.0.0)
27
+ coderay (1.1.1)
28
+ concurrent-ruby (1.0.5)
14
29
  daemons (1.2.4)
15
30
  diff-lcs (1.1.3)
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)
22
- rack-protection (1.5.3)
31
+ eventmachine (1.2.5)
32
+ httparty (0.15.6)
33
+ multi_xml (>= 0.5.2)
34
+ i18n (0.8.6)
35
+ method_source (0.8.2)
36
+ minitest (5.10.3)
37
+ multi_xml (0.6.0)
38
+ mustermann (1.0.1)
39
+ pg (0.21.0)
40
+ pry (0.10.4)
41
+ coderay (~> 1.1.0)
42
+ method_source (~> 0.8.1)
43
+ slop (~> 3.4)
44
+ rack (2.0.3)
45
+ rack-protection (2.0.0)
23
46
  rack
24
47
  rake (12.0.0)
25
- redis (3.3.3)
26
48
  rspec (2.12.0)
27
49
  rspec-core (~> 2.12.0)
28
50
  rspec-expectations (~> 2.12.0)
@@ -31,20 +53,29 @@ GEM
31
53
  rspec-expectations (2.12.1)
32
54
  diff-lcs (~> 1.1.3)
33
55
  rspec-mocks (2.12.2)
34
- sinatra (1.4.7)
35
- rack (~> 1.5)
36
- rack-protection (~> 1.4)
37
- tilt (>= 1.3, < 3)
38
- thin (1.7.0)
56
+ sinatra (2.0.0)
57
+ mustermann (~> 1.0)
58
+ rack (~> 2.0)
59
+ rack-protection (= 2.0.0)
60
+ tilt (~> 2.0)
61
+ sinatra-activerecord (2.0.13)
62
+ activerecord (>= 3.2)
63
+ sinatra (>= 1.0)
64
+ slop (3.6.0)
65
+ thin (1.7.2)
39
66
  daemons (~> 1.0, >= 1.0.9)
40
67
  eventmachine (~> 1.0, >= 1.0.4)
41
68
  rack (>= 1, < 3)
42
- tilt (2.0.7)
69
+ thread_safe (0.3.6)
70
+ tilt (2.0.8)
71
+ tzinfo (1.2.3)
72
+ thread_safe (~> 0.1)
43
73
 
44
74
  PLATFORMS
45
75
  ruby
46
76
 
47
77
  DEPENDENCIES
78
+ pry
48
79
  rspec
49
80
  rspectacles!
50
81
 
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rspectacles.png)](http://badge.fury.io/rb/rspectacles)
2
2
  # RSpectacles
3
3
 
4
- RSpectacles is an in-browser visualizer and profiler for RSpec. It uses
5
- Server-Sent Events, Redis, and d3.js to render a
6
- [partition](http://bl.ocks.org/mbostock/4063423) of your specs in real time, so
4
+ RSpectacles is an in-browser visualizer and profiler for RSpec. It uses d3.js to render a
5
+ [partition](http://bl.ocks.org/mbostock/4063423) of your specs based on time to complete, so
7
6
  that you can tell at a glance where the time is spent in your test suite.
8
7
 
9
8
  ![Example Partition](viz.png)
@@ -22,24 +21,30 @@ Or in your Gemfile:
22
21
 
23
22
  Then add the formatter to your .rspec file:
24
23
 
25
- --require rspectacles/formatter/redis
26
- --format RSpectacles::Formatter::Redis
24
+ --require rspectacles/formatter/batched
25
+ --format RSpectacles::Formatter::Batched
27
26
 
28
27
  --format progress # or whatever other formatters you want to use
29
28
 
30
29
  The formatter assumes you are using RSpec3. If you use RSpec 2:
31
30
 
32
- --require rspectacles/formatter/legacy/redis
33
- --format RSpectacles::Formatter::Legacy::Redis
31
+ --require rspectacles/formatter/legacy/base
32
+ --format RSpectacles::Formatter::Legacy::Base
34
33
 
35
- ## Redis
34
+ ## Batched Formatter
36
35
 
37
- RSpectacles depends on [Redis](http://redis.io) for pubsub and persistence. You
38
- can quickly get an instance up and running by using your favorite package
39
- manager:
36
+ The `Batched` formatter is preferred, as it will send fewer web requests and will be less likely to
37
+ slow down your specs if the connection to the server is slow. You can change the batch
38
+ sizes by changing the `batch_size` in config settings.
40
39
 
41
- brew install redis
42
- redis-server
40
+ ## Storage
41
+
42
+ RSpectacles depends on ActiveRecord for persistence. You
43
+ can quickly get an instance up and running by configuring the database.yml file,
44
+ and running the standard rake commands:
45
+
46
+ rake db:create
47
+ rake db:migrate
43
48
 
44
49
  Start the server and connect to it in your browser:
45
50
 
@@ -72,27 +77,11 @@ export RSPECTACLES_CONFIG='/path/to/config/rspectacles.yml'
72
77
  And in ```rspectacles.yml```:
73
78
  ```yaml
74
79
  sinatra_port: 4567
75
- redis_uri: 'redis://127.0.0.1:6379/'
76
- pubsub_channel_name: 'redis-rspec-examples'
80
+ batch_size: 500
81
+ rspectacles_url: 'http://127.0.0.1:4567/'
77
82
  last_run_primary_key: 'redis-rspec-last-run'
78
83
  ```
79
84
 
80
- ## Realtime Results
81
-
82
- RSpectacles will attempt to stream spec results into the browser in realtime.
83
- This optional feature depends on EventMachine, and so will only work on servers
84
- with EM support. So if you mount RSpectacles on an app that uses
85
- [thin](http://code.macournoyer.com/thin/) or
86
- [rainbows](http://rainbows.rubyforge.org/) then
87
- you should be able to see the realtime results.
88
-
89
- If you use a server that doesn't support EventMachine - no sweat. You'll still
90
- be able to see the visualization. You'll just need to refresh your browser
91
- from time to time.
92
-
93
- Or you could always spin up an instance in standalone mode, which uses thin by
94
- default.
95
-
96
85
  ## Contributing
97
86
 
98
87
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
+ require 'sinatra/activerecord/rake'
1
2
  require 'bundler/gem_tasks'
3
+
4
+ namespace :db do
5
+ task :load_config do
6
+ require './lib/rspectacles/app'
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ class CreateExamplesTable < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :examples do |t|
4
+ t.string :rspec_run, null: false
5
+ t.text :properties
6
+ end
7
+
8
+ add_index :examples, :rspec_run
9
+ end
10
+ end
data/db/schema.rb ADDED
@@ -0,0 +1,24 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 20170907205819) do
14
+
15
+ # These are extensions that must be enabled in order to support this database
16
+ enable_extension "plpgsql"
17
+
18
+ create_table "examples", force: :cascade do |t|
19
+ t.string "rspec_run", null: false
20
+ t.text "properties"
21
+ t.index ["rspec_run"], name: "index_examples_on_rspec_run"
22
+ end
23
+
24
+ end
@@ -1,8 +1,8 @@
1
- require 'rspectacles/adapter/redis_logger'
1
+ require 'rspectacles/adapter/logger'
2
2
 
3
3
  module RSpectacles
4
4
  module Adapter
5
- class BatchedRedisLogger < RedisLogger
5
+ class BatchedLogger < Logger
6
6
  def queued_messages
7
7
  @queued_messages ||= []
8
8
  end
@@ -17,15 +17,18 @@ module RSpectacles
17
17
  end
18
18
 
19
19
  def queue(message)
20
+ return unless active?
20
21
  queued_messages << message
21
22
  flush_queue if queued_messages.count > batch_size
22
23
  end
23
24
 
24
25
  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
26
+ return unless active?
27
+ return unless queued_messages.size > 0
28
+
29
+ HTTParty.post(full_uri, timeout: 5,
30
+ body: { examples: queued_messages }.to_json,
31
+ headers: { 'Content-Type' => 'application/json' })
29
32
 
30
33
  @queued_messages = []
31
34
  end
@@ -1,15 +1,14 @@
1
1
  require 'rspectacles/config'
2
- require 'redis'
3
2
  require 'uri'
4
3
  require 'json'
4
+ require 'httparty'
5
5
 
6
6
  module RSpectacles
7
7
  module Adapter
8
- class RedisLogger
9
- attr_reader :redis, :test_run_key
8
+ class Logger
9
+ attr_reader :test_run_key
10
10
 
11
11
  def initialize(test_run_key: nil)
12
- @redis = ::Redis.new host: uri.host, port: uri.port, password: uri.password, username: uri.user
13
12
  @test_run_key = test_run_key || config.last_run_primary_key
14
13
  end
15
14
 
@@ -18,37 +17,33 @@ module RSpectacles
18
17
  end
19
18
 
20
19
  def uri
21
- @uri ||= URI.parse config.redis_uri
22
- end
23
-
24
- def delete_last_log
25
- redis.del config.last_run_primary_key
20
+ @uri ||= config.rspectacles_url
26
21
  end
27
22
 
28
23
  def stop
29
- log 'status:stop'
30
24
  end
31
25
 
32
26
  def start
33
- log 'status:start'
34
27
  end
35
28
 
36
- def message(text)
37
- log "message:#{text}"
29
+ def log(example)
30
+ message = format_example(example)
31
+ queue message
38
32
  end
39
33
 
40
- def log(message)
41
- queue "#{test_run_key}:#{message}"
34
+ private
35
+
36
+ def queue(message)
37
+ return unless active?
38
+ HTTParty.post(uri, timeout: 5, data: { examples: Array.wrap(message) })
42
39
  end
43
40
 
44
- def log_formatted(example)
45
- message = format_example(example)
46
- queue message
41
+ def active?
42
+ !!uri
47
43
  end
48
44
 
49
- def queue(message)
50
- redis.publish config.pubsub_channel_name, message
51
- redis.lpush test_run_key, message
45
+ def full_uri
46
+ "#{uri}/examples"
52
47
  end
53
48
 
54
49
  def format_example(example)
@@ -60,7 +55,7 @@ module RSpectacles
60
55
  duration: example.execution_result.run_time,
61
56
  file_path: example.metadata[:file_path],
62
57
  line_number: example.metadata[:line_number]
63
- }.to_json
58
+ }
64
59
  end
65
60
  end
66
61
  end
@@ -0,0 +1,7 @@
1
+ class Example < ActiveRecord::Base
2
+ serialize :properties, Hash
3
+
4
+ def as_json(*_)
5
+ properties
6
+ end
7
+ end
@@ -2,25 +2,12 @@
2
2
  define(['riffle'], function (riffle) {
3
3
  'use strict';
4
4
 
5
- return function streams(serverUri, ajaxUri, currentRun) {
5
+ return function streams(ajaxUri) {
6
6
  var stream = riffle.stream
7
- , me
8
- , serverEvents
9
- , ajaxEvents
10
- , matching
11
- , toJson
12
7
  , each
13
- , stringEvents
14
- , allEvents
15
- , allExamples
16
- , scopedExamples
17
- , eventToString
8
+ , jsonEvents
18
9
  ;
19
10
 
20
- serverEvents = stream(function (o, i) {
21
- new EventSource(serverUri).addEventListener('message', o);
22
- }).invoke();
23
-
24
11
  function ajaxStream(url, args) {
25
12
  return stream(function (o) {
26
13
  $.get(url, args, function (d) {
@@ -29,20 +16,6 @@ define(['riffle'], function (riffle) {
29
16
  });
30
17
  }
31
18
 
32
- eventToString = stream(function (o, i) {
33
- o(i.data);
34
- });
35
-
36
- matching = function (regex) {
37
- return stream(function (o, i) {
38
- if (i.match(regex)) { o(i); }
39
- });
40
- };
41
-
42
- toJson = stream(function (o, i) {
43
- o(JSON.parse(i));
44
- });
45
-
46
19
  each = stream(function (o, i) {
47
20
  i.forEach(function (item) { o(item); });
48
21
  });
@@ -69,19 +42,8 @@ define(['riffle'], function (riffle) {
69
42
  });
70
43
  }
71
44
 
72
- stringEvents = eventToString.input(serverEvents);
73
- ajaxEvents = each.input(ajaxStream(ajaxUri).invoke());
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);
45
+ jsonEvents = each.input(ajaxStream(ajaxUri).invoke());
79
46
 
80
- return me = {
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)
85
- };
47
+ return { example: batched().input(jsonEvents) };
86
48
  };
87
49
  });
@@ -4,21 +4,11 @@ require(['chart', 'exampleStream'], function (chart, examples) {
4
4
 
5
5
  var
6
6
  bodyEl = document.querySelector('body')
7
- , uri = bodyEl.dataset.streamUrl
8
- , ajaxUri = bodyEl.dataset.lastUrl
9
- , currentRun = bodyEl.dataset.currentRun
10
- , streams = examples(uri, ajaxUri, currentRun)
7
+ , ajaxUri = bodyEl.dataset.ajaxUrl
8
+ , streams = examples(ajaxUri)
11
9
  , c = chart()
12
10
  ;
13
11
 
14
- streams.start.onOutput(function (data) {
15
- c.reset();
16
- });
17
-
18
- streams.message.onOutput(function (data) {
19
- console.log('message logged', data);
20
- });
21
-
22
12
  streams.example.onOutput(function (data) {
23
13
  c.push(data);
24
14
  });
@@ -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 "/last/#{params['key']}" %> data-current-run=<%= params['key'] %>>
8
+ <body data-ajax-url=<%= url "/examples/#{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>
@@ -1,15 +1,17 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra/base'
3
3
  require 'json'
4
- require 'em-hiredis'
5
- require 'redis'
6
- require 'uri'
4
+ require 'sinatra/activerecord'
7
5
  require 'thin'
8
6
  require 'rspectacles/config.rb'
7
+ require 'rspectacles/app/models/example'
9
8
 
10
9
  module RSpectacles
11
10
  class App < Sinatra::Base
12
11
  require 'rspectacles/app/helpers'
12
+ register Sinatra::ActiveRecordExtension
13
+
14
+ set :database_file, 'config/database.yml'
13
15
 
14
16
  connections = []
15
17
  config = RSpectacles.config
@@ -25,9 +27,6 @@ module RSpectacles
25
27
  set :public, "#{dir}/app/public"
26
28
  end
27
29
 
28
- uri = URI.parse config.redis_uri
29
- redis = Redis.new host: uri.host, port: uri.port, password: uri.password, username: uri.user
30
-
31
30
  # Routes
32
31
  get '/watch/:key' do
33
32
  erb :index
@@ -38,24 +37,18 @@ module RSpectacles
38
37
  erb :index
39
38
  end
40
39
 
41
- get '/stream', :provides => 'text/event-stream' do
42
- stream :keep_open do |out|
43
- connections << out
44
- out.callback { connections.delete(out) }
45
- end
46
- end
47
-
48
- get '/last/:key' do
49
- redis.lrange(params['key'], 0, -1).to_json
40
+ get '/examples/:key' do
41
+ Example.where(rspec_run: params['key']).to_json
50
42
  end
51
43
 
52
- # pubsub and streaming - EventMachine support only
53
- EM.next_tick do
54
- emredis = EM::Hiredis.connect(uri)
44
+ post '/examples' do
45
+ payload = JSON.parse(request.body.read)
55
46
 
56
- emredis.pubsub.subscribe config.pubsub_channel_name do |message|
57
- connections.each { |out| out << "data: #{message}\n\n" }
47
+ data = payload['examples'].map do |args|
48
+ { rspec_run: args['rspec_run'], properties: args }
58
49
  end
50
+
51
+ Example.create(data)
59
52
  end
60
53
  end
61
54
  end
@@ -0,0 +1,29 @@
1
+ development:
2
+ adapter: postgresql
3
+ database: rspectacles_dev
4
+ username: postgres
5
+ pool: 5
6
+ host: localhost
7
+ timeout: 5000
8
+ variables:
9
+ statement_timeout: 3600000
10
+
11
+ test: &test
12
+ adapter: <%= ENV['DB_ADAPTER'] || 'postgresql' %>
13
+ database: rspectacles_test
14
+ username: postgres
15
+ pool: 5
16
+ host: <%= ENV['DB_HOST'] || 'localhost' %>
17
+ timeout: 5000
18
+ variables:
19
+ statement_timeout: 3600000
20
+
21
+ production: &production
22
+ adapter: postgresql
23
+ database: rspectacles_prod
24
+ username: postgres
25
+ pool: 10
26
+ host: localhost
27
+ timeout: 5000
28
+ variables:
29
+ statement_timeout: 3600000
@@ -5,16 +5,15 @@ require 'erb'
5
5
  module RSpectacles
6
6
  class Config
7
7
  def initialize
8
- @opts = OpenStruct.new defaults.merge(yml || {})
8
+ @opts = OpenStruct.new defaults.merge(yml.symbolize_keys)
9
9
  end
10
10
 
11
11
  def defaults
12
12
  {
13
13
  sinatra_port: ENV['RSPECTACLES_PORT'] || ENV['PORT'] || 4567,
14
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'] || ENV['CIRCLE_BUILD_NUM'] || 'redis-rspec-last-run',
17
- redis_uri: ENV['RSPECTACLES_REDIS_URL'] || 'redis://127.0.0.1:6379/'
15
+ last_run_primary_key: ENV['RSPECTACLES_LAST_RUN_KEY'] || ENV['CIRCLE_BUILD_NUM'] || 'rspec-last-run',
16
+ rspectacles_url: ENV['RSPECTACLES_URL']
18
17
  }
19
18
  end
20
19
 
@@ -25,9 +24,7 @@ module RSpectacles
25
24
  private
26
25
 
27
26
  def yml_path
28
- if ENV['RSPECTACLES_CONFIG']
29
- ::File.expand_path(ENV['RSPECTACLES_CONFIG'])
30
- end
27
+ ::File.expand_path(ENV['RSPECTACLES_CONFIG']) if ENV['RSPECTACLES_CONFIG']
31
28
  end
32
29
 
33
30
  def yml_exists?
@@ -35,7 +32,11 @@ module RSpectacles
35
32
  end
36
33
 
37
34
  def yml
38
- @yml ||= ::YAML.load(::ERB.new(IO.read(yml_path)).result) if yml_exists?
35
+ if yml_exists?
36
+ @yml ||= ::YAML.load(::ERB.new(IO.read(yml_path)).result)
37
+ else
38
+ {}
39
+ end
39
40
  end
40
41
  end
41
42
 
@@ -1,8 +1,8 @@
1
- require 'rspectacles/adapter/redis_logger'
1
+ require 'rspectacles/adapter/logger'
2
2
 
3
3
  module RSpectacles
4
4
  module Formatter
5
- class Redis
5
+ class Base
6
6
  RSpec::Core::Formatters.register self,
7
7
  *%i(example_passed
8
8
  example_failed
@@ -16,11 +16,10 @@ module RSpectacles
16
16
  end
17
17
 
18
18
  def logger
19
- @logger ||= RSpectacles::Adapter::RedisLogger.new(test_run_key: current_run_key)
19
+ @logger ||= RSpectacles::Adapter::Logger.new(test_run_key: current_run_key)
20
20
  end
21
21
 
22
22
  def message(notification)
23
- logger.message notification.message
24
23
  end
25
24
 
26
25
  def start(_)
@@ -32,15 +31,15 @@ module RSpectacles
32
31
  end
33
32
 
34
33
  def example_passed(notification)
35
- logger.log_formatted notification.example
34
+ logger.log notification.example
36
35
  end
37
36
 
38
37
  def example_pending(notification)
39
- logger.log_formatted notification.example
38
+ logger.log notification.example
40
39
  end
41
40
 
42
41
  def example_failed(notification)
43
- logger.log_formatted notification.example
42
+ logger.log notification.example
44
43
  end
45
44
 
46
45
  def current_run_key
@@ -1,9 +1,9 @@
1
- require 'rspectacles/adapter/batched_redis_logger'
2
- require 'rspectacles/formatter/redis'
1
+ require 'rspectacles/adapter/batched_logger'
2
+ require 'rspectacles/formatter/base'
3
3
 
4
4
  module RSpectacles
5
5
  module Formatter
6
- class BatchedRedis < RSpectacles::Formatter::Redis
6
+ class Batched < RSpectacles::Formatter::Base
7
7
  RSpec::Core::Formatters.register self,
8
8
  *%i(example_passed
9
9
  example_failed
@@ -12,7 +12,7 @@ module RSpectacles
12
12
  message)
13
13
 
14
14
  def logger
15
- @logger ||= RSpectacles::Adapter::BatchedRedisLogger.new(test_run_key: current_run_key)
15
+ @logger ||= RSpectacles::Adapter::BatchedLogger.new(test_run_key: current_run_key)
16
16
  end
17
17
  end
18
18
  end
@@ -1,45 +1,43 @@
1
1
  require 'rspec/core/formatters/base_formatter'
2
- require 'rspectacles/adapter/redis_logger'
2
+ require 'rspectacles/adapter/logger'
3
3
 
4
4
  module RSpectacles
5
5
  module Formatter
6
6
  module Legacy
7
- class Redis < RSpec::Core::Formatters::BaseFormatter
7
+ class Base < RSpec::Core::Formatters::BaseFormatter
8
8
  attr_reader :output
9
9
 
10
10
  def initialize(_)
11
11
  end
12
12
 
13
13
  def logger
14
- @logger ||= RSpectacles::Adapter::RedisLogger.new
14
+ @logger ||= RSpectacles::Adapter::Logger.new
15
15
  end
16
16
 
17
- def message(message)
18
- logger.log "message:#{message}"
17
+ def message(_message)
19
18
  end
20
19
 
21
- def start(example_count)
22
- logger.log 'status:start'
23
- logger.delete_last_log
20
+ def start(_example_count)
21
+ logger.start
24
22
  end
25
23
 
26
24
  def stop
27
- logger.log 'status:stop'
25
+ logger.stop
28
26
  end
29
27
 
30
28
  def example_started(example)
31
29
  end
32
30
 
33
31
  def example_passed(example)
34
- logger.log_formatted example
32
+ logger.log example
35
33
  end
36
34
 
37
35
  def example_pending(example)
38
- logger.log_formatted example
36
+ logger.log example
39
37
  end
40
38
 
41
39
  def example_failed(example)
42
- logger.log_formatted example
40
+ logger.log example
43
41
  end
44
42
 
45
43
  def close
@@ -1,3 +1,3 @@
1
1
  module RSpectacles
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
data/rspectacles.gemspec CHANGED
@@ -21,9 +21,11 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # specify any dependencies here; for example:
23
23
  s.add_development_dependency 'rspec'
24
+ s.add_development_dependency 'pry'
24
25
  s.add_dependency 'rake'
26
+ s.add_dependency 'pg'
27
+ s.add_dependency 'sinatra-activerecord'
25
28
  s.add_dependency 'thin', '>= 1.5.1'
26
29
  s.add_dependency 'sinatra', '>= 1.4.5'
27
- s.add_dependency 'redis'
28
- s.add_dependency 'em-hiredis', '>= 0.3.0'
30
+ s.add_dependency 'httparty'
29
31
  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.2.2
4
+ version: 0.3.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: 2017-09-02 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -25,13 +25,13 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :runtime
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -39,35 +39,35 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: thin
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.5.1
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.5.1
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: sinatra
56
+ name: pg
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.4.5
61
+ version: '0'
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
- version: 1.4.5
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: redis
70
+ name: sinatra-activerecord
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,19 +81,47 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: em-hiredis
84
+ name: thin
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.5.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.5.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: sinatra
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.4.5
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.4.5
111
+ - !ruby/object:Gem::Dependency
112
+ name: httparty
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - ">="
88
116
  - !ruby/object:Gem::Version
89
- version: 0.3.0
117
+ version: '0'
90
118
  type: :runtime
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - ">="
95
123
  - !ruby/object:Gem::Version
96
- version: 0.3.0
124
+ version: '0'
97
125
  description: Visualize rspec test running in the browser
98
126
  email:
99
127
  - mwheeler@g2crowd.com
@@ -103,6 +131,7 @@ extensions: []
103
131
  extra_rdoc_files: []
104
132
  files:
105
133
  - ".gitignore"
134
+ - ".jshintrc"
106
135
  - Gemfile
107
136
  - Gemfile.lock
108
137
  - LICENSE
@@ -110,11 +139,14 @@ files:
110
139
  - Rakefile
111
140
  - bin/rspectacles
112
141
  - config.ru
142
+ - db/migrate/20170907205819_create_examples_table.rb
143
+ - db/schema.rb
113
144
  - lib/rspectacles.rb
114
- - lib/rspectacles/adapter/batched_redis_logger.rb
115
- - lib/rspectacles/adapter/redis_logger.rb
145
+ - lib/rspectacles/adapter/batched_logger.rb
146
+ - lib/rspectacles/adapter/logger.rb
116
147
  - lib/rspectacles/app.rb
117
148
  - lib/rspectacles/app/helpers.rb
149
+ - lib/rspectacles/app/models/example.rb
118
150
  - lib/rspectacles/app/public/css/style.css
119
151
  - lib/rspectacles/app/public/js/chart.js
120
152
  - lib/rspectacles/app/public/js/d3.js
@@ -128,9 +160,10 @@ files:
128
160
  - lib/rspectacles/app/public/js/script.js
129
161
  - lib/rspectacles/app/views/index.erb
130
162
  - lib/rspectacles/config.rb
131
- - lib/rspectacles/formatter/batched_redis.rb
132
- - lib/rspectacles/formatter/legacy/redis.rb
133
- - lib/rspectacles/formatter/redis.rb
163
+ - lib/rspectacles/config/database.yml
164
+ - lib/rspectacles/formatter/base.rb
165
+ - lib/rspectacles/formatter/batched.rb
166
+ - lib/rspectacles/formatter/legacy/base.rb
134
167
  - lib/rspectacles/version.rb
135
168
  - rspectacles.gemspec
136
169
  - spec/javascripts/resources/qunit.css