Sha256: d9db8fbba3fc613f2c1d5abea428001784dfae7c5e6b8af141427189164179d8

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

describe CouchPotato, 'full_url_to_database' do
  before(:each) do
    @original_database_name = CouchPotato::Config.database_name
  end
  after(:each) do
    CouchPotato::Config.database_name = @original_database_name
  end

  it "should add the default localhost and port if only a name is set" do
    CouchPotato::Config.database_name = 'test'
    expect(CouchPotato.full_url_to_database).to eq('http://127.0.0.1:5984/test')
  end

  it "should return the set url" do
    CouchPotato::Config.database_name = 'http://db.local/test'
    expect(CouchPotato.full_url_to_database).to eq('http://db.local/test')
  end
end

describe CouchPotato, 'use' do
  it 'should return the db object' do
    db = CouchPotato.use("testdb")
    expect(db.couchrest_database.root.to_s).to eq('http://127.0.0.1:5984/testdb')
  end
end

describe CouchPotato, '.models' do
  it "returns all classes that have implemented CouchPotato::Persistence" do
    clazz = Class.new
    clazz.send(:include, CouchPotato::Persistence)

    expect(CouchPotato.models).to include(clazz)
  end

  it 'returns all subclasses of classes that have implemented CouchPotato::Persistence' do
    clazz = Class.new
    clazz.send(:include, CouchPotato::Persistence)
    subclazz = Class.new clazz

    expect(CouchPotato.models).to include(subclazz)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
couch_potato-1.7.1 spec/unit/couch_potato_spec.rb
couch_potato-1.7.0 spec/unit/couch_potato_spec.rb
couch_potato-1.6.5 spec/unit/couch_potato_spec.rb
couch_potato-1.6.4 spec/unit/couch_potato_spec.rb
couch_potato-1.6.3 spec/unit/couch_potato_spec.rb