Sha256: 879729c8f647f4f8bf4febf91ac52fcdfe9f97815e349b2485b77dddbeb33793

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require 'lib/spec_helper'
require 'lib/shared/path_reader_shared'
require 'lib/shared/path_finder_shared'
require 'opal/path_reader'


describe Opal::PathReader do
  subject(:file_reader) { described_class.new(path_finder) }
  let(:path_finder) { double('path_finder') }
  let(:path) { 'opal_file' }
  let(:full_path) { File.expand_path('../fixtures/opal_file.rb', __FILE__) }
  let(:contents) { File.read(full_path) }

  before do
    allow(path_finder).to receive(:find) {|path| nil}
    allow(path_finder).to receive(:find).with(path).and_return(full_path)
    allow(path_finder).to receive(:paths).and_return(Opal.paths)
  end

  include_examples :path_finder
  include_examples :path_reader do
    let(:path_reader) { file_reader }

    it 'works with absolute paths' do
      expect(path_reader.read(File.expand_path(__FILE__))).not_to be_nil
    end

    it 'works with relative paths starting with ./' do
      expect(path_reader.read('./spec/lib/shared/path_reader_shared.rb')).not_to be_nil
    end

    it 'works with absolute paths' do
      expect(path_reader.read("../#{File.basename(Dir.pwd)}/spec/lib/shared/path_reader_shared.rb")).not_to be_nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-0.10.6 spec/lib/path_reader_spec.rb
opal-0.10.6.beta spec/lib/path_reader_spec.rb
opal-0.10.5 spec/lib/path_reader_spec.rb
opal-0.10.4 spec/lib/path_reader_spec.rb
opal-0.11.0.rc1 spec/lib/path_reader_spec.rb