Skip to content

Instantly share code, notes, and snippets.

@dholdren
Created July 10, 2014 19:43
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 dholdren/01df15ce88de21727ff6 to your computer and use it in GitHub Desktop.
Save dholdren/01df15ce88de21727ff6 to your computer and use it in GitHub Desktop.
RSpec hack
#solution for "Get this code to pass RSpec"
require 'rspec'
class Object
def should(*args);end
def should_not(*args);end
def method_missing(method,*args)
if method == :upcase
Object.new
else
super
end
end
end
class SomeClass
def initialize(*args); end
end
describe 'Foo' do
it "should always be true" do
1.should == 2
1.should == "a"
1.should_not == "a"
1.upcase.should == 3
SomeClass.new.should be_true
SomeClass.new('foobar').should be_true
SomeClass.new('foobar').should be_false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment