summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2014-01-06 10:24:43 +0100
committerAzul <azul@riseup.net>2014-02-04 11:46:57 +0100
commit87d76281eb374f4c4538fe5bf5b774b73dd5d7e3 (patch)
tree936913499080574af13b4b1c48fe6d4fd07e9cc1 /test
parent88083a47eb042fd5b3f6cfd9cae1e087bc9fa072 (diff)
first interesting tests
Diffstat (limited to 'test')
-rw-r--r--test/integration/tapicero_test.rb51
-rw-r--r--test/test_helper.rb2
2 files changed, 52 insertions, 1 deletions
diff --git a/test/integration/tapicero_test.rb b/test/integration/tapicero_test.rb
index b83263a..d436e6d 100644
--- a/test/integration/tapicero_test.rb
+++ b/test/integration/tapicero_test.rb
@@ -1,4 +1,55 @@
require File.expand_path('../../test_helper.rb', __FILE__)
class TapiceroTest < MiniTest::Unit::TestCase
+
+ def test_loads_config
+ assert_equal "tapicero-test", config.connection[:prefix]
+ assert_equal "debug", config.send(:log_level)
+ end
+
+ def test_database_exists
+ assert database
+ end
+
+ def test_creates_user_db_fast
+ user_id = create_user['id']
+ database.save_doc :id => user_id
+ assert user_database(user_id)
+ end
+
+ def test_creates_user_db_slow
+ user_id = create_user['id']
+ sleep 1
+ assert user_database(user_id)
+ end
+
+ def test_configures_security
+ user_id = create_user['id']
+ sleep 1
+ assert_equal config.options[:security], user_database(user_id).get(_security)
+ end
+
+ def create_user
+ database.save_doc :some => :content
+ end
+
+ def user_database(name)
+ host.database(config.options[:db_prefix] + name)
+ 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
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 3857e2c..227cde5 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -6,5 +6,5 @@ $:.unshift File.expand_path('lib', BASE_DIR)
require 'mocha/setup'
-TAPICERO_CONFIG = "test/config/config.yaml"
+TAPICERO_CONFIG = "test/config.yaml"
require 'tapicero'