1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# minispec
#
# Very minimal set of features to support specs like this:
#
# describe "Array" do
#   it "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 it(msg)
  print '.'
  begin
    yield
  rescue Exception => e
    print msg
    print " FAILED\n"
    print e.message
    print "\n"
  end
end

def describe(msg)
  yield
end