Sha256: 547a6c05d754fd81f722d51f94d779a924116f77293e5adcba089bce4d20218b

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe AdhearsionSequel::Plugin::Service do

  describe "when starting the Sequel connection" do
    def tempfile_with_content(contents)
      Tempfile.new("bogus_model").tap do |file|
        file.puts contents
        file.flush
      end
    end

    def sample_user_model
      <<-CODE
        class User < Sequel::Model
          set_primary_key [:name]
        end
      CODE
    end

    let :options do
      {
        :adapter => "mysql",
        :database => "test",
        :username => "root",
        :password => "",
        :host => "localhost",
        :port => 3306,
        :model_path => 'models'
      }
    end

    it "should raise an exception when no adapater has been configured" do
      Adhearsion.config.adhearsion_sequel.adapter = nil
      lambda { Adhearsion::Plugin.init_plugins }.should raise_error "Must supply an adapter to the AdhearsionSequel configuration"
    end

    it "establishes the connection with the not nil config values as options" do
      Adhearsion.config.adhearsion_sequel.database = "test"
      AdhearsionSequel::Plugin::Service.expects(:establish_connection).with(options).returns true
      AdhearsionSequel::Plugin::Service.start
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adhearsion_sequel-0.0.1 spec/adhearsion_sequel/plugin/service_spec.rb