test/test_helper.rb in mattly-exegesis-0.2.2 vs test/test_helper.rb in mattly-exegesis-0.2.3
- old
+ new
@@ -1,40 +1,49 @@
require 'rubygems'
-require 'test/unit'
+require 'minitest/spec'
+MiniTest::Unit.autorun
-require 'context' # with github: gem install jeremymcanally-context
-require 'matchy' # best bet for now: clone from github and build yourself; when jeremy fixes matchy, jeremymcanally-matchy
-require 'zebra' # until jeremy updates matchy, download and build yourself, after that, with github: gem install giraffesoft-zebra
-
-begin
- require 'ruby-debug'
- Debugger.start
-rescue
- puts "no ruby-debug installed? REAlLY? ok, if that's how you roll..."
+unless RUBY_VERSION =~ /^1\.9/
+ begin
+ require 'ruby-debug'
+ Debugger.start
+ rescue
+ puts "protip: `(sudo) gem install ruby-debug` for superhuman debugging powers"
+ end
end
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'lib/exegesis'
class TestingDatabase
include Exegesis::Database
end
-class Test::Unit::TestCase
+class MiniTest::Spec
+ # beacuse test names are really just comments, and therefore a code smell
+ def self.expect(desc=nil, &block)
+ @counter ||= 0; @counter += 1
+ desc ||= "[#{@counter}]"
+ name = ["test_", description_stack.join(' '), desc].join(' ')
+ define_method name, &block
+ end
+end
+
+class MiniTest::Unit::TestCase
def fixtures_path fixtures
File.join(File.dirname(__FILE__), 'fixtures', fixtures)
end
def db_server
@db_server ||= Exegesis::Server.new('http://localhost:5984')
end
# todo: extract to some helper methods to include ala RR, etc
- def reset_db(name=nil)
+ def reset_db(name=nil, klass=TestingDatabase)
RestClient.delete "http://localhost:5984/#{db(name)}" rescue nil
db_server.create_database(db(name))
- @db = TestingDatabase.new(db_server, db(name))
+ @db = klass.new(db_server, db(name))
end
def db(name)
"exegesis-test#{name.nil? ? '' : "-#{name}"}"
end
\ No newline at end of file