From 7ded7de452d857218f50e9d30de30e57ee7212ba Mon Sep 17 00:00:00 2001 From: Shinji Yoshida Date: Mon, 5 Apr 2021 17:55:45 +0900 Subject: [PATCH] override inspect() of ref and lazy to make description readable --- lib/rspec/parameterized/lazy_arg.rb | 6 ++++++ lib/rspec/parameterized/ref_arg.rb | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/lib/rspec/parameterized/lazy_arg.rb b/lib/rspec/parameterized/lazy_arg.rb index 15f83f4..392791a 100644 --- a/lib/rspec/parameterized/lazy_arg.rb +++ b/lib/rspec/parameterized/lazy_arg.rb @@ -8,6 +8,12 @@ def initialize(&block) def apply(obj) obj.instance_eval(&@block) end + + def inspect + "#{@block.to_raw_source}" + rescue Parser::SyntaxError + super.inspect + end end end end diff --git a/lib/rspec/parameterized/ref_arg.rb b/lib/rspec/parameterized/ref_arg.rb index baa3d5e..da9de44 100644 --- a/lib/rspec/parameterized/ref_arg.rb +++ b/lib/rspec/parameterized/ref_arg.rb @@ -9,6 +9,10 @@ def initialize(symbol) def apply(obj) obj.send(@symbol) end + + def inspect + "#{@symbol}" + end end end end