Sha256: c2772d91cf33e9f2c3bad56c5e9c6a26ac902aca8ee924deb403ef5f6f1c56fa

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'shared/rom/files/media_relation'

RSpec.describe ROM::Files::Relation, '#to_a' do
  include_context 'media relation'

  let(:names) { relation.pluck(:basename) }
  let(:paths) { relation.to_a.map { |file| file[:__FILE__] } }

  its(:to_a) { is_expected.to eq data }
  its(:schema) { is_expected.to be_a ROM::Files::Schema }

  it 'lists file paths' do
    expect(paths).to eql([
                           P('media/some_image.png'),
                           P('media/some_file.txt'),
                           P('media/some_markdown.md')
                         ])
  end

  context 'names' do
    subject { names }

    it { is_expected.to eql([P('some_image.png'), P('some_file.txt'), P('some_markdown.md')]) }

    context 'with custom view using select' do
      let(:relation) { super().text_files }

      it { is_expected.to eql [P('some_file.txt'), P('some_markdown.md')] }
    end

    context 'with custom view using reject' do
      let(:relation) { super().binary_files }

      it { is_expected.to eql [P('some_image.png')] }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-files-0.2.0 spec/lib/rom/files/relation/to_a_spec.rb