Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'helper' | ||
|
||
describe Pry::Method::Patcher do | ||
|
||
before do | ||
@x = Object.new | ||
def @x.test; :before; end | ||
@method = Pry::Method(@x.method(:test)) | ||
end | ||
|
||
it "should change the behaviour of the method" do | ||
@x.test.should == :before | ||
@method.redefine "def @x.test; :after; end\n" | ||
@x.test.should == :after | ||
end | ||
|
||
it "should return a new method with new source" do | ||
@method.source.strip.should == "def @x.test; :before; end" | ||
@method.redefine("def @x.test; :after; end\n"). | ||
source.strip.should == "def @x.test; :after; end" | ||
end | ||
|
||
it "should change the source of new Pry::Method objects" do | ||
@method.redefine "def @x.test; :after; end\n" | ||
Pry::Method(@x.method(:test)).source.strip.should == "def @x.test; :after; end" | ||
end | ||
end |