diff options
Diffstat (limited to 'test/support/integration_test.rb')
-rw-r--r-- | test/support/integration_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/support/integration_test.rb b/test/support/integration_test.rb new file mode 100644 index 0000000..b28c0e1 --- /dev/null +++ b/test/support/integration_test.rb @@ -0,0 +1,39 @@ +module Tapicero + class IntegrationTest < MiniTest::Unit::TestCase + + def create_user(fast = false) + result = database.save_doc :some => :content + raise RuntimeError.new(result.inspect) unless result['ok'] + sleep 1 unless fast # allow tapicero to do its job + @user = {'_id' => result["id"], '_rev' => result["rev"]} + end + + def delete_user(fast = false) + return if @user.nil? or @user['_deleted'] + result = database.delete_doc @user + raise RuntimeError.new(result.inspect) unless result['ok'] + @user['_deleted'] = true + sleep 1 unless fast # allow tapicero to do its job + end + + def user_database + host.database(config.options[:db_prefix] + @user['_id']) + end + + def database + @database ||= host.database(database_name) + end + + def database_name + config.complete_db_name('users') + end + + def host + @host ||= CouchRest.new(config.couch_host) + end + + def config + Tapicero.config + end + end +end |