rspec-debugging 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 896e136df71d2e337174b069c599e26004bc84255a13b226abe2d29aea474f1c
4
- data.tar.gz: 89ce8e417c627add4db5d53896b072fc45b00b25f478f8ee3e383242f837e0f2
3
+ metadata.gz: 9d232979bdf2295fb58cec0c7295355366fb703f74e327d0d87d6d6febc35da9
4
+ data.tar.gz: 98d1146bb2abb4e83f4308f47f302d74755c1d5b1f2c622ef216390ec25c6496
5
5
  SHA512:
6
- metadata.gz: 46ba38fe0e0e119b61f3648dc6d9b7e3661bc0fe511f710bab8d711d151c071d5ae086c637e5fe7886b3b6a661aed8175286bb7fbf0316dc6f9c86f68610c080
7
- data.tar.gz: 48f3376fc2e14099fc319e18dc64169d020eeff444d14b1452e0f75411eeb99aca47e3cc24680fb5ee5206c409c566d41e91b13b5342ce23e93d3a53476a2f4d
6
+ metadata.gz: b22241789c483ef578ef866f7262e263938629486ed90f931f0a09511d3b662b0818cbbccd7cb5f3df2c441be2decdadfd775c6e61c37fcf080b5a100d245bb6
7
+ data.tar.gz: d537656b7b9d64d8e572a2844e83dfd86450bb1a803a910f58322d5a14ec23d62a6b00e3958f27d5f9bd2ba2d50ab5292abf4a6fe97a7837e341a8c81d7db770
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ ### 0.0.2 (2025-01-14)
2
+ - dit - debugging examples
3
+
1
4
  ### 0.0.1 (2025-01-10)
2
5
  - init
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-debugging (0.0.1)
4
+ rspec-debugging (0.0.2)
5
5
  rspec-expectations (>= 3)
6
6
 
7
7
  GEM
@@ -0,0 +1,56 @@
1
+ require 'debug/session'
2
+
3
+ module RSpec
4
+ module Debugging
5
+ module DebugIt
6
+ ENABLED = ['1', 'true'].include?(ENV['RSPEC_DEBUGGING'])
7
+
8
+ def initialize(example_group_class, description, user_metadata, example_block=nil)
9
+ return super unless user_metadata[:debug] || ENABLED
10
+
11
+ if example_block
12
+ orig_example_block = example_block
13
+
14
+ example_block = Proc.new do
15
+ e = DEBUGGER__::SESSION.capture_exception_frames /(exe|bin|lib)\/rspec/ do
16
+ instance_exec(&orig_example_block)
17
+ end
18
+
19
+ if e
20
+ STDERR.puts <<~MSG
21
+
22
+ Error:
23
+ #{e.message}
24
+
25
+ MSG
26
+
27
+ DEBUGGER__::SESSION.enter_postmortem_session e
28
+ raise e
29
+ end
30
+ end # Proc.new
31
+ elsif user_metadata[:debug] && user_metadata[:skip] == RSpec::Core::Pending::NOT_YET_IMPLEMENTED
32
+ # called with no block
33
+ user_metadata.delete(:skip)
34
+
35
+ file, line = caller[2].split(":")
36
+
37
+ example_block = Proc.new do
38
+ STDERR.puts <<~MSG
39
+ debugging: #{file}:#{line}
40
+
41
+ MSG
42
+
43
+ debugger
44
+ end
45
+ end
46
+
47
+ super
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ RSpec::Core::Example.prepend RSpec::Debugging::DebugIt
54
+ RSpec::Core::ExampleGroup.define_example_method(:dit, debug: true, focus: true)
55
+ RSpec::Core::ExampleGroup.define_example_group_method(:ddescribe, debug: true, focus: true)
56
+ RSpec::Core::ExampleGroup.define_example_group_method(:dcontext, debug: true, focus: true)
@@ -1,5 +1,6 @@
1
1
  require "rspec/expectations"
2
2
 
3
+ require "rspec/debugging/debug_it"
3
4
  require "rspec/debugging/let_variables"
4
5
  require "rspec/debugging/version"
5
6
 
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.homepage = "https://github.com/dpep/rspec-debugging"
6
6
  s.license = "MIT"
7
7
  s.name = File.basename(__FILE__, ".gemspec")
8
- s.summary = "RSpec::Debugging"
9
- s.version = "0.0.1"
8
+ s.summary = s.description
9
+ s.version = "0.0.2"
10
10
 
11
11
  s.required_ruby_version = ">= 3.1"
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-debugging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-11 00:00:00.000000000 Z
11
+ date: 2025-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-expectations
@@ -79,6 +79,7 @@ files:
79
79
  - README.md
80
80
  - lib/rspec-debugging.rb
81
81
  - lib/rspec/debugging.rb
82
+ - lib/rspec/debugging/debug_it.rb
82
83
  - lib/rspec/debugging/let_variables.rb
83
84
  - lib/rspec/debugging/version.rb
84
85
  - rspec-debugging.gemspec
@@ -104,5 +105,5 @@ requirements: []
104
105
  rubygems_version: 3.5.23
105
106
  signing_key:
106
107
  specification_version: 4
107
- summary: RSpec::Debugging
108
+ summary: Tools to improve debugging in RSpec
108
109
  test_files: []