Skip to content

Instantly share code, notes, and snippets.

@brixen
Created April 10, 2012 23:17
Show Gist options
  • Select an option

  • Save brixen/2355525 to your computer and use it in GitHub Desktop.

Select an option

Save brixen/2355525 to your computer and use it in GitHub Desktop.
git show 958a0e9b1a06 in the Rubinius repo
# minispec
#
# Very minimal set of features to support specs like this:
#
# context "Array" do
# specify "should respond to new" do
# Array.new.should == []
# end
# end
class PostiveSpec
def initialize(obj)
@obj = obj
end
def ==(other)
if @obj != other
raise Exception.new("equality expected")
end
end
end
class NegativeSpec
def initialize(obj)
@obj = obj
end
def ==(other)
if @obj == other
raise Exception.new("inequality expected")
end
end
end
class Object
def should
PostiveSpec.new(self)
end
def should_not
NegativeSpec.new(self)
end
end
def specify(msg)
print '.'
begin
yield
rescue Exception => e
print msg
print " FAILED\n"
print e.message
print "\n"
end
end
def context(msg)
yield
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment