$: << File.dirname(__FILE__) + '/../lib' require 'logworm.rb' describe Logworm::DB, " initialization" do it "should only accept proper URLs" do lambda {Logworm::DB.new('')}.should raise_exception(Logworm::ForbiddenAccessException) lambda {Logworm::DB.new('http://www.test.com')}.should raise_exception(Logworm::ForbiddenAccessException) lambda {Logworm::DB.new('logworm://a:b@xxx/c/d')}.should raise_exception(Logworm::ForbiddenAccessException) lambda {Logworm::DB.new('logworm://a:b@/c/d/')}.should raise_exception(Logworm::ForbiddenAccessException) lambda {Logworm::DB.new('logworm://a:b@sda//d/')}.should raise_exception(Logworm::ForbiddenAccessException) lambda {Logworm::DB.new('logworm://:b@sda//d/')}.should raise_exception(Logworm::ForbiddenAccessException) lambda {Logworm::DB.new('logworm://a:b@xxx/c/d/')}.should_not raise_exception(Logworm::ForbiddenAccessException) end it "should be able to parse a proper logworm URL" do db = Logworm::DB.new('logworm://a:b@localhost:9401/c/d/') db.host.should == "localhost:9401" db.consumer_key.should == "a" db.consumer_secret.should == "b" db.token.should == "c" db.token_secret.should == "d" end it "should be able to read its configuration from a file" it "should be able to read its configuration from the current Heroku application" end describe Logworm::DB, " functioning" do before(:all) do @db = Logworm::DB.new('logworm://a:b@localhost:9401/c/d/') end it "should support a call to get the list of tables" do @db.should have(0).tables log_details = {:value => 10, :_ts => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"), :_ts_utc => (Time.now.utc.to_f * 1000).to_i} @db.batch_log([["log", log_details]]) @db.should have(1).tables end it "should support a call to start a query" it "should support a call to get the results of a query" it "should raise DFGD if 404" it "should raise DFGD if 403" it "should raise DFGD if 400" end