~ubuntu-branches/ubuntu/utopic/ruby-validatable/utopic-proposed

« back to all changes in this revision

Viewing changes to test/test_helper.rb

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2012-05-19 17:34:34 UTC
  • Revision ID: package-import@ubuntu.com-20120519173434-o3pdvc5suz2jzbv4
Tags: upstream-1.6.7
Import upstream version 1.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
require 'rubygems'
 
3
require 'mocha'
 
4
require 'dust'
 
5
require 'set'
 
6
require 'expectations'
 
7
 
 
8
require File.dirname(__FILE__) + '/../lib/validatable'
 
9
 
 
10
class << Test::Unit::TestCase
 
11
  def expect(expected_value, &block)
 
12
    define_method :"test_#{caller.first.split("/").last}" do
 
13
      begin
 
14
        assert_equal expected_value, instance_eval(&block)
 
15
      rescue Exception => ex
 
16
        raise ex unless expected_value.is_a?(Class) && ex.is_a?(expected_value)
 
17
        assert_equal expected_value, ex.class
 
18
      end
 
19
    end 
 
20
  end
 
21
end
 
22
 
 
23
class Test::Unit::TestCase
 
24
  def assert_array_equal a, b
 
25
    assert_equal Set.new(a), Set.new(b)
 
26
  end
 
27
end
 
28
 
 
29
class Array
 
30
  def to_blank_options_hash
 
31
    self.inject({}) {|hash, value| hash[value] = nil; hash }
 
32
  end
 
33
end
 
 
b'\\ No newline at end of file'