Sha256: ae4e075aa07fffe477d0a8c54bf4a8004bc000c97030b9ee39f0126e72fc9a3f

Contents?: true

Size: 1012 Bytes

Versions: 7

Compression:

Stored size: 1012 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

require 'sequel'

describe "Chatterbot::DB" do
  before(:each) do
    @db_tmp = Tempfile.new("config.db")
    @db_uri = "sqlite://#{@db_tmp.path}"

    @bot = Chatterbot::Bot.new    
    @bot.config[:db_uri] = @db_uri
  end

  describe "get_connection" do
    it "should make sure sequel is actually installed" do
      @bot.stub!(:has_sequel?).and_return(false)
      @bot.should_receive(:display_db_config_notice)
      @bot.db
    end
  end
  
  describe "table creation" do
    [:blacklist, :tweets, :config].each do |table|
      it "should create table #{table}" do
        @bot.db
        @tmp_conn = Sequel.connect(@db_uri)
        @tmp_conn.tables.include?(table).should == true
      end
    end      
  end
  
  describe "store_database_config" do
    it "doesn't fail" do
      @bot = Chatterbot::Bot.new    
      @bot.config[:db_uri] = @db_uri

      @bot.db      
      @bot.store_database_config.should == true
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chatterbot-0.6.3 spec/db_spec.rb
chatterbot-0.6.2 spec/db_spec.rb
chatterbot-0.6.1 spec/db_spec.rb
chatterbot-0.5.1 spec/db_spec.rb
chatterbot-0.5.0 spec/db_spec.rb
chatterbot-0.4.0 spec/db_spec.rb
chatterbot-0.3.0 spec/db_spec.rb