From 0cc176cdf9aa68f096b5587a5946d80a2b8b2ded Mon Sep 17 00:00:00 2001 From: Trey Lawrence Date: Sat, 21 Jul 2012 15:47:34 -0400 Subject: [PATCH] Add test case for ancestor modules and the show-source -s option --- test/test_default_commands/test_show_source.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/test_default_commands/test_show_source.rb b/test/test_default_commands/test_show_source.rb index 6f2c9c57..23169f95 100644 --- a/test/test_default_commands/test_show_source.rb +++ b/test/test_default_commands/test_show_source.rb @@ -237,7 +237,7 @@ if !mri18_and_no_real_source_location? it "source of variable should take precedence over method that is being shadowed" do string = mock_pry(@method_shadow,"show-source hello","exit-all") string.include?("def hello").should == false - string =~ /proc { ' smile ' }/ + string.should =~ /proc { ' smile ' }/ end it "source of method being shadowed should take precedence over variable @@ -261,7 +261,13 @@ if !mri18_and_no_real_source_location? end end + module ShowSourceTestSuperModule + def alpha + end + end + module ShowSourceTestModule + include ShowSourceTestSuperModule def alpha end end @@ -281,6 +287,7 @@ if !mri18_and_no_real_source_location? Object.remove_const :ShowSourceTestSuperClass Object.remove_const :ShowSourceTestClass Object.remove_const :ShowSourceTestClassWeirdSyntax + Object.remove_const :ShowSourceTestSuperModule Object.remove_const :ShowSourceTestModule Object.remove_const :ShowSourceTestModuleWeirdSyntax end @@ -298,6 +305,10 @@ if !mri18_and_no_real_source_location? mock_pry("show-source ShowSourceTestModule").should =~ /module ShowSourceTestModule/ end + it 'should show source for an ancestor module' do + mock_pry("show-source -s ShowSourceTestModule").should =~ /module ShowSourceTestSuperModule/ + end + it 'should show source for a class when Const = Class.new syntax is used' do mock_pry("show-source ShowSourceTestClassWeirdSyntax").should =~ /ShowSourceTestClassWeirdSyntax = Class.new/ end