Sha256: 3a18539de948a53c9643e937b45e0f5fbc3971e976558625a9b62d80c187a823

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

RSpec.describe Employee::Collection do
  describe '.find' do
    describe 'empty argument' do
      it 'returns an empty collection when initialized with nil' do
        described_class.find(nil).should be_a described_class
        described_class.find(nil).should be_empty
      end
      it 'returns an empty collection when initialized with empty string' do
        described_class.find('').should be_a described_class
        described_class.find('').should be_empty
      end
      it 'returns an empty collection when initialized with empty array' do
        described_class.find([]).should be_a described_class
        described_class.find([]).should be_empty
      end
    end

    describe 'existing records' do
      it "finds the records" do
        employee1 = Employee.create name: 'E1', section: 'ABC', admin: true, vegan: false
        employee2 = Employee.create name: 'E2', section: 'QNP', admin: false, vegan: false
        described_class.find([employee1.id, employee2.id]).collection.should match_array [employee1, employee2]
      end
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
record_collection-0.4.6 spec/base/finding_records_spec.rb
record_collection-0.4.5 spec/base/finding_records_spec.rb
record_collection-0.4.4 spec/base/finding_records_spec.rb
record_collection-0.4.3 spec/base/finding_records_spec.rb
record_collection-0.4.2 spec/base/finding_records_spec.rb
record_collection-0.4.1 spec/base/finding_records_spec.rb
record_collection-0.4.0 spec/base/finding_records_spec.rb