rspec-activerecord-formatter 1.0.3 → 1.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/README.md +3 -2
- data/lib/rspec/activerecord/formatter.rb +12 -7
- data/rspec-activerecord-formatter.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 573d9da6bd2d49e858ad2598ecf931c7b9909cc4d53881ed84d27b9e071310c5
|
4
|
+
data.tar.gz: a4f40473db9a50e226ba87b5512b031a1adacf5694f1872ef1571763e997f212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87e83e43deaad1f964e3cc88264ab51779a0362c789f18a5ea3d33d1116059866f7f3df0c8946f936462215b94a8f4440bafb1f11143bf5a7d5a2f964a62f433
|
7
|
+
data.tar.gz: '068fbce81ae37fe58c1e0d97d61f4024cab3cd233618f870d8e4b842d25291810872504dc53c21e702379a92a4aca472dde66fbdb7869a7d57a6ef1524dac255'
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Installation
|
|
17
17
|
Normal bundle stuff. You'll almost certainly need to add this gem to your
|
18
18
|
bundle at least temporarily, since you'll be running rspec using bundler.
|
19
19
|
|
20
|
-
gem 'rspec-activerecord-formatter'
|
20
|
+
gem 'rspec-activerecord-formatter', require: false
|
21
21
|
|
22
22
|
|
23
23
|
Usage
|
@@ -25,6 +25,7 @@ Usage
|
|
25
25
|
|
26
26
|
The current answer is to change your `.rspec` initializer to include the following:
|
27
27
|
|
28
|
+
--require rspec-activerecord-formatter
|
28
29
|
--require rails_helper
|
29
30
|
--format ActiveRecordFormatter
|
30
31
|
|
@@ -33,7 +34,7 @@ formatter. That way, we can hook into AR creations.
|
|
33
34
|
|
34
35
|
You can also run the formatter as a one-off option to rspec:
|
35
36
|
|
36
|
-
rspec path/to/example_spec.rb --require rails_helper --format ActiveRecordFormatter
|
37
|
+
rspec path/to/example_spec.rb --require rspec-activerecord-formatter --require rails_helper --format ActiveRecordFormatter
|
37
38
|
|
38
39
|
Once you set the formatter, you should now see the number of objects created and total queries
|
39
40
|
for each of your tests:
|
@@ -31,16 +31,21 @@ class ActiveRecordFormatter < ::RSpec::Core::Formatters::DocumentationFormatter
|
|
31
31
|
end
|
32
32
|
|
33
33
|
output.puts formatted
|
34
|
-
|
34
|
+
write_profile_summary
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
def write_profile_summary
|
38
|
+
output_report_filename = Time.now.strftime("rspec_activerecord_result_%Y_%m_%d_%H_%m_%S.txt")
|
39
|
+
output_report_path = Rails.root.join("tmp", output_report_filename)
|
40
|
+
|
41
|
+
puts "\nOutputting Detailed Profile Data to #{output_report_path}"
|
42
|
+
File.open(output_report_path, "wb") do |f|
|
43
|
+
f.puts "#{collector.total_objects} AR objects, #{collector.total_queries} AR queries\n"
|
44
|
+
f.puts "Query Summary"
|
45
|
+
collector.most_common_query_names.each do |name, count|
|
46
|
+
f.puts "%-4s %s" % [count, name]
|
47
|
+
end
|
41
48
|
end
|
42
|
-
|
43
|
-
summary.join("\n")
|
44
49
|
end
|
45
50
|
|
46
51
|
protected
|
@@ -6,7 +6,7 @@ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
|
8
8
|
gem.name = "rspec-activerecord-formatter"
|
9
|
-
gem.version = "1.0
|
9
|
+
gem.version = "1.1.0"
|
10
10
|
|
11
11
|
gem.summary = "Adds object creations and queries to Rspec output."
|
12
12
|
gem.description = "Creates a new formatter for ActiveRecord that can help you diagnose performance issues in RSpec"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-activerecord-formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Mastey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|