opal-sprockets 0.4.9.1.0.3.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
- require 'shared/path_reader_shared'
3
- require 'opal/sprockets/path_reader'
4
-
5
- describe Opal::Sprockets::PathReader do
6
- let(:env) { Sprockets::Environment.new }
7
- let(:context) { double('context', depend_on: nil, depend_on_asset: nil) }
8
- let(:contents) { File.read(full_path) }
9
- let(:full_path) { fixtures_dir.join(logical_path+'.js.rb') }
10
- let(:logical_path) { 'sprockets_file' }
11
- let(:fixtures_dir) { Pathname('../../fixtures/').expand_path(__FILE__) }
12
-
13
- subject(:path_reader) { described_class.new(env, context) }
14
-
15
- before do
16
- Opal.paths.each {|p| env.append_path(p)}
17
- env.append_path fixtures_dir
18
- end
19
-
20
- include_examples :path_reader do
21
- let(:path) { logical_path }
22
- end
23
-
24
- it 'can read stuff from sprockets env' do
25
- expect(path_reader.read(logical_path)).to eq(contents)
26
- end
27
-
28
- it 'reads js files processing their directives' do
29
- path = 'file_with_directives.js'
30
- full_path = fixtures_dir.join(path)
31
- required_contents = File.read(fixtures_dir.join('required_file.js')).strip
32
- read_contents = path_reader.read(path)
33
- actual_contents = full_path.read
34
-
35
- expect(actual_contents).to include('//= require')
36
- expect(read_contents).not_to include('//= require')
37
-
38
- expect(read_contents).to include(required_contents)
39
- expect(actual_contents).not_to include(required_contents)
40
- end
41
- end