rspec-debugging 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
  SHA256:
3
- metadata.gz: 9d232979bdf2295fb58cec0c7295355366fb703f74e327d0d87d6d6febc35da9
4
- data.tar.gz: 98d1146bb2abb4e83f4308f47f302d74755c1d5b1f2c622ef216390ec25c6496
3
+ metadata.gz: 36fab720f096a8d0db955d8560666e60cfb13e3346bee84fb228ab1638a6784d
4
+ data.tar.gz: f45cfa7bbc17ba60a3847c05e6feb38c3fb5dcfdeb93227e250bb8afb6cea75f
5
5
  SHA512:
6
- metadata.gz: b22241789c483ef578ef866f7262e263938629486ed90f931f0a09511d3b662b0818cbbccd7cb5f3df2c441be2decdadfd775c6e61c37fcf080b5a100d245bb6
7
- data.tar.gz: d537656b7b9d64d8e572a2844e83dfd86450bb1a803a910f58322d5a14ec23d62a6b00e3958f27d5f9bd2ba2d50ab5292abf4a6fe97a7837e341a8c81d7db770
6
+ metadata.gz: 6f69fb8e97573a353809337c5aac04a16d4659f5b0284e126b10db367afb18db1fe493db4cc76a473a03895a3e4eb712986f0fb4b47c1c1ed5d926e4ff9eef21
7
+ data.tar.gz: 726a432e06a848ccc328b9f9ee4857f2eea2754c48520079b2547186490da7c3e18aa6701143f57eb208b92534bfb80ce8e56ffb9a5826b0c1db22c5e8e3a8d6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.0.3 (2025-01-21)
2
+ - let_variable_reset
3
+ - test coverage
4
+ - readme
5
+
1
6
  ### 0.0.2 (2025-01-14)
2
7
  - dit - debugging examples
3
8
 
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.3)
5
5
  rspec-expectations (>= 3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,15 +4,77 @@ 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
+
10
+ Debug broken specs
11
+ ----
12
+ Use `dit`, `dcontext`, or `ddescribe` to run a subset of examples and and start the debugger if anything breaks.
8
13
 
9
14
  ```ruby
10
15
  require "rspec/debugging"
11
16
 
17
+ describe MySpec do
18
+ dit { is_expected.to ... }
19
+ end
20
+ ```
21
+
22
+
23
+ Stop and explore
24
+ ----
25
+ Drop `dit` anywhere to start a debugger.
12
26
 
27
+ ```ruby
28
+ describe MySpec do
29
+ dit
30
+ end
13
31
  ```
14
32
 
15
33
 
34
+ Got let variables?
35
+ ----
36
+ `let` variables are great, but complexity can obscure their value.
37
+
38
+ ```ruby
39
+ describe RSpec::Debugging do
40
+ describe RSpec::Debugging::LetVariables do
41
+ subject { a }
42
+
43
+ let(:a) { "a" }
44
+ let!(:b) { "b" }
45
+
46
+ it { is_expected.to be ??? }
47
+
48
+ context "when we nest" do
49
+ let(:a) { "A" + b }
50
+
51
+ it { is_expected.to be ??? }
52
+
53
+ context "...and nest" do
54
+ let(:a) { super() * 2 }
55
+
56
+ it { is_expected.to be ??? }
57
+ end
58
+ end
59
+ ```
60
+
61
+ ...add a hundred lines of legacy code and then solve for `a`. Or use tooling :)
62
+
63
+ ### let_variables
64
+ * Returns the list of variables defined by RSpec `let`
65
+
66
+
67
+ ### let_variable_initialized?(name)
68
+ * Has the specified let variable been initialized?
69
+
70
+
71
+ ### let_variable_get(name)
72
+ * Returns the value of a let variable, if initialized
73
+
74
+ ### let_variable_values(name)
75
+ * Return all locations where the specified variable has been defined or redefined, and it's value at each location.
76
+
77
+
16
78
  ----
17
79
  ## Contributing
18
80
 
@@ -17,7 +17,7 @@ module RSpec
17
17
  end
18
18
 
19
19
  if e
20
- STDERR.puts <<~MSG
20
+ $stderr.puts <<~MSG
21
21
 
22
22
  Error:
23
23
  #{e.message}
@@ -32,15 +32,18 @@ module RSpec
32
32
  # called with no block
33
33
  user_metadata.delete(:skip)
34
34
 
35
- file, line = caller[2].split(":")
35
+ location = RSpec::Core::Metadata.relative_path(caller[2].split(":in").first)
36
36
 
37
37
  example_block = Proc.new do
38
- STDERR.puts <<~MSG
39
- debugging: #{file}:#{line}
38
+ $stderr.puts <<~MSG
39
+ debugging: #{location}
40
40
 
41
41
  MSG
42
42
 
43
43
  debugger
44
+ end.tap do |block|
45
+ # redefine source_location to return the correct location
46
+ block.define_singleton_method(:source_location) { location.split(":") }
44
47
  end
45
48
  end
46
49
 
@@ -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.3"
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.3"
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.2
4
+ version: 0.0.3
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-13 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-expectations