rspec_expectation_count 0.0.2 → 0.0.3

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: 9ee1c8edc6a6549c3b849b3d32e82081a0c7ba60
4
- data.tar.gz: 2f4bf38f2841ad7420c776a6772f9433e4689efa
3
+ metadata.gz: a89daebe2c66a3015e00e647acd86d455ef57821
4
+ data.tar.gz: 2019f766fd468afb7969311b4670a17356f67ba0
5
5
  SHA512:
6
- metadata.gz: 71217c867346583a201f1ce80910693d18b7002d6b44bf8f169394de7fb5effcb57cb3fbc1811788e44991697bd889ab9ef00fcd0365ec93b1149ada742761aa
7
- data.tar.gz: 95c45ee1e60dac2e720c88aee28232641dd0755d30a988022675822f5cb652e9419200834cf143b97265c12cf05420af372afdc23fd8256d89ef83a4e3171e6b
6
+ metadata.gz: d052f7fe7ebb99145ada3897724f32d5312d3fff0905801c2304ee245ca7df14f5d2f69e413deb6887eb3b48dae3bb649a5e47e61a31fb94f01de47bb6ced4de
7
+ data.tar.gz: 35c427d364bb558a928127d7a715fa6ee12ee40778027b3cc088767623bea9da94e844201514c73ab232d517b9896bdad124307fe6f5a991a17aa99b42c3d415
data/.rubocop.yml CHANGED
@@ -4,3 +4,5 @@ Metrics/CyclomaticComplexity:
4
4
  Enabled: false
5
5
  Metrics/PerceivedComplexity:
6
6
  Enabled: false
7
+ Metrics/LineLength:
8
+ Enabled: false
@@ -0,0 +1,29 @@
1
+ unless ::RSpec::Expectations.expectation_debug.is_a?(Array)
2
+ module RSpec
3
+ module Expectations
4
+ class << self
5
+ def expectation_debug
6
+ @expectation_debug ||= []
7
+ end
8
+
9
+ attr_accessor :last_spec_hash
10
+
11
+ TracePoint.new do |trace|
12
+ file_path = trace.path
13
+ if file_path.end_with?('_spec.rb')
14
+ line_number = trace.lineno
15
+ line = IO.readlines(file_path)[line_number - 1]
16
+ if line.include?('expect') # expect() || expect { }
17
+ expect_hash = { file: file_path, line: line.strip, line_number: line_number }
18
+ ::RSpec::Expectations.last_spec_hash = expect_hash
19
+ end
20
+ end
21
+ end.enable
22
+
23
+ def update_expectation_debug
24
+ expectation_debug << last_spec_hash
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -3,7 +3,6 @@ require 'rspec'
3
3
  require 'rspec/matchers'
4
4
  require 'rspec/expectations/handler'
5
5
  require 'rspec/core/formatters/base_text_formatter'
6
-
7
6
  # https://github.com/rspec/rspec-core/issues/740
8
7
 
9
8
  unless ::RSpec::Expectations.respond_to?(:expectation_count)
@@ -15,6 +14,12 @@ unless ::RSpec::Expectations.respond_to?(:expectation_count)
15
14
  end
16
15
 
17
16
  attr_writer :expectation_count
17
+
18
+ def update_expectation_debug
19
+ end
20
+
21
+ def expectation_debug
22
+ end
18
23
  end
19
24
 
20
25
  class PositiveExpectationHandler
@@ -22,6 +27,7 @@ unless ::RSpec::Expectations.respond_to?(:expectation_count)
22
27
  alias_method :old_handle_matcher, :handle_matcher
23
28
 
24
29
  def handle_matcher(*args)
30
+ ::RSpec::Expectations.update_expectation_debug
25
31
  ::RSpec::Expectations.expectation_count += 1
26
32
  old_handle_matcher(*args)
27
33
  end
@@ -33,6 +39,7 @@ unless ::RSpec::Expectations.respond_to?(:expectation_count)
33
39
  alias_method :old_handle_matcher, :handle_matcher
34
40
 
35
41
  def handle_matcher(*args)
42
+ ::RSpec::Expectations.update_expectation_debug
36
43
  ::RSpec::Expectations.expectation_count += 1
37
44
  old_handle_matcher(*args)
38
45
  end
@@ -53,6 +60,7 @@ unless ::RSpec::Expectations.respond_to?(:expectation_count)
53
60
  count = ::RSpec::Expectations.expectation_count
54
61
  plural = count == 1 ? '' : 's'
55
62
  output.puts "#{count} expectation#{plural}"
63
+ output.puts ::RSpec::Expectations.expectation_debug
56
64
  end
57
65
  end
58
66
  end
@@ -1,4 +1,4 @@
1
1
  module RSpecExpectationCount
2
- VERSION = '0.0.2' unless defined? ::RSpecExpectationCount::VERSION
2
+ VERSION = '0.0.3' unless defined? ::RSpecExpectationCount::VERSION
3
3
  DATE = '2015-11-09' unless defined? ::RSpecExpectationCount::DATE
4
4
  end
data/readme.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # rspec_expectation_count
2
2
 
3
3
  [![Build Status](https://travis-ci.org/bootstraponline/rspec_expectation_count.svg?branch=master)](https://travis-ci.org/bootstraponline/rspec_expectation_count/builds)
4
+ [![Gem Version](https://badge.fury.io/rb/rspec_expectation_count.svg)](https://rubygems.org/gems/rspec_expectation_count)
4
5
 
5
6
  Count the number of expectations used in an RSpec test suite
data/release_notes.md CHANGED
@@ -1,3 +1,12 @@
1
+ #### v0.0.3 2015-11-09
2
+
3
+ - [ba31882](https://github.com/bootstraponline/rspec_expectation_count/commit/ba3188209ee245ecc42f7eb2963ebc9d754cd134) Release 0.0.3
4
+ - [d92ce4d](https://github.com/bootstraponline/rspec_expectation_count/commit/d92ce4dbb40037cf075ee6bfd0cc8610820d9258) Fix rubocop
5
+ - [2284792](https://github.com/bootstraponline/rspec_expectation_count/commit/22847927b9eac5bb1e2081bbfdded40a37803ab9) Clean up code
6
+ - [61c5072](https://github.com/bootstraponline/rspec_expectation_count/commit/61c50723fb954ba180b821d33a312364ae679425) Add debug logging for expectation count
7
+ - [003cf27](https://github.com/bootstraponline/rspec_expectation_count/commit/003cf2753e549c0475951649eedeeda3f03186c8) Add gem badge
8
+
9
+
1
10
  #### v0.0.2 2015-11-09
2
11
 
3
12
  - [2125bc6](https://github.com/bootstraponline/rspec_expectation_count/commit/2125bc67ced2486f86c1eea07226d1e96333dd30) Release 0.0.2
@@ -1,7 +1,6 @@
1
1
  require_relative 'lib/rspec_expectation_count/version'
2
2
 
3
3
  # rubocop:disable Style/SpaceAroundOperators
4
- # rubocop:disable Metrics/LineLength
5
4
 
6
5
  Gem::Specification.new do |s|
7
6
  s.required_ruby_version = '>= 2.2.3'
@@ -0,0 +1,14 @@
1
+ require_relative '../lib/rspec_expectation_count'
2
+ require_relative '../lib/rspec_expectation_count/expectation_debug'
3
+
4
+ describe 'count' do
5
+ it 'tracks the amount of expects' do
6
+ # 1
7
+ # 2
8
+ # 3
9
+ expect(1).to eq(1)
10
+ # 4
11
+ expect(2).not_to eq(3)
12
+ # 5
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_expectation_count
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
@@ -94,12 +94,14 @@ files:
94
94
  - LICENSE
95
95
  - Thorfile
96
96
  - lib/rspec_expectation_count.rb
97
+ - lib/rspec_expectation_count/expectation_debug.rb
97
98
  - lib/rspec_expectation_count/rspec_expectation_count.rb
98
99
  - lib/rspec_expectation_count/version.rb
99
100
  - readme.md
100
101
  - release_notes.md
101
102
  - rspec_expectation_count.gemspec
102
103
  - spec2/count_spec.rb
104
+ - spec3/count_spec.rb
103
105
  homepage: https://github.com/bootstraponline/rspec_expectation_count
104
106
  licenses:
105
107
  - http://www.apache.org/licenses/LICENSE-2.0.txt