Sha256: 9540288e28deae9ffd701f0445cb8980a7db58982752919d12ef8b0c6ace4aa3

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

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

describe CouchRestRails::Views do

  before :each do
    CouchRest.delete(COUCHDB_CONFIG[:full_path]) rescue nil
  end
  
  after :all do
    CouchRest.delete(COUCHDB_CONFIG[:full_path]) rescue nil
  end

  describe '#create' do
  
    it 'should create a CouchDB database for the current environment' do
      CouchRestRails::Database.create
      res = CouchRest.get(COUCHDB_CONFIG[:full_path])
      res['db_name'].should == COUCHDB_CONFIG[:database]
    end

    it 'should do nothing and display a message if the database already exists' do
      CouchRest.database!("#{COUCHDB_CONFIG[:full_path]}")
      res = CouchRestRails::Database.create
      res.should =~ /already exists/i
    end

  end
  
  describe "#delete" do
    
    it 'should delete the CouchDB database for the current environment' do
      CouchRest.database!("#{COUCHDB_CONFIG[:full_path]}")
      CouchRestRails::Database.delete
      lambda {CouchRest.get(COUCHDB_CONFIG[:full_path])}.should raise_error('Resource not found')
    end

    it 'should do nothing and display a message if the database does not exist' do
      res = CouchRestRails::Database.delete
      res.should =~ /does not exist/i
    end
    
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
therealadam-couchrest-rails-0.1.1 spec/lib/couch_rest_rails/database_spec.rb