cirandas.net

ref: master

test/support/should.rb


 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
module Test

  module Should

    def should name, &block
      @shoulds ||= []

      destname = 'test_should_' + name.gsub(/[^a-zA-z0-9]+/, '_')
      if @shoulds.include?(destname)
        raise "there is already a test named \"#{destname}\""
      end

      @shoulds << destname
      if block_given?
        self.send(:define_method, destname, &block)
      else
        self.send(:define_method, destname) do
          flunk 'pending: should ' + name
        end
      end

    end

  end

end