Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 3d76fd1

Browse files
committed
Merge pull request #1620 from rspec/expose_sensible_procsy_inspect
Expose a better inspect value for Example::Procsy
2 parents 2bd27ee + c5b5627 commit 3d76fd1

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Enhancements:
66
* Update files generated by `rspec --init` so that warnings are enabled
77
in commented out section of `spec_helper` rather than `.rspec` so users
88
have to consciously opt-in to the setting. (Andrew Hooker, #1572)
9+
* Provide an `inspect` output for example procsy objects (used in around
10+
hooks) that doesn't make them look like procs. (Jon Rowe, #1620)
911

1012
Bug Fixes:
1113

lib/rspec/core/example.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ def initialize(example, &block)
220220
def wrap(&block)
221221
self.class.new(example, &block)
222222
end
223+
224+
# @private
225+
def inspect
226+
@example.inspect.gsub('Example', 'ExampleProcsy')
227+
end
223228
end
224229

225230
# @private

spec/rspec/core/hooks_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ def self.data_from(ex)
181181
expect(data_1).to eq(expected_data)
182182
expect(data_2).to eq(expected_data)
183183
end
184+
185+
it "exposes a sensible inspect value" do
186+
inspect_value = nil
187+
group = ExampleGroup.describe do
188+
around do |ex|
189+
inspect_value = ex.inspect
190+
end
191+
192+
it "does something" do
193+
end
194+
end
195+
196+
group.run
197+
expect(inspect_value).to match /ExampleProcsy/
198+
end
184199
end
185200

186201
context "when running the example within a block passed to a method" do

0 commit comments

Comments
 (0)