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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +63 -1
- data/lib/rspec/debugging/debug_it.rb +7 -4
- data/lib/rspec/debugging/let_variables.rb +4 -0
- data/lib/rspec/debugging/version.rb +1 -1
- data/rspec-debugging.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36fab720f096a8d0db955d8560666e60cfb13e3346bee84fb228ab1638a6784d
|
4
|
+
data.tar.gz: f45cfa7bbc17ba60a3847c05e6feb38c3fb5dcfdeb93227e250bb8afb6cea75f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f69fb8e97573a353809337c5aac04a16d4659f5b0284e126b10db367afb18db1fe493db4cc76a473a03895a3e4eb712986f0fb4b47c1c1ed5d926e4ff9eef21
|
7
|
+
data.tar.gz: 726a432e06a848ccc328b9f9ee4857f2eea2754c48520079b2547186490da7c3e18aa6701143f57eb208b92534bfb80ce8e56ffb9a5826b0c1db22c5e8e3a8d6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,15 +4,77 @@ rspec-debugging
|
|
4
4
|
[](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
|
-
|
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
|
-
|
35
|
+
location = RSpec::Core::Metadata.relative_path(caller[2].split(":in").first)
|
36
36
|
|
37
37
|
example_block = Proc.new do
|
38
|
-
|
39
|
-
debugging: #{
|
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(":"))
|
data/rspec-debugging.gemspec
CHANGED
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.
|
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-
|
11
|
+
date: 2025-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-expectations
|