Sha256: 31a507d604431be209ab8cdad8f353b574c69d337be7bbd59f2b2be7bae1c51e

Contents?: true

Size: 1.12 KB

Versions: 25

Compression:

Stored size: 1.12 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
    path_finder.stub(:find) {|path| nil}
    path_finder.stub(:find).with(path).and_return(full_path)
    path_finder.stub(: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

25 entries across 25 versions & 2 rubygems

Version Path
opal-0.10.3 spec/lib/path_reader_spec.rb
opal-0.10.2 spec/lib/path_reader_spec.rb
opal-0.10.1 spec/lib/path_reader_spec.rb
opal-0.10.0 spec/lib/path_reader_spec.rb
opal-0.10.0.rc2 spec/lib/path_reader_spec.rb
opal-0.9.4 spec/lib/path_reader_spec.rb
opal-0.9.3 spec/lib/path_reader_spec.rb
opal-0.10.0.rc1 spec/lib/path_reader_spec.rb
opal-0.10.0.beta5 spec/lib/path_reader_spec.rb
opal-0.10.0.beta4 spec/lib/path_reader_spec.rb
opal-0.10.0.beta3 spec/lib/path_reader_spec.rb
opal-0.10.0.beta2 spec/lib/path_reader_spec.rb
opal-0.10.0.beta1 spec/lib/path_reader_spec.rb
opal-0.9.2 spec/lib/path_reader_spec.rb
opal-0.9.0 spec/lib/path_reader_spec.rb
opal-0.9.0.rc1 spec/lib/path_reader_spec.rb
opal-0.9.0.beta2 spec/lib/path_reader_spec.rb
opal-0.9.0.beta1 spec/lib/path_reader_spec.rb
opal-0.8.1 spec/lib/path_reader_spec.rb
opal-0.8.1.rc1 spec/lib/path_reader_spec.rb