Created
August 14, 2011 13:17
-
-
Save ashmoran/1144868 to your computer and use it in GitHub Desktop.
Testing Ruby alias_method
This file contains hidden or 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
| class SatoshiVersion | |
| # ... | |
| def to_s | |
| components = @version_components.dup | |
| components.delete_at(3) if components[3] == 0 | |
| components.join(".") | |
| end | |
| alias_method :to_str, :to_s | |
| end |
This file contains hidden or 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
| describe "conversion" do | |
| describe "to strings" do | |
| # ... | |
| it "supports #to_str as an alias of :to_s" do | |
| version = SatoshiVersion.new(0, 3, 24) | |
| to_s_method = version.method(:to_s) | |
| to_str_method = version.method(:to_str) | |
| to_str_method.should eq to_s_method | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment