From d9d9e7e22da73816b19af703eeca299d8d3e763e Mon Sep 17 00:00:00 2001 From: Waldyr Date: Sat, 2 Apr 2016 13:02:22 -0300 Subject: [PATCH 1/2] Add test for new #no_definition_message --- spec/commands/show_source_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb index 16f65a33..5cf4f0c1 100644 --- a/spec/commands/show_source_spec.rb +++ b/spec/commands/show_source_spec.rb @@ -71,6 +71,13 @@ describe "show-source" do expect(mock_pry(binding, "show-source _c#wrongmethod")).to match(/Couldn't locate/) end + it "should not show the source and deliver an error message without exclamation point" do + _c = Class.new + error_message = "Error: Couldn't locate a definition for _c#wrongmethod" + expect(mock_pry(binding, "show-source _c#wrongmethod")).to eq(error_message) + end + + it "should find instance_methods if the class overrides instance_method" do _c = Class.new{ def method; From f2cdb9a2e5269d9dff4c369ee0de732b434f9596 Mon Sep 17 00:00:00 2001 From: Waldyr Date: Sat, 2 Apr 2016 13:02:36 -0300 Subject: [PATCH 2/2] Remove exclamation point from #no_definition_message Add \n in the end of expected error message --- lib/pry/commands/show_info.rb | 2 +- spec/commands/show_source_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pry/commands/show_info.rb b/lib/pry/commands/show_info.rb index b71ea247..a9814b76 100644 --- a/lib/pry/commands/show_info.rb +++ b/lib/pry/commands/show_info.rb @@ -93,7 +93,7 @@ class Pry end def no_definition_message - "Couldn't locate a definition for #{obj_name}!" + "Couldn't locate a definition for #{obj_name}" end # Generate a header (meta-data information) for all the code diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb index 5cf4f0c1..6e18ceb9 100644 --- a/spec/commands/show_source_spec.rb +++ b/spec/commands/show_source_spec.rb @@ -73,7 +73,7 @@ describe "show-source" do it "should not show the source and deliver an error message without exclamation point" do _c = Class.new - error_message = "Error: Couldn't locate a definition for _c#wrongmethod" + error_message = "Error: Couldn't locate a definition for _c#wrongmethod\n" expect(mock_pry(binding, "show-source _c#wrongmethod")).to eq(error_message) end