require 'spec_helper'

describe CephStorage::PoolEnumerator do
  let(:config) { cluster_config }
  let(:spconfig) { spec_config }
  let(:cluster) { CephStorage::ClusterFactory.build config }
  let(:pool_name) { spconfig[:pool][:name] }
  let(:pool) { cluster.pool(pool_name) }
  let(:object_name) { spconfig[:pool][:object] }
  let(:pool_enumerator) { cluster.pools }
  subject { pool_enumerator }

  it 'should be a CephStorage::PoolEnumerator' do
    expect(subject).to be_a ::CephStorage::PoolEnumerator
  end

  describe 'before pool creation' do
    it 'should not have the test pool in it' do
      expect(subject.any? { |p| p.name ==  pool_name }).to be false
    end
  end

  describe 'after pool creation' do
    before { pool.create }
    after { pool.destroy }
    it 'should have the test pool in it' do
      expect(subject.any? { |p| p.name ==  pool_name }).to be true
    end

    it 'should return pool objects' do
      expect(subject.first).to be_a ::CephStorage::Pool
    end
  end
end