rspec-debugging 0.0.2 → 0.0.4

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: 9d232979bdf2295fb58cec0c7295355366fb703f74e327d0d87d6d6febc35da9
4
- data.tar.gz: 98d1146bb2abb4e83f4308f47f302d74755c1d5b1f2c622ef216390ec25c6496
3
+ metadata.gz: 18dc39f0ec372fefa54e665b0f8fa941ee58d2e5437d0f7baf165411a7ae3706
4
+ data.tar.gz: bd59263041e3197220b04c1cda058e1d57fe91eb86ed4a50d461c06c02620c98
5
5
  SHA512:
6
- metadata.gz: b22241789c483ef578ef866f7262e263938629486ed90f931f0a09511d3b662b0818cbbccd7cb5f3df2c441be2decdadfd775c6e61c37fcf080b5a100d245bb6
7
- data.tar.gz: d537656b7b9d64d8e572a2844e83dfd86450bb1a803a910f58322d5a14ec23d62a6b00e3958f27d5f9bd2ba2d50ab5292abf4a6fe97a7837e341a8c81d7db770
6
+ metadata.gz: f1a1432398be62a3f54c4c3b198b94b6a69ac9f1524a36f25026ff53bfd5af7ec17dcb0b64c2f01f6b3886492055121f961216f5a818cd37ca2bfbf831fed4cc
7
+ data.tar.gz: eda816fa9f998da2aaf4075010af9e06bafca4b2c308609a2285e0fc202c325284e77eefa5d39ddca787f4a18f7b4ada05265955c08caa2bdd5bc14969765f90
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 0.0.4 (2025-02-08)
2
+ - dependency fix
3
+ - readme
4
+ - inspired by
5
+
6
+ ### 0.0.3 (2025-01-21)
7
+ - let_variable_reset
8
+ - test coverage
9
+ - readme
10
+
1
11
  ### 0.0.2 (2025-01-14)
2
12
  - dit - debugging examples
3
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-debugging (0.0.2)
4
+ rspec-debugging (0.0.4)
5
5
  rspec-expectations (>= 3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,14 +4,90 @@ rspec-debugging
4
4
  [![codecov](https://codecov.io/gh/dpep/rspec-debugging/branch/main/graph/badge.svg)](https://codecov.io/gh/dpep/rspec-debugging)
5
5
 
6
6
 
7
- Tools to make debugging RSpec easier.
7
+ Tools to make debugging RSpec tests easier.
8
+
9
+ <br />
10
+
11
+ Debug broken specs
12
+ ----
13
+ Use `dit`, `dcontext`, or `ddescribe` to run a subset of examples and and start the debugger if anything breaks.
8
14
 
9
15
  ```ruby
10
16
  require "rspec/debugging"
11
17
 
18
+ describe MySpec do
19
+ dit { is_expected.to ... }
20
+ end
21
+ ```
22
+
23
+ or set an environment variable to run and debug all specs:
24
+ ```
25
+ RSPEC_DEBUGGING=true bundle exec rspec
26
+ ```
27
+
28
+ <br />
29
+
30
+ Stop and explore
31
+ ----
32
+ Drop `dit` anywhere to start a debugger.
12
33
 
34
+ ```ruby
35
+ describe MySpec do
36
+ dit
37
+ end
13
38
  ```
14
39
 
40
+ <br />
41
+
42
+ Got let variables?
43
+ ----
44
+ `let` variables are great, but complexity can obscure their value.
45
+
46
+ ```ruby
47
+ describe RSpec::Debugging do
48
+ describe RSpec::Debugging::LetVariables do
49
+ subject { a }
50
+
51
+ let(:a) { "a" }
52
+ let!(:b) { "b" }
53
+
54
+ it { is_expected.to be ??? }
55
+
56
+ context "when we nest" do
57
+ let(:a) { "A" + b }
58
+
59
+ it { is_expected.to be ??? }
60
+
61
+ context "...and nest" do
62
+ let(:a) { super() * 2 }
63
+
64
+ it { is_expected.to be ??? }
65
+ end
66
+ end
67
+ ```
68
+
69
+ ...add a hundred lines of legacy code and then solve for `a`. Or use tooling :)
70
+
71
+ <br />
72
+
73
+ ----
74
+
75
+ ### let_variables
76
+ * list of variables defined by RSpec `let`
77
+
78
+
79
+ ### let_variable_initialized?(name)
80
+ * whether a specified let variable been initialized
81
+
82
+
83
+ ### let_variable_get(name)
84
+ * the value of a let variable, if initialized
85
+
86
+ ### let_variable_values(name)
87
+ * all locations where the specified variable has been defined or redefined, and it's value at each location
88
+
89
+
90
+ <br />
15
91
 
16
92
  ----
17
93
  ## Contributing
@@ -24,3 +100,12 @@ Yes please :)
24
100
  1. Commit your changes (`git commit -am 'awesome new feature'`)
25
101
  1. Push your branch (`git push origin my-feature`)
26
102
  1. Create a Pull Request
103
+
104
+
105
+ <br />
106
+
107
+ ----
108
+ ### Inspired by
109
+
110
+ - [@alexdean](https://github.com/alexdean)
111
+ - [rspec-debug](https://github.com/ko1/rspec-debug)
@@ -1,3 +1,4 @@
1
+ require 'debug'
1
2
  require 'debug/session'
2
3
 
3
4
  module RSpec
@@ -17,7 +18,7 @@ module RSpec
17
18
  end
18
19
 
19
20
  if e
20
- STDERR.puts <<~MSG
21
+ $stderr.puts <<~MSG
21
22
 
22
23
  Error:
23
24
  #{e.message}
@@ -32,15 +33,18 @@ module RSpec
32
33
  # called with no block
33
34
  user_metadata.delete(:skip)
34
35
 
35
- file, line = caller[2].split(":")
36
+ location = RSpec::Core::Metadata.relative_path(caller[2].split(":in").first)
36
37
 
37
38
  example_block = Proc.new do
38
- STDERR.puts <<~MSG
39
- debugging: #{file}:#{line}
39
+ $stderr.puts <<~MSG
40
+ debugging: #{location}
40
41
 
41
42
  MSG
42
43
 
43
44
  debugger
45
+ end.tap do |block|
46
+ # redefine source_location to return the correct location
47
+ block.define_singleton_method(:source_location) { location.split(":") }
44
48
  end
45
49
  end
46
50
 
@@ -13,6 +13,10 @@ module RSpec
13
13
  __memoized.instance_variable_get("@memoized")[name]
14
14
  end
15
15
 
16
+ def let_variable_reset(name)
17
+ __memoized.instance_variable_get("@memoized").delete(name)
18
+ end
19
+
16
20
  def let_variable_locations(name)
17
21
  let_variable_methods(self)[name].map do |fn|
18
22
  normalize_path(fn.source_location.join(":"))
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Debugging
3
- VERSION = Gem.loaded_specs["rspec-debugging"].version.to_s
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.license = "MIT"
7
7
  s.name = File.basename(__FILE__, ".gemspec")
8
8
  s.summary = s.description
9
- s.version = "0.0.2"
9
+ s.version = "0.0.4"
10
10
 
11
11
  s.required_ruby_version = ">= 3.1"
12
12
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-debugging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-13 00:00:00.000000000 Z
10
+ date: 2025-02-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rspec-expectations
@@ -67,7 +66,6 @@ dependencies:
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  description: Tools to improve debugging in RSpec
70
- email:
71
69
  executables: []
72
70
  extensions: []
73
71
  extra_rdoc_files: []
@@ -87,7 +85,6 @@ homepage: https://github.com/dpep/rspec-debugging
87
85
  licenses:
88
86
  - MIT
89
87
  metadata: {}
90
- post_install_message:
91
88
  rdoc_options: []
92
89
  require_paths:
93
90
  - lib
@@ -102,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
99
  - !ruby/object:Gem::Version
103
100
  version: '0'
104
101
  requirements: []
105
- rubygems_version: 3.5.23
106
- signing_key:
102
+ rubygems_version: 3.6.3
107
103
  specification_version: 4
108
104
  summary: Tools to improve debugging in RSpec
109
105
  test_files: []