Sha256: b4e80c07586512c292bd3895476f826141450b10dd09ea5e8ab473265c3d1c1a

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

require 'spec_helper'

describe ROM::Relation do
  subject(:relation) { ROM::Relation.new(dataset, dataset.header) }

  let(:dataset) { ROM::Adapter::Memory::Dataset.new([jane, joe], [:id, :name]) }

  let(:jane) { { id: 1, name: 'Jane' } }
  let(:joe) { { id: 2, name: 'Joe' } }

  describe "#header" do
    it "return's duplicated and frozen dataset header" do
      expect(relation.header).to be_frozen
      expect(relation.header).not_to be(dataset.header)
    end
  end

  describe "#each" do
    it "yields all objects" do
      result = []

      relation.each do |user|
        result << user
      end

      expect(result).to eql([jane, joe])
    end

    it "returns an enumerator if block is not provided" do
      expect(relation.each).to be_instance_of(Enumerator)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-0.4.2 spec/unit/rom/relation_spec.rb
rom-0.4.1 spec/unit/rom/relation_spec.rb