rspec-activerecord-formatter 1.0.3 → 1.1.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
  SHA256:
3
- metadata.gz: eb680f42fdf9b7a605517cf7a577b17a494b0d8125e06616891f5aab77a359b5
4
- data.tar.gz: 984a2d0ab39d672bfc42d1cdfd8c6aa73435227a9745b1d672e709818d0f8a26
3
+ metadata.gz: 573d9da6bd2d49e858ad2598ecf931c7b9909cc4d53881ed84d27b9e071310c5
4
+ data.tar.gz: a4f40473db9a50e226ba87b5512b031a1adacf5694f1872ef1571763e997f212
5
5
  SHA512:
6
- metadata.gz: 218ab5de04b4b8f01d80cd66b83c4a96dd7ecab0019660db3279ea593e62410c1c6ca58370d811e2b1be208123106c7e1124bf8e7d13cf133f0e0162733a4bb7
7
- data.tar.gz: ec002a337aed2d08b180504e36c6d284e920b73f26371b3bf8cdd3ffd5d95ec70f751e8d22b10620c0b4291cdc705a2ef936b8973df5a23f2ed8522c2e89a44c
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
- output.puts record_type_summaries
34
+ write_profile_summary
35
35
  end
36
36
 
37
- def record_type_summaries
38
- summary = ["", "Summary of Queries"]
39
- collector.most_common_query_names.each do |name, count|
40
- summary << "%-4s %s" % [count, name]
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.3"
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.3
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-04-07 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport