Sha256: a18b9eb6f6e47f4167af81c5c553dfd7983217cbbc7872c12ca3ee49642690da

Contents?: true

Size: 1.47 KB

Versions: 10

Compression:

Stored size: 1.47 KB

Contents

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

describe "App" do
  describe "initialization" do
    it "should set root as pathname" do
      app = Rid::App.new
      app.root.should be_a(Pathname)
    end

    it "should set root from options" do
      app = Rid::App.new(OpenStruct.new(:root => "myroot"))
      app.root.should == Pathname.new("myroot")
    end

    it "should default root to pwd" do
      app = Rid::App.new
      app.root.should == Pathname.new(Dir.pwd)
    end

    it "should set database url from options" do
      app = Rid::App.new(OpenStruct.new(:database => "mydb"))
      app.db_url.should == "mydb"
    end

    it "should default database url to contents of _database file at root" do
      app = Rid::App.new(OpenStruct.new(:root => mock_app_root))
      app.db_url.should == "mydb"
    end
  end

  describe "db" do
    before do
      @app = Rid::App.new(OpenStruct.new(:database => "mydb"))
    end

    it "should return an instance od Rid::Database" do
      @app.db.should be_a(Rid::Database)
    end

    it "should return a database set to db_name" do
      @app.db.name.should == 'mydb'
    end
  end

  describe "documents" do
    before do
      @app = Rid::App.new(OpenStruct.new(:root => mock_app_root))
    end

    it "should be an array" do
      @app.documents.should be_a(Array)
    end

    it "should return Document instances" do
      @app.documents.all? { |d| d.should be_a(Rid::Document) }
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rid-core-1.5.2 spec/rid/app_spec.rb
rid-core-1.5.1 spec/rid/app_spec.rb
rid-core-1.5.0 spec/rid/app_spec.rb
rid-core-1.4.0 spec/rid/app_spec.rb
rid-core-1.3.0 spec/rid/app_spec.rb
rid-core-1.2.0 spec/rid/app_spec.rb
rid-core-1.1.0 spec/rid/app_spec.rb
rid-core-1.0.3 spec/rid/app_spec.rb
rid-1.0.3 spec/rid/app_spec.rb
rid-1.0.2 spec/rid/app_spec.rb