rspec_profiling 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +50 -15
- data/lib/rspec_profiling.rb +5 -1
- data/lib/rspec_profiling/collectors/csv.rb +4 -0
- data/lib/rspec_profiling/collectors/psql.rb +106 -0
- data/lib/rspec_profiling/collectors/{database.rb → sql.rb} +4 -3
- data/lib/rspec_profiling/config.rb +3 -4
- data/lib/rspec_profiling/rspec.rb +6 -1
- data/lib/rspec_profiling/run.rb +13 -5
- data/lib/rspec_profiling/vcs/git.rb +15 -0
- data/lib/rspec_profiling/vcs/git_svn.rb +29 -0
- data/lib/rspec_profiling/vcs/svn.rb +15 -0
- data/lib/rspec_profiling/version.rb +1 -1
- data/lib/tasks/rspec_profiling.rake +3 -3
- data/rspec_profiling +0 -0
- data/rspec_profiling.gemspec +2 -0
- data/spec/collectors/{database_spec.rb → psql_spec.rb} +5 -5
- data/spec/collectors/sql_spec.rb +85 -0
- metadata +55 -20
- data/lib/rspec_profiling/current_commit.rb +0 -28
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZjlhZjRiMDRiYmM0NDllNTcwMjA2M2M3M2U4MDJmZTJkNmU3NTAxNw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6bc728acea2819f10b80dabdb13491eaabe8a17c
|
4
|
+
data.tar.gz: a3777e5d205c41a13d5b2d7413d8ad897cbe84d9
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NzU3YTI4MTU0YjU0NGNkOGY0NjliY2JhMWQ3ZTZmYjE5ZWE1YTcyM2NjZWRi
|
11
|
-
YzJlMThmZWU1Y2NmNmVlNjg0NzEzM2UyMzllMWEzNThkMTg5MDA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MjZlMjk0MTA2MjY3NzJhZTM2NmZmZmJlZTUwMjZmZjlmMzBiODFjNzRhNzAw
|
14
|
-
YTJjNTY1NjdiNGRiYmYwOWFiNjZhY2FkM2RhZTQyMjA1MDQ0MTU4Y2UxNTQ2
|
15
|
-
MDY1YTkwZmRhNTdiNTk3OWMxYTY4YmMyODBiNjEzN2MxMTQyYzg=
|
6
|
+
metadata.gz: fd7439d412650cdc9dc1be244d65b258f0397eed74e7ae43eaca1abd232b3d45d7a07e45668c0ff38355d4b03c204d33a31b10f6d9d0a88cecf118cbeb38eb21
|
7
|
+
data.tar.gz: ce31b48d6789a4695fd4befa270dbfc3d51dd539af4ded0822e1f34aef17d2f4851af71ce96ca6606742d075fe2c7f6f7726876fdf97f6a05fde654808875797
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rspec_profiling
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.1
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RspecProfiling
|
2
2
|
|
3
3
|
Collects profiles of RSpec test suites, enabling you to identify specs
|
4
4
|
with interesting attributes. For example, find the slowest specs, or the
|
@@ -15,7 +15,7 @@ Collected attributes include:
|
|
15
15
|
|
16
16
|
## Compatibility
|
17
17
|
|
18
|
-
|
18
|
+
RspecProfiling should work with Rails >= 3.2 and RSpec >= 2.14.
|
19
19
|
|
20
20
|
## Installation
|
21
21
|
|
@@ -46,6 +46,34 @@ bundle exec rake rspec_profiling:install
|
|
46
46
|
|
47
47
|
## Usage
|
48
48
|
|
49
|
+
### Choose a version control system
|
50
|
+
|
51
|
+
Results are collected based on the version control system employed e.g. revision or commit SHA for `svn` and `git` respectively.
|
52
|
+
|
53
|
+
#### Git
|
54
|
+
|
55
|
+
By default, RspecProfiling expects Git as the version control system.
|
56
|
+
|
57
|
+
#### Subversion
|
58
|
+
|
59
|
+
RspecProfiling can be configured to use `svn` in `config/initializers/rspec_profiling.rb`:
|
60
|
+
|
61
|
+
```Ruby
|
62
|
+
RspecProfiling.configure do |config|
|
63
|
+
config.vcs = RspecProfiling::VCS::Svn
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
#### Git / Subversion
|
68
|
+
|
69
|
+
For those with a mixed project, with some developers using `git svn` and others regular `svn`, use this configuration to detect which is being used locally and behave accordingly.
|
70
|
+
|
71
|
+
```Ruby
|
72
|
+
RspecProfiling.configure do |config|
|
73
|
+
config.vcs = RspecProfiling::VCS::GitSvn
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
49
77
|
### Choose a results collector
|
50
78
|
|
51
79
|
Results are collected just by running the specs.
|
@@ -55,7 +83,7 @@ Results are collected just by running the specs.
|
|
55
83
|
By default, profiles are collected in an SQL database. Make sure you've
|
56
84
|
run the installation rake task before attempting.
|
57
85
|
|
58
|
-
You can review results by running the
|
86
|
+
You can review results by running the RspecProfiling console.
|
59
87
|
|
60
88
|
```
|
61
89
|
bundle exec rake rspec_profiling:console
|
@@ -76,15 +104,12 @@ results.count
|
|
76
104
|
|
77
105
|
#### CSV
|
78
106
|
|
79
|
-
You can configure `
|
80
|
-
`spec_helper.rb` file.
|
107
|
+
You can configure `RspecProfiling` to collect results in a CSV in `config/initializers/rspec_profiling.rb`:
|
81
108
|
|
82
109
|
```Ruby
|
83
|
-
|
84
|
-
config.collector =
|
110
|
+
RspecProfiling.configure do |config|
|
111
|
+
config.collector = RspecProfiling::Collectors::CSV
|
85
112
|
end
|
86
|
-
|
87
|
-
require "rspec_profiling/rspec"
|
88
113
|
```
|
89
114
|
|
90
115
|
By default, the CSV is output to `cat tmp/spec_benchmarks.csv`.
|
@@ -92,12 +117,22 @@ Rerunning spec will overwrite the file. You can customize the CSV path
|
|
92
117
|
to, for example, include the sample time.
|
93
118
|
|
94
119
|
```Ruby
|
95
|
-
|
96
|
-
config.collector =
|
120
|
+
RspecProfiling.configure do |config|
|
121
|
+
config.collector = RspecProfiling::Collectors::CSV
|
97
122
|
config.csv_path = ->{ "tmp/spec_benchmark_#{Time.now.to_i}" }
|
98
123
|
end
|
124
|
+
```
|
99
125
|
|
100
|
-
|
126
|
+
#### Postgresql
|
127
|
+
|
128
|
+
You can configure `RspecProfiling` to collect results in a Postgres database
|
129
|
+
in your `spec_helper.rb` file.
|
130
|
+
|
131
|
+
```Ruby
|
132
|
+
RspecProfiling.configure do |config|
|
133
|
+
config.collector = RspecProfiling::Collectors::PSQL
|
134
|
+
config.db_path = 'profiling'
|
135
|
+
end
|
101
136
|
```
|
102
137
|
|
103
138
|
## Configuration Options
|
@@ -105,7 +140,7 @@ require "rspec_profiling/rspec"
|
|
105
140
|
Configuration is performed like this:
|
106
141
|
|
107
142
|
```Ruby
|
108
|
-
|
143
|
+
RspecProfiling.configure do |config|
|
109
144
|
config.<option> = <something>
|
110
145
|
end
|
111
146
|
```
|
@@ -115,11 +150,11 @@ end
|
|
115
150
|
- `db_path` - the location of the SQLite database file
|
116
151
|
- `table_name` - the database table name in which results are stored
|
117
152
|
- `csv_path` - the directory in which CSV files are dumped
|
153
|
+
- `collector` - collector to use
|
118
154
|
|
119
155
|
## Uninstalling
|
120
156
|
|
121
|
-
To remove the results database, run `bundle exec rake
|
122
|
-
rspec_profiling:uninstall`.
|
157
|
+
To remove the results database, run `bundle exec rake rspec_profiling:uninstall`.
|
123
158
|
|
124
159
|
## Contributing
|
125
160
|
|
data/lib/rspec_profiling.rb
CHANGED
@@ -4,7 +4,11 @@ require "rspec_profiling/config"
|
|
4
4
|
require "rspec_profiling/version"
|
5
5
|
require "rspec_profiling/run"
|
6
6
|
require "rspec_profiling/collectors/csv"
|
7
|
-
require "rspec_profiling/collectors/
|
7
|
+
require "rspec_profiling/collectors/sql"
|
8
|
+
require "rspec_profiling/collectors/psql"
|
9
|
+
require "rspec_profiling/vcs/git"
|
10
|
+
require "rspec_profiling/vcs/svn"
|
11
|
+
require "rspec_profiling/vcs/git_svn"
|
8
12
|
|
9
13
|
module RspecProfiling
|
10
14
|
class Railtie < Rails::Railtie
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require "pg"
|
2
|
+
require "active_record"
|
3
|
+
|
4
|
+
module RspecProfiling
|
5
|
+
module Collectors
|
6
|
+
class PSQL
|
7
|
+
def self.install
|
8
|
+
new.install
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.uninstall
|
12
|
+
new.uninstall
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.reset
|
16
|
+
new.results.destroy_all
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
RspecProfiling.config.db_path ||= 'rspec_profiling'
|
21
|
+
establish_connection
|
22
|
+
end
|
23
|
+
|
24
|
+
def install
|
25
|
+
return if prepared?
|
26
|
+
|
27
|
+
connection.create_table(table) do |t|
|
28
|
+
t.string :commit
|
29
|
+
t.datetime :date
|
30
|
+
t.text :file
|
31
|
+
t.integer :line_number
|
32
|
+
t.text :description
|
33
|
+
t.decimal :time
|
34
|
+
t.string :status
|
35
|
+
t.text :exception
|
36
|
+
t.integer :query_count
|
37
|
+
t.decimal :query_time
|
38
|
+
t.integer :request_count
|
39
|
+
t.decimal :request_time
|
40
|
+
t.timestamps null: true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def uninstall
|
45
|
+
connection.drop_table(table)
|
46
|
+
end
|
47
|
+
|
48
|
+
def insert(attributes)
|
49
|
+
results.create!(attributes.except(:created_at))
|
50
|
+
end
|
51
|
+
|
52
|
+
def results
|
53
|
+
@results ||= begin
|
54
|
+
establish_connection
|
55
|
+
|
56
|
+
Result.table_name = table
|
57
|
+
Result.attr_protected if Result.respond_to?(:attr_protected)
|
58
|
+
Result
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def prepared?
|
65
|
+
connection.table_exists?(table)
|
66
|
+
end
|
67
|
+
|
68
|
+
def connection
|
69
|
+
@connection ||= results.connection
|
70
|
+
end
|
71
|
+
|
72
|
+
def establish_connection
|
73
|
+
begin
|
74
|
+
PG.connect(dbname: 'postgres').exec("CREATE DATABASE #{database}")
|
75
|
+
rescue PG::DuplicateDatabase
|
76
|
+
# no op
|
77
|
+
end
|
78
|
+
|
79
|
+
Result.establish_connection(
|
80
|
+
:adapter => 'postgresql',
|
81
|
+
:database => database
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def table
|
86
|
+
RspecProfiling.config.table_name
|
87
|
+
end
|
88
|
+
|
89
|
+
def database
|
90
|
+
RspecProfiling.config.db_path
|
91
|
+
end
|
92
|
+
|
93
|
+
class Result < ActiveRecord::Base
|
94
|
+
def to_s
|
95
|
+
[description, location].join(" - ")
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def location
|
101
|
+
[file, line_number].join(":")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -3,7 +3,7 @@ require "active_record"
|
|
3
3
|
|
4
4
|
module RspecProfiling
|
5
5
|
module Collectors
|
6
|
-
class
|
6
|
+
class SQL
|
7
7
|
def self.install
|
8
8
|
new.install
|
9
9
|
end
|
@@ -17,6 +17,7 @@ module RspecProfiling
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize
|
20
|
+
RspecProfiling.config.db_path ||= 'tmp/rspec_profiling'
|
20
21
|
establish_connection
|
21
22
|
end
|
22
23
|
|
@@ -36,7 +37,7 @@ module RspecProfiling
|
|
36
37
|
t.decimal :query_time
|
37
38
|
t.integer :request_count
|
38
39
|
t.decimal :request_time
|
39
|
-
t.timestamps
|
40
|
+
t.timestamps null: true
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -70,7 +71,7 @@ module RspecProfiling
|
|
70
71
|
|
71
72
|
def establish_connection
|
72
73
|
Result.establish_connection(
|
73
|
-
:adapter =>
|
74
|
+
:adapter => 'sqlite3',
|
74
75
|
:database => database
|
75
76
|
)
|
76
77
|
end
|
@@ -5,10 +5,9 @@ module RspecProfiling
|
|
5
5
|
|
6
6
|
def self.config
|
7
7
|
@config ||= OpenStruct.new({
|
8
|
-
collector: RspecProfiling::Collectors::
|
9
|
-
|
10
|
-
table_name: 'spec_profiling_results'
|
11
|
-
csv_path: Proc.new { 'tmp/spec_benchmarks.csv' }
|
8
|
+
collector: RspecProfiling::Collectors::SQL,
|
9
|
+
vcs: RspecProfiling::VCS::Git,
|
10
|
+
table_name: 'spec_profiling_results'
|
12
11
|
})
|
13
12
|
end
|
14
13
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
require "rspec_profiling"
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
-
|
4
|
+
runner = RspecProfiling::Run.new(RspecProfiling.config.collector.new,
|
5
|
+
RspecProfiling.config.vcs.new)
|
6
|
+
|
7
|
+
config.reporter.register_listener(
|
8
|
+
runner,
|
5
9
|
:start,
|
6
10
|
:example_started,
|
7
11
|
:example_passed,
|
8
12
|
:example_failed
|
13
|
+
)
|
9
14
|
end
|
data/lib/rspec_profiling/run.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
require "rspec_profiling/example"
|
2
|
-
require "rspec_profiling/
|
2
|
+
require "rspec_profiling/vcs/git"
|
3
|
+
require "rspec_profiling/vcs/svn"
|
4
|
+
require "rspec_profiling/vcs/git_svn"
|
5
|
+
require "rspec_profiling/collectors/sql"
|
6
|
+
require "rspec_profiling/collectors/psql"
|
7
|
+
require "rspec_profiling/collectors/csv"
|
3
8
|
|
4
9
|
module RspecProfiling
|
5
10
|
class Run
|
6
|
-
def initialize(collector
|
11
|
+
def initialize(collector = RspecProfiling.config.collector.new,
|
12
|
+
vcs = RspecProfiling.config.vcs.new)
|
13
|
+
|
7
14
|
@collector = collector
|
15
|
+
@vcs = vcs
|
8
16
|
end
|
9
17
|
|
10
18
|
def start(*args)
|
@@ -19,8 +27,8 @@ module RspecProfiling
|
|
19
27
|
|
20
28
|
def example_finished(*args)
|
21
29
|
collector.insert({
|
22
|
-
commit:
|
23
|
-
date:
|
30
|
+
commit: vcs.sha,
|
31
|
+
date: vcs.time,
|
24
32
|
file: @current_example.file,
|
25
33
|
line_number: @current_example.line_number,
|
26
34
|
description: @current_example.description,
|
@@ -39,7 +47,7 @@ module RspecProfiling
|
|
39
47
|
|
40
48
|
private
|
41
49
|
|
42
|
-
attr_reader :collector
|
50
|
+
attr_reader :collector, :vcs
|
43
51
|
|
44
52
|
def start_counting_queries
|
45
53
|
ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, query|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module RspecProfiling
|
4
|
+
module VCS
|
5
|
+
class GitSvn
|
6
|
+
# returns nil if using `git svn`
|
7
|
+
def version_control
|
8
|
+
`[ -d .git/svn ] && [ x != x"$(ls -A .git/svn/)" ]`
|
9
|
+
RspecProfiling::VCS::Svn unless $CHILD_STATUS.success?
|
10
|
+
end
|
11
|
+
|
12
|
+
def sha
|
13
|
+
if version_control.nil?
|
14
|
+
`git svn info | grep "Revision" | cut -f2 -d' '`
|
15
|
+
else
|
16
|
+
`svn info -r 'HEAD' | grep "Revision" | cut -f2 -d' '`
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def time
|
21
|
+
if version_control.nil?
|
22
|
+
Time.parse `git svn info | grep "Last Changed Date" | cut -f4,5,6 -d' '`
|
23
|
+
else
|
24
|
+
Time.parse `svn info -r 'HEAD' | grep "Last Changed Date" | cut -f4,5,6 -d' '`
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
module RspecProfiling
|
4
|
+
module VCS
|
5
|
+
class Svn
|
6
|
+
def sha
|
7
|
+
`svn info -r 'HEAD' | grep "Revision" | cut -f2 -d' '`
|
8
|
+
end
|
9
|
+
|
10
|
+
def time
|
11
|
+
Time.parse `svn info -r 'HEAD' | grep "Last Changed Date" | cut -f4,5,6 -d' '`
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,16 +2,16 @@ require 'rake'
|
|
2
2
|
|
3
3
|
namespace :rspec_profiling do
|
4
4
|
desc "Install the collector"
|
5
|
-
task :
|
5
|
+
task install: :environment do
|
6
6
|
collector.install
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "Uninstall the collector"
|
10
|
-
task :
|
10
|
+
task uninstall: :environment do
|
11
11
|
collector.uninstall
|
12
12
|
end
|
13
13
|
|
14
|
-
task :
|
14
|
+
task console: :environment do
|
15
15
|
require 'irb'
|
16
16
|
require 'irb/completion'
|
17
17
|
require 'rspec_profiling'
|
data/rspec_profiling
CHANGED
Binary file
|
data/rspec_profiling.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "sqlite3"
|
22
22
|
spec.add_dependency "activerecord"
|
23
|
+
spec.add_dependency "pg"
|
24
|
+
spec.add_dependency "rails"
|
23
25
|
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
27
|
spec.add_development_dependency "rake"
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "rspec_profiling/config"
|
2
|
-
require "rspec_profiling/collectors/
|
2
|
+
require "rspec_profiling/collectors/psql"
|
3
3
|
|
4
4
|
module RspecProfiling
|
5
5
|
module Collectors
|
6
|
-
describe
|
7
|
-
before(:all) {
|
8
|
-
after(:all) {
|
6
|
+
describe PSQL do
|
7
|
+
before(:all) { described_class.install }
|
8
|
+
after(:all) { described_class.uninstall }
|
9
9
|
|
10
10
|
describe "#insert" do
|
11
11
|
let(:collector) { described_class.new }
|
@@ -37,7 +37,7 @@ module RspecProfiling
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "records the commit date" do
|
40
|
-
expect(result.
|
40
|
+
expect(result.date).to eq Time.utc(2012, 12, 18, 12)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "records the file" do
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "rspec_profiling/config"
|
2
|
+
require "rspec_profiling/collectors/sql"
|
3
|
+
|
4
|
+
module RspecProfiling
|
5
|
+
module Collectors
|
6
|
+
describe SQL do
|
7
|
+
before(:all) { described_class.install }
|
8
|
+
after(:all) { described_class.uninstall }
|
9
|
+
|
10
|
+
describe "#insert" do
|
11
|
+
let(:collector) { described_class.new }
|
12
|
+
let(:result) { collector.results.first }
|
13
|
+
|
14
|
+
before do
|
15
|
+
collector.insert({
|
16
|
+
commit: "ABC123",
|
17
|
+
date: "Thu Dec 18 12:00:00 2012",
|
18
|
+
file: "/some/file.rb",
|
19
|
+
line_number: 10,
|
20
|
+
description: "Some spec",
|
21
|
+
time: 100,
|
22
|
+
status: :passed,
|
23
|
+
exception: "some issue",
|
24
|
+
query_count: 10,
|
25
|
+
query_time: 50,
|
26
|
+
request_count: 1,
|
27
|
+
request_time: 400
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
it "records a single result" do
|
32
|
+
expect(collector.results.count).to eq 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it "records the commit SHA" do
|
36
|
+
expect(result.commit).to eq "ABC123"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "records the commit date" do
|
40
|
+
expect(result.date).to eq Time.utc(2012, 12, 18, 12)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "records the file" do
|
44
|
+
expect(result.file).to eq "/some/file.rb"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "records the line number" do
|
48
|
+
expect(result.line_number).to eq 10
|
49
|
+
end
|
50
|
+
|
51
|
+
it "records the description" do
|
52
|
+
expect(result.description).to eq "Some spec"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "records the time" do
|
56
|
+
expect(result.time).to eq 100.0
|
57
|
+
end
|
58
|
+
|
59
|
+
it "records the passing status" do
|
60
|
+
expect(result.status).to eq 'passed'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "records the exception" do
|
64
|
+
expect(result.exception). to eq 'some issue'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "records the query count" do
|
68
|
+
expect(result.query_count).to eq 10
|
69
|
+
end
|
70
|
+
|
71
|
+
it "records the query time" do
|
72
|
+
expect(result.query_time).to eq 50
|
73
|
+
end
|
74
|
+
|
75
|
+
it "records the request count" do
|
76
|
+
expect(result.request_count).to eq 1
|
77
|
+
end
|
78
|
+
|
79
|
+
it "records the request time" do
|
80
|
+
expect(result.request_time).to eq 400
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
CHANGED
@@ -1,83 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_profiling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Eddy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pg
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
|
-
- - ~>
|
73
|
+
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
75
|
version: '1.3'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- - ~>
|
80
|
+
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '1.3'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rake
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- -
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
89
|
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- -
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rspec
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
|
-
- -
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
103
|
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- -
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
description: Profile RSpec test suites
|
@@ -87,25 +115,31 @@ executables: []
|
|
87
115
|
extensions: []
|
88
116
|
extra_rdoc_files: []
|
89
117
|
files:
|
90
|
-
- .gitignore
|
118
|
+
- ".gitignore"
|
119
|
+
- ".ruby-gemset"
|
120
|
+
- ".ruby-version"
|
91
121
|
- Gemfile
|
92
122
|
- LICENSE.txt
|
93
123
|
- README.md
|
94
124
|
- Rakefile
|
95
125
|
- lib/rspec_profiling.rb
|
96
126
|
- lib/rspec_profiling/collectors/csv.rb
|
97
|
-
- lib/rspec_profiling/collectors/
|
127
|
+
- lib/rspec_profiling/collectors/psql.rb
|
128
|
+
- lib/rspec_profiling/collectors/sql.rb
|
98
129
|
- lib/rspec_profiling/config.rb
|
99
130
|
- lib/rspec_profiling/console.rb
|
100
|
-
- lib/rspec_profiling/current_commit.rb
|
101
131
|
- lib/rspec_profiling/example.rb
|
102
132
|
- lib/rspec_profiling/rspec.rb
|
103
133
|
- lib/rspec_profiling/run.rb
|
134
|
+
- lib/rspec_profiling/vcs/git.rb
|
135
|
+
- lib/rspec_profiling/vcs/git_svn.rb
|
136
|
+
- lib/rspec_profiling/vcs/svn.rb
|
104
137
|
- lib/rspec_profiling/version.rb
|
105
138
|
- lib/tasks/rspec_profiling.rake
|
106
139
|
- rspec_profiling
|
107
140
|
- rspec_profiling.gemspec
|
108
|
-
- spec/collectors/
|
141
|
+
- spec/collectors/psql_spec.rb
|
142
|
+
- spec/collectors/sql_spec.rb
|
109
143
|
- spec/run_spec.rb
|
110
144
|
homepage: https://github.com/foraker/rspec_profiling
|
111
145
|
licenses:
|
@@ -117,20 +151,21 @@ require_paths:
|
|
117
151
|
- lib
|
118
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
153
|
requirements:
|
120
|
-
- -
|
154
|
+
- - ">="
|
121
155
|
- !ruby/object:Gem::Version
|
122
156
|
version: '0'
|
123
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
158
|
requirements:
|
125
|
-
- -
|
159
|
+
- - ">="
|
126
160
|
- !ruby/object:Gem::Version
|
127
161
|
version: '0'
|
128
162
|
requirements: []
|
129
163
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.4.5
|
131
165
|
signing_key:
|
132
166
|
specification_version: 4
|
133
167
|
summary: Profile RSpec test suites
|
134
168
|
test_files:
|
135
|
-
- spec/collectors/
|
169
|
+
- spec/collectors/psql_spec.rb
|
170
|
+
- spec/collectors/sql_spec.rb
|
136
171
|
- spec/run_spec.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require "time"
|
2
|
-
|
3
|
-
module RspecProfiling
|
4
|
-
module CurrentCommit
|
5
|
-
extend self
|
6
|
-
|
7
|
-
def git?
|
8
|
-
`git rev-parse 2>&1`
|
9
|
-
$?.success?
|
10
|
-
end
|
11
|
-
|
12
|
-
def sha
|
13
|
-
if git?
|
14
|
-
`git rev-parse HEAD`
|
15
|
-
else
|
16
|
-
`svn info -r 'HEAD' | grep "Revision" | cut -f2 -d' '`
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def time
|
21
|
-
if git?
|
22
|
-
Time.parse `git show -s --format=%ci #{sha}`
|
23
|
-
else
|
24
|
-
Time.parse `svn info -r 'HEAD' | grep "Last Changed Date" | cut -f4,5,6 -d' '`
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|