rspec_profiling 0.0.6 → 0.0.7

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE/bug.yml +66 -0
  4. data/.github/ISSUE_TEMPLATE/config.yml +1 -0
  5. data/.github/ISSUE_TEMPLATE/docs.yml +18 -0
  6. data/.github/ISSUE_TEMPLATE/feature-request.yml +36 -0
  7. data/.github/ISSUE_TEMPLATE/question-support.yml +18 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +17 -0
  9. data/.github/dependabot.yaml +20 -0
  10. data/.github/workflows/auto-assign-author.yaml +13 -0
  11. data/.github/workflows/codeql.yaml +43 -0
  12. data/.github/workflows/release.yaml +40 -0
  13. data/.github/workflows/stale.yaml +38 -0
  14. data/.github/workflows/test.yaml +54 -0
  15. data/.gitignore +3 -0
  16. data/.ruby-version +1 -1
  17. data/CODE_OF_CONDUCT.md +130 -0
  18. data/CONTRIBUTING.md +37 -0
  19. data/EMERITUS.md +3 -0
  20. data/{LICENSE.txt → LICENSE.md} +2 -1
  21. data/Makefile +60 -0
  22. data/README.md +61 -19
  23. data/SECURITY.md +20 -0
  24. data/docker-compose.yml +13 -0
  25. data/lib/rspec_profiling/collectors/csv.rb +30 -7
  26. data/lib/rspec_profiling/collectors/json.rb +70 -0
  27. data/lib/rspec_profiling/collectors/psql.rb +1 -1
  28. data/lib/rspec_profiling/collectors/sql.rb +1 -1
  29. data/lib/rspec_profiling/config.rb +4 -2
  30. data/lib/rspec_profiling/example.rb +23 -1
  31. data/lib/rspec_profiling/rspec.rb +1 -1
  32. data/lib/rspec_profiling/run.rb +33 -5
  33. data/lib/rspec_profiling/vcs/git.rb +1 -1
  34. data/lib/rspec_profiling/version.rb +1 -1
  35. data/lib/rspec_profiling.rb +14 -2
  36. data/rspec_profiling.gemspec +9 -6
  37. metadata +45 -35
  38. data/.ruby-gemset +0 -1
  39. data/rspec_profiling +0 -0
  40. data/spec/collectors/psql_spec.rb +0 -90
  41. data/spec/collectors/sql_spec.rb +0 -90
  42. data/spec/run_spec.rb +0 -151
  43. data/spec/vcs/git_spec.rb +0 -27
  44. data/spec/vcs/svn_spec.rb +0 -25
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_profiling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
- - Ben Eddy
7
+ - Procore Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sqlite3
14
+ name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activerecord
28
+ name: get_process_mem
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pg
42
+ name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,33 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rails
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ">"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
61
+ version: '1.3'
62
+ type: :development
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: '0'
68
+ version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '1.3'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '1.3'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -110,21 +110,40 @@ dependencies:
110
110
  version: '0'
111
111
  description: Profile RSpec test suites
112
112
  email:
113
- - bae@foraker.com
113
+ - opensource@procore.com
114
114
  executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/CODEOWNERS"
119
+ - ".github/ISSUE_TEMPLATE/bug.yml"
120
+ - ".github/ISSUE_TEMPLATE/config.yml"
121
+ - ".github/ISSUE_TEMPLATE/docs.yml"
122
+ - ".github/ISSUE_TEMPLATE/feature-request.yml"
123
+ - ".github/ISSUE_TEMPLATE/question-support.yml"
124
+ - ".github/PULL_REQUEST_TEMPLATE.md"
125
+ - ".github/dependabot.yaml"
126
+ - ".github/workflows/auto-assign-author.yaml"
127
+ - ".github/workflows/codeql.yaml"
128
+ - ".github/workflows/release.yaml"
129
+ - ".github/workflows/stale.yaml"
130
+ - ".github/workflows/test.yaml"
118
131
  - ".gitignore"
119
- - ".ruby-gemset"
120
132
  - ".ruby-version"
121
133
  - CHANGELOG.md
134
+ - CODE_OF_CONDUCT.md
135
+ - CONTRIBUTING.md
136
+ - EMERITUS.md
122
137
  - Gemfile
123
- - LICENSE.txt
138
+ - LICENSE.md
139
+ - Makefile
124
140
  - README.md
125
141
  - Rakefile
142
+ - SECURITY.md
143
+ - docker-compose.yml
126
144
  - lib/rspec_profiling.rb
127
145
  - lib/rspec_profiling/collectors/csv.rb
146
+ - lib/rspec_profiling/collectors/json.rb
128
147
  - lib/rspec_profiling/collectors/psql.rb
129
148
  - lib/rspec_profiling/collectors/sql.rb
130
149
  - lib/rspec_profiling/config.rb
@@ -137,17 +156,13 @@ files:
137
156
  - lib/rspec_profiling/vcs/svn.rb
138
157
  - lib/rspec_profiling/version.rb
139
158
  - lib/tasks/rspec_profiling.rake
140
- - rspec_profiling
141
159
  - rspec_profiling.gemspec
142
- - spec/collectors/psql_spec.rb
143
- - spec/collectors/sql_spec.rb
144
- - spec/run_spec.rb
145
- - spec/vcs/git_spec.rb
146
- - spec/vcs/svn_spec.rb
147
- homepage: https://github.com/foraker/rspec_profiling
160
+ homepage: https://github.com/procore-oss/rspec_profiling
148
161
  licenses:
149
162
  - MIT
150
- metadata: {}
163
+ metadata:
164
+ allowed_push_host: https://rubygems.org
165
+ rubygems_mfa_required: 'true'
151
166
  post_install_message:
152
167
  rdoc_options: []
153
168
  require_paths:
@@ -163,13 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
178
  - !ruby/object:Gem::Version
164
179
  version: '0'
165
180
  requirements: []
166
- rubygems_version: 3.1.2
181
+ rubygems_version: 3.4.19
167
182
  signing_key:
168
183
  specification_version: 4
169
184
  summary: Profile RSpec test suites
170
- test_files:
171
- - spec/collectors/psql_spec.rb
172
- - spec/collectors/sql_spec.rb
173
- - spec/run_spec.rb
174
- - spec/vcs/git_spec.rb
175
- - spec/vcs/svn_spec.rb
185
+ test_files: []
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- rspec_profiling
data/rspec_profiling DELETED
Binary file
@@ -1,90 +0,0 @@
1
- require "rspec_profiling/config"
2
- require "rspec_profiling/collectors/psql"
3
-
4
- module RspecProfiling
5
- module Collectors
6
- describe PSQL 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
- branch: "master",
17
- commit_hash: "ABC123",
18
- date: "Thu Dec 18 12:00:00 2012",
19
- file: "/some/file.rb",
20
- line_number: 10,
21
- description: "Some spec",
22
- time: 100,
23
- status: :passed,
24
- exception: "some issue",
25
- query_count: 10,
26
- query_time: 50,
27
- request_count: 1,
28
- request_time: 400
29
- })
30
- end
31
-
32
- it "records a single result" do
33
- expect(collector.results.count).to eq 1
34
- end
35
-
36
- it "records the branch name" do
37
- expect(result.branch).to eq "master"
38
- end
39
-
40
- it "records the commit_hash SHA" do
41
- expect(result.commit_hash).to eq "ABC123"
42
- end
43
-
44
- it "records the commit_hash date" do
45
- expect(result.date).to eq Time.utc(2012, 12, 18, 12)
46
- end
47
-
48
- it "records the file" do
49
- expect(result.file).to eq "/some/file.rb"
50
- end
51
-
52
- it "records the line number" do
53
- expect(result.line_number).to eq 10
54
- end
55
-
56
- it "records the description" do
57
- expect(result.description).to eq "Some spec"
58
- end
59
-
60
- it "records the time" do
61
- expect(result.time).to eq 100.0
62
- end
63
-
64
- it "records the passing status" do
65
- expect(result.status).to eq 'passed'
66
- end
67
-
68
- it "records the exception" do
69
- expect(result.exception). to eq 'some issue'
70
- end
71
-
72
- it "records the query count" do
73
- expect(result.query_count).to eq 10
74
- end
75
-
76
- it "records the query time" do
77
- expect(result.query_time).to eq 50
78
- end
79
-
80
- it "records the request count" do
81
- expect(result.request_count).to eq 1
82
- end
83
-
84
- it "records the request time" do
85
- expect(result.request_time).to eq 400
86
- end
87
- end
88
- end
89
- end
90
- end
@@ -1,90 +0,0 @@
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
- branch: "master",
17
- commit_hash: "ABC123",
18
- date: "Thu Dec 18 12:00:00 2012",
19
- file: "/some/file.rb",
20
- line_number: 10,
21
- description: "Some spec",
22
- time: 100,
23
- status: :passed,
24
- exception: "some issue",
25
- query_count: 10,
26
- query_time: 50,
27
- request_count: 1,
28
- request_time: 400
29
- })
30
- end
31
-
32
- it "records a single result" do
33
- expect(collector.results.count).to eq 1
34
- end
35
-
36
- it "records the branch name" do
37
- expect(result.branch).to eq "master"
38
- end
39
-
40
- it "records the commit_hash SHA" do
41
- expect(result.commit_hash).to eq "ABC123"
42
- end
43
-
44
- it "records the commit_hash date" do
45
- expect(result.date).to eq Time.utc(2012, 12, 18, 12)
46
- end
47
-
48
- it "records the file" do
49
- expect(result.file).to eq "/some/file.rb"
50
- end
51
-
52
- it "records the line number" do
53
- expect(result.line_number).to eq 10
54
- end
55
-
56
- it "records the description" do
57
- expect(result.description).to eq "Some spec"
58
- end
59
-
60
- it "records the time" do
61
- expect(result.time).to eq 100.0
62
- end
63
-
64
- it "records the passing status" do
65
- expect(result.status).to eq 'passed'
66
- end
67
-
68
- it "records the exception" do
69
- expect(result.exception). to eq 'some issue'
70
- end
71
-
72
- it "records the query count" do
73
- expect(result.query_count).to eq 10
74
- end
75
-
76
- it "records the query time" do
77
- expect(result.query_time).to eq 50
78
- end
79
-
80
- it "records the request count" do
81
- expect(result.request_count).to eq 1
82
- end
83
-
84
- it "records the request time" do
85
- expect(result.request_time).to eq 400
86
- end
87
- end
88
- end
89
- end
90
- end
data/spec/run_spec.rb DELETED
@@ -1,151 +0,0 @@
1
- require "active_support/core_ext"
2
- require "rspec_profiling/run"
3
- require "time"
4
- require "ostruct"
5
-
6
- module RspecProfiling
7
- describe Run do
8
- def simulate_query(sql)
9
- ActiveSupport::Notifications.instrument("sql.active_record", "sql", 100, 200, 1, {
10
- sql: sql
11
- })
12
- end
13
-
14
- def simulate_request
15
- ActiveSupport::Notifications.instrument("process_action.action_controller", "request", 100, 400, 2, {
16
- view_runtime: 10
17
- })
18
- end
19
-
20
- describe "#run_example" do
21
- let(:collector) { CollectorDouble.new }
22
- let(:vcs) { VcsDouble.new }
23
- let(:run) { described_class.new(collector, vcs) }
24
- let(:result) { collector.results.first }
25
- let(:example) do
26
- ExampleDouble.new({
27
- file_path: "/something_spec.rb",
28
- line_number: 15,
29
- full_description: "should do something"
30
- })
31
- end
32
-
33
- def simulate_test_suite_run
34
- run.start
35
- run.example_started(double(example: example))
36
- simulate_query "SELECT * FROM users LIMIT 1;"
37
- simulate_query "SELECT * FROM comments WHERE user_id = 1;"
38
- simulate_request
39
- run.example_passed
40
- end
41
-
42
- before do
43
- stub_const("ActiveSupport::Notifications", Notifications.new)
44
- simulate_test_suite_run
45
- end
46
-
47
- it "collects a single example" do
48
- expect(collector.count).to eq 1
49
- end
50
-
51
- it "records the branch name" do
52
- expect(result.branch).to eq "master"
53
- end
54
-
55
- it "records the commit_hash SHA" do
56
- expect(result.commit_hash).to eq "abc123"
57
- end
58
-
59
- it "counts two queries" do
60
- expect(result.query_count).to eq 2
61
- end
62
-
63
- it "counts one request" do
64
- expect(result.request_count).to eq 1
65
- end
66
-
67
- it "records the file" do
68
- expect(result.file).to eq "/something_spec.rb"
69
- end
70
-
71
- it "records the file number" do
72
- expect(result.line_number).to eq 15
73
- end
74
-
75
- it "records the description" do
76
- expect(result.description).to eq "should do something"
77
- end
78
-
79
- it "records the time" do
80
- expect(result.time).to eq 500
81
- end
82
-
83
- it "records the query time" do
84
- expect(result.query_time).to eq 200
85
- end
86
-
87
- it "records the request time" do
88
- expect(result.request_time).to eq 10
89
- end
90
- end
91
-
92
- class CollectorDouble
93
- attr_reader :results
94
-
95
- def initialize
96
- @results = []
97
- end
98
-
99
- def insert(result)
100
- @results << OpenStruct.new(result)
101
- end
102
-
103
- def count
104
- results.count
105
- end
106
- end
107
-
108
- class VcsDouble
109
- def branch
110
- "master"
111
- end
112
-
113
- def sha
114
- "abc123"
115
- end
116
-
117
- def time
118
- 0.1
119
- end
120
- end
121
-
122
- class ExampleDouble
123
- attr_reader :metadata
124
-
125
- def initialize(metadata)
126
- @metadata = metadata
127
- end
128
-
129
- def execution_result
130
- OpenStruct.new({
131
- run_time: 500,
132
- status: :passed
133
- })
134
- end
135
- end
136
-
137
- class Notifications
138
- def initialize
139
- @subscriptions = Hash.new { |h, k| h[k] = [] }
140
- end
141
-
142
- def subscribe(event, &block)
143
- @subscriptions[event].push block
144
- end
145
-
146
- def instrument(event, *args)
147
- @subscriptions[event].each { |callback| callback.call(*args) }
148
- end
149
- end
150
- end
151
- end
data/spec/vcs/git_spec.rb DELETED
@@ -1,27 +0,0 @@
1
- require "rspec_profiling/vcs/git"
2
-
3
- module RspecProfiling
4
- describe VCS::Git do
5
- describe "#branch" do
6
- it "calls Git to get the current branch" do
7
- expect(subject).to receive(:`).with("git rev-parse --abbrev-ref HEAD").and_return("master\n")
8
- expect(subject.branch).to eq "master"
9
- end
10
- end
11
-
12
- describe "#sha" do
13
- it "calls Git to get the current commit's SHA" do
14
- expect(subject).to receive(:`).with("git rev-parse HEAD").and_return("abc123\n")
15
- expect(subject.sha).to eq "abc123"
16
- end
17
- end
18
-
19
- describe "#time" do
20
- it "calls Git to get the current commit's datetime" do
21
- expect(subject).to receive(:`).with("git rev-parse HEAD").and_return("abc123\n")
22
- expect(subject).to receive(:`).with("git show -s --format=%ci abc123").and_return("2017-01-31\n")
23
- expect(subject.time).to eq Time.parse("2017-01-31")
24
- end
25
- end
26
- end
27
- end
data/spec/vcs/svn_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- require "rspec_profiling/vcs/svn"
2
-
3
- module RspecProfiling
4
- describe VCS::Svn do
5
- describe "#branch" do
6
- it "calls Git to get the current branch" do
7
- expect(subject.branch).to be_nil
8
- end
9
- end
10
-
11
- describe "#sha" do
12
- it "calls Git to get the current commit's SHA" do
13
- expect(subject).to receive(:`).with("svn info -r 'HEAD' | grep \"Revision\" | cut -f2 -d' '").and_return("abc123")
14
- expect(subject.sha).to eq "abc123"
15
- end
16
- end
17
-
18
- describe "#time" do
19
- it "calls Git to get the current commit's datetime" do
20
- expect(subject).to receive(:`).with("svn info -r 'HEAD' | grep \"Last Changed Date\" | cut -f4,5,6 -d' '").and_return("2017-01-31")
21
- expect(subject.time).to eq Time.parse("2017-01-31")
22
- end
23
- end
24
- end
25
- end