Skip to content

Instantly share code, notes, and snippets.

@chubas
Forked from ivanacostarubio/Gemfile
Created September 28, 2012 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chubas/3800523 to your computer and use it in GitHub Desktop.
Save chubas/3800523 to your computer and use it in GitHub Desktop.
ICANHAZTYPOS
source :rubygems
gem 'levenshtein-ffi', :require => 'levenshtein'
gem "rspec"
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.
require 'levenshtein'
module ICANHAZTYPOS
def method_missing(name, *args, &block)
methods.each do |m|
return self.send(m, *args, &block) 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment