Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Created August 14, 2011 13:17
Show Gist options
  • Save ashmoran/1144868 to your computer and use it in GitHub Desktop.
Save ashmoran/1144868 to your computer and use it in GitHub Desktop.
Testing Ruby alias_method
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
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