Sha256: b9055d6c3af125393dcf120f85195bd8693112c2987ae0d25a64e1ccf344ad55

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 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'
    CouchPotato.full_url_to_database.should == 'http://127.0.0.1:5984/test'
  end

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

describe CouchPotato, 'use' do
  it 'should return the db object' do
    db = CouchPotato.use("testdb")
    db.couchrest_database.root.should == '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.4.0 spec/unit/couch_potato_spec.rb
couch_potato-1.3.0 spec/unit/couch_potato_spec.rb
couch_potato-1.2.0 spec/unit/couch_potato_spec.rb
couch_potato-1.1.4 spec/unit/couch_potato_spec.rb
couch_potato-1.1.2 spec/unit/couch_potato_spec.rb