Created
September 24, 2012 23:14
-
-
Save ivanacostarubio/3779025 to your computer and use it in GitHub Desktop.
ICANHAZTYPOS
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
source :rubygems | |
gem 'levenshtein-ffi', :require => 'levenshtein' | |
gem "rspec" |
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
Please nominate this for the worst idea of 2012 | |
The ICANHAZTYPOS module allow you to have typos by calling the first method with a Levenshtein distance of 1. |
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
require 'levenshtein' | |
module ICANHAZTYPOS | |
def method_missing(name, *args, &block) | |
methods.each do |m| | |
return self.send(m) if Levenshtein.distance(m.to_s, name.to_s) == 1 | |
end | |
end | |
end | |
class WTF | |
include ICANHAZTYPOS | |
def attempt | |
"wtf" | |
end | |
end | |
describe Object do | |
let(:wtf) { WTF.new } | |
it "does just as expected" do | |
wtf.attempt.should == "wtf" | |
end | |
it "does other things" do | |
wtf.attemp.should == "wtf" | |
end | |
it "makes my cry" do | |
wtf.atempt.should == "wtf" | |
end | |
end |
Author
ivanacostarubio
commented
Sep 24, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment