opal 0.10.3 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -2
- data/.travis.yml +10 -13
- data/.yardopts +3 -1
- data/Gemfile +2 -0
- data/lib/opal/config.rb +113 -36
- data/lib/opal/sprockets.rb +13 -27
- data/lib/opal/sprockets/processor.rb +33 -8
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +1 -1
- data/opal/corelib/constants.rb +3 -3
- data/spec/lib/cli_runners/phantomjs_spec.rb +2 -2
- data/spec/lib/config_spec.rb +97 -0
- data/spec/lib/path_reader_spec.rb +3 -3
- data/spec/lib/spec_helper.rb +88 -4
- data/spec/lib/sprockets/erb_spec.rb +1 -1
- data/spec/lib/sprockets/processor_spec.rb +3 -3
- data/spec/lib/sprockets_spec.rb +12 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89554baf418fe68fca2684442d11d361b74c6771
|
4
|
+
data.tar.gz: 7e44601e429aae698df5656a952447be076fc90f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc37070ccc46ba143fdad2056837f5dea4fc1bc3f3afbbd2839e978e85e005653301bafbba303af5e7f56b26158a64b9903b3385f8fda872a62cc09ecde0f57
|
7
|
+
data.tar.gz: 816cc90b77dbaa07d4bac8bcc32a54e218d6b1b9411a6c864b8f3eb87474c57bff6d648b18a295978c28e6387eae68bb4440d4b2d24f18b8e53ea48c450130cc
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -11,31 +11,31 @@ matrix:
|
|
11
11
|
fast_finish: true
|
12
12
|
|
13
13
|
include:
|
14
|
-
- rvm: 2.3.
|
14
|
+
- rvm: 2.3.3
|
15
15
|
env: RUN=jshint SUITE=core
|
16
16
|
|
17
|
-
- rvm: 2.3.
|
17
|
+
- rvm: 2.3.3
|
18
18
|
env: RUN=jshint SUITE=stdlib
|
19
19
|
|
20
|
-
- rvm: 2.3.
|
20
|
+
- rvm: 2.3.3
|
21
21
|
env: RUN=mspec_opal_nodejs
|
22
22
|
|
23
|
-
- rvm: 2.3.
|
23
|
+
- rvm: 2.3.3
|
24
24
|
env: RUN=mspec_ruby_nodejs TZ="/usr/share/zoneinfo/Pacific/Fiji"
|
25
25
|
|
26
|
-
- rvm: 2.3.
|
26
|
+
- rvm: 2.3.3
|
27
27
|
env: RUN=mspec_ruby_sprockets_phantomjs
|
28
28
|
|
29
|
-
- rvm: 2.3.
|
29
|
+
- rvm: 2.3.3
|
30
30
|
env: RUN=minitest
|
31
31
|
|
32
|
-
- rvm: 2.3.
|
32
|
+
- rvm: 2.3.3
|
33
33
|
env: RUN=rspec RACK_VERSION='~> 2.0.0' CHECK_COVERAGE=true
|
34
34
|
|
35
35
|
- rvm: ruby-head
|
36
36
|
env: RUN=rspec
|
37
37
|
|
38
|
-
- rvm: 2.2.
|
38
|
+
- rvm: 2.2.6
|
39
39
|
env: RUN=rspec TILT_VERSION=2.0.1 SPROCKETS_VERSION='~> 3.7'
|
40
40
|
|
41
41
|
- rvm: 2.1.10
|
@@ -44,10 +44,7 @@ matrix:
|
|
44
44
|
- rvm: 2.0.0
|
45
45
|
env: RUN="rspec mspec_opal_nodejs" RACK_VERSION='< 2.0'
|
46
46
|
|
47
|
-
- rvm:
|
48
|
-
env: RUN=rspec
|
49
|
-
|
50
|
-
- rvm: jruby-9.0.5.0
|
47
|
+
- rvm: jruby-9.1.6.0
|
51
48
|
env: RUN=rspec
|
52
49
|
|
53
50
|
- rvm: jruby-head
|
@@ -55,7 +52,6 @@ matrix:
|
|
55
52
|
|
56
53
|
allow_failures:
|
57
54
|
- rvm: ruby-head
|
58
|
-
- rvm: rbx
|
59
55
|
- rvm: jruby-head
|
60
56
|
|
61
57
|
|
@@ -66,6 +62,7 @@ before_install:
|
|
66
62
|
- git submodule update --init
|
67
63
|
- npm install -g jshint
|
68
64
|
- npm install -g uglify-js
|
65
|
+
- bundle config without doc
|
69
66
|
|
70
67
|
script:
|
71
68
|
- "bundle exec rake $RUN"
|
data/.yardopts
CHANGED
data/Gemfile
CHANGED
data/lib/opal/config.rb
CHANGED
@@ -2,53 +2,130 @@ require 'set'
|
|
2
2
|
|
3
3
|
module Opal
|
4
4
|
module Config
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
const_missing_enabled: true,
|
12
|
-
dynamic_require_severity: :warning, # :error, :warning or :ignore
|
13
|
-
irb_enabled: false,
|
14
|
-
inline_operators_enabled: true,
|
15
|
-
source_map_enabled: true,
|
16
|
-
stubbed_files: Set.new,
|
17
|
-
}
|
5
|
+
extend self
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def config_options
|
10
|
+
@config_options ||= {}
|
18
11
|
end
|
19
12
|
|
20
|
-
|
21
|
-
|
13
|
+
# Defines a new configuration option
|
14
|
+
#
|
15
|
+
# @param [String] name the option name
|
16
|
+
# @param [Object] default_value the option's default value
|
17
|
+
# @!macro [attach] property
|
18
|
+
# @!attribute [rw] $1
|
19
|
+
def config_option(name, default_value, options = {})
|
20
|
+
compiler = options.fetch(:compiler_option, nil)
|
21
|
+
valid_values = options.fetch(:valid_values , [true, false])
|
22
|
+
|
23
|
+
config_options[name] = {
|
24
|
+
default: default_value,
|
25
|
+
compiler: compiler,
|
26
|
+
}
|
27
|
+
|
28
|
+
define_singleton_method(name) { config.fetch(name, default_value) }
|
29
|
+
define_singleton_method("#{name}=") do |value|
|
30
|
+
unless valid_values.any? { |valid_value| valid_value === value }
|
31
|
+
raise ArgumentError, "Not a valid value for option #{self}.#{name}, provided #{value.inspect}. "\
|
32
|
+
"Must be #{valid_values.inspect} === #{value.inspect}"
|
33
|
+
end
|
34
|
+
|
35
|
+
config[name] = value
|
36
|
+
end
|
22
37
|
end
|
23
38
|
|
24
|
-
|
25
|
-
|
39
|
+
public
|
40
|
+
|
41
|
+
# @return [Hash] the default configuration
|
42
|
+
def default_config
|
43
|
+
default_config = {}
|
44
|
+
config_options.each do |name, options|
|
45
|
+
default_value = options.fetch(:default)
|
46
|
+
default_value = Proc === default_value ? default_value.call : default_value
|
47
|
+
default_config[name] = default_value
|
48
|
+
end
|
49
|
+
default_config
|
26
50
|
end
|
27
51
|
|
28
|
-
|
29
|
-
|
30
|
-
method_missing: :method_missing_enabled,
|
31
|
-
arity_check: :arity_check_enabled,
|
32
|
-
freezing: :freezing_stubs_enabled,
|
33
|
-
tainting: :tainting_stubs_enabled,
|
34
|
-
const_missing: :const_missing_enabled,
|
35
|
-
dynamic_require_severity: :dynamic_require_severity,
|
36
|
-
irb: :irb_enabled,
|
37
|
-
inline_operators: :inline_operators_enabled,
|
38
|
-
}
|
39
|
-
|
40
|
-
def self.compiler_options
|
41
|
-
config = self.config
|
52
|
+
# @return [Hash] the configuration for Opal::Compiler
|
53
|
+
def compiler_options
|
42
54
|
compiler_options = {}
|
43
|
-
|
44
|
-
|
55
|
+
config_options.each do |name, options|
|
56
|
+
compiler_option_name = options.fetch(:compiler)
|
57
|
+
compiler_options[compiler_option_name] = config.fetch(name)
|
45
58
|
end
|
46
59
|
compiler_options
|
47
60
|
end
|
48
61
|
|
49
|
-
|
50
|
-
|
51
|
-
|
62
|
+
# @return [Hash] the current configuration, defaults to #default_config
|
63
|
+
def config
|
64
|
+
@config ||= default_config
|
52
65
|
end
|
66
|
+
|
67
|
+
# Resets the config to its default value
|
68
|
+
#
|
69
|
+
# @return [void]
|
70
|
+
def reset!
|
71
|
+
@config = nil
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
# Enable method_missing support.
|
76
|
+
#
|
77
|
+
# @return [true, false]
|
78
|
+
config_option :method_missing_enabled, true, compiler_option: :method_missing
|
79
|
+
|
80
|
+
# Enable const_missing support.
|
81
|
+
#
|
82
|
+
# @return [true, false]
|
83
|
+
config_option :const_missing_enabled, true, compiler_option: :const_missing
|
84
|
+
|
85
|
+
# Enable arity check on the arguments passed to methods, procs and lambdas.
|
86
|
+
#
|
87
|
+
# @return [true, false]
|
88
|
+
config_option :arity_check_enabled, false, compiler_option: :arity_check
|
89
|
+
|
90
|
+
# Add stubs for methods related to freezing objects (for compatibility).
|
91
|
+
#
|
92
|
+
# @return [true, false]
|
93
|
+
config_option :freezing_stubs_enabled, true, compiler_option: :freezing
|
94
|
+
|
95
|
+
# Add stubs for methods related to tainting objects (for compatibility).
|
96
|
+
#
|
97
|
+
# @return [true, false]
|
98
|
+
config_option :tainting_stubs_enabled, true, compiler_option: :tainting
|
99
|
+
|
100
|
+
# Set the error severity for when a require can't be solved at compile time.
|
101
|
+
#
|
102
|
+
# - `:error` will raise an error at compile time
|
103
|
+
# - `:warning` will print a warning on stderr at compile time
|
104
|
+
# - `:ignore` will skip the require silently at compile time
|
105
|
+
#
|
106
|
+
# @return [:error, :warning, :ignore]
|
107
|
+
config_option :dynamic_require_severity, :warning, compiler_option: :dynamic_require_severity, valid_values: [:error, :warning, :ignore]
|
108
|
+
|
109
|
+
# Enable IRB support for making local variables across multiple compilations.
|
110
|
+
#
|
111
|
+
# @return [true, false]
|
112
|
+
config_option :irb_enabled, false, compiler_option: :irb
|
113
|
+
|
114
|
+
# Enable for inline operators optimizations.
|
115
|
+
#
|
116
|
+
# @return [true, false]
|
117
|
+
config_option :inline_operators_enabled, true, compiler_option: :inline_operators
|
118
|
+
|
119
|
+
# Enable source maps support.
|
120
|
+
#
|
121
|
+
# @return [true, false]
|
122
|
+
config_option :source_map_enabled, true
|
123
|
+
|
124
|
+
# A set of stubbed files that will be marked as loaded and skipped during
|
125
|
+
# compilation. The value is expected to be mutated but it's ok to replace
|
126
|
+
# it.
|
127
|
+
#
|
128
|
+
# @return [Set]
|
129
|
+
config_option :stubbed_files, -> { Set.new }, valid_values: [Set]
|
53
130
|
end
|
54
131
|
end
|
data/lib/opal/sprockets.rb
CHANGED
@@ -9,7 +9,7 @@ module Opal
|
|
9
9
|
#
|
10
10
|
# @example
|
11
11
|
#
|
12
|
-
# Opal::Sprockets.load_asset(
|
12
|
+
# Opal::Sprockets.load_asset('application')
|
13
13
|
#
|
14
14
|
# @example Will output the following JavaScript:
|
15
15
|
#
|
@@ -19,38 +19,24 @@ module Opal
|
|
19
19
|
# Opal.load("application");
|
20
20
|
# }
|
21
21
|
#
|
22
|
-
# @param name
|
23
|
-
# @param sprockets [Sprockets::Environment]
|
22
|
+
# @param name [String] The logical name of the main asset to be loaded (without extension)
|
24
23
|
#
|
25
24
|
# @return [String] JavaScript code
|
26
|
-
def self.load_asset(name,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
ext if engine <= ::Opal::Processor
|
32
|
-
end.compact
|
25
|
+
def self.load_asset(name, _sprockets = :deprecated)
|
26
|
+
if _sprockets != :deprecated && !@load_asset_warning_displayed
|
27
|
+
@load_asset_warning_displayed = true
|
28
|
+
warn "Passing a sprockets environment to Opal::Sprockets.load_asset no more needed.\n #{caller(1, 3).join("\n ")}"
|
29
|
+
end
|
33
30
|
|
34
|
-
|
35
|
-
path_extnames = -> path { File.basename(path).scan(/\.[^.]+/) }
|
36
|
-
mark_loaded = -> paths { "Opal.loaded([#{paths.map(&:inspect).join(',')}]);" }
|
37
|
-
processed_by_opal = -> asset { (path_extnames[asset.pathname] & opal_extnames).any? }
|
31
|
+
name = name.sub(/(\.(js|rb|opal))*\z/, '')
|
38
32
|
stubbed_files = ::Opal::Config.stubbed_files
|
39
33
|
|
40
|
-
|
41
|
-
.select { |asset| not(processed_by_opal[asset]) }
|
42
|
-
.map { |asset| module_name[asset] }
|
43
|
-
|
44
|
-
loaded = ['opal'] + non_opal_assets + stubbed_files.to_a
|
45
|
-
|
46
|
-
if processed_by_opal[asset]
|
47
|
-
load_asset_code = "Opal.load(#{module_name[asset].inspect});"
|
48
|
-
end
|
49
|
-
|
34
|
+
loaded = ['opal', 'corelib/runtime'] + stubbed_files.to_a
|
50
35
|
|
51
36
|
"if (typeof(Opal) !== 'undefined') { "\
|
52
|
-
"#{
|
53
|
-
"
|
37
|
+
"Opal.loaded(#{loaded.to_json}); "\
|
38
|
+
"if (typeof(OpalLoaded) === 'undefined') Opal.loaded(OpalLoaded); "\
|
39
|
+
"if (Opal.modules[#{name.to_json}]) Opal.load(#{name.to_json}); "\
|
54
40
|
"}"
|
55
41
|
end
|
56
42
|
|
@@ -83,7 +69,7 @@ module Opal
|
|
83
69
|
scripts << %{<script src="#{prefix}/#{name}.js"></script>}
|
84
70
|
end
|
85
71
|
|
86
|
-
scripts << %{<script>#{::Opal::Sprockets.load_asset(name
|
72
|
+
scripts << %{<script>#{::Opal::Sprockets.load_asset(name)}</script>}
|
87
73
|
|
88
74
|
scripts.join "\n"
|
89
75
|
end
|
@@ -48,10 +48,8 @@ module Opal
|
|
48
48
|
process_requires(compiler.requires, context)
|
49
49
|
process_required_trees(compiler.required_trees, context)
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
::Opal::SourceMapServer.set_map_cache(sprockets, logical_path, map_contents)
|
54
|
-
end
|
51
|
+
map_contents = compiler.source_map.as_json.to_json
|
52
|
+
::Opal::SourceMapServer.set_map_cache(sprockets, logical_path, map_contents)
|
55
53
|
|
56
54
|
result.to_s
|
57
55
|
end
|
@@ -139,10 +137,37 @@ module Opal
|
|
139
137
|
end
|
140
138
|
end
|
141
139
|
|
140
|
+
module Opal::Sprockets::Processor
|
141
|
+
module PlainJavaScriptLoader
|
142
|
+
def self.call(input)
|
143
|
+
sprockets = input[:environment]
|
144
|
+
asset = OpenStruct.new(input)
|
145
|
+
|
146
|
+
opal_extnames = sprockets.engines.map do |ext, engine|
|
147
|
+
ext if engine <= ::Opal::Processor
|
148
|
+
end.compact
|
149
|
+
|
150
|
+
path_extnames = -> path { File.basename(path).scan(/\.[^.]+/) }
|
151
|
+
processed_by_opal = -> asset { (path_extnames[asset.filename] & opal_extnames).any? }
|
152
|
+
|
153
|
+
unless processed_by_opal[asset]
|
154
|
+
[
|
155
|
+
input[:data],
|
156
|
+
%{if (typeof(OpalLoaded) === 'undefined') OpalLoaded = []; OpalLoaded.push(#{input[:name].to_json});}
|
157
|
+
].join(";\n")
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
|
142
164
|
if Sprockets.respond_to? :register_transformer
|
143
|
-
|
144
|
-
Sprockets.register_engine '.opal', Opal::Processor, mime_type: 'application/javascript', silence_deprecation: true
|
165
|
+
extra_args = [{mime_type: 'application/javascript', silence_deprecation: true}]
|
145
166
|
else
|
146
|
-
|
147
|
-
Sprockets.register_engine '.opal', Opal::Processor
|
167
|
+
extra_args = []
|
148
168
|
end
|
169
|
+
|
170
|
+
Sprockets.register_engine '.rb', Opal::Processor, *extra_args
|
171
|
+
Sprockets.register_engine '.opal', Opal::Processor, *extra_args
|
172
|
+
Sprockets.register_postprocessor 'application/javascript', Opal::Sprockets::Processor::PlainJavaScriptLoader
|
173
|
+
|
data/lib/opal/version.rb
CHANGED
data/opal.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency 'mspec', '1.5.20'
|
29
29
|
s.add_development_dependency 'rake'
|
30
30
|
s.add_development_dependency 'racc'
|
31
|
-
s.add_development_dependency 'rspec', '~>
|
31
|
+
s.add_development_dependency 'rspec', '~> 3.5.0'
|
32
32
|
s.add_development_dependency 'octokit', '~> 2.4.0'
|
33
33
|
s.add_development_dependency 'bundler', '~> 1.5'
|
34
34
|
s.add_development_dependency 'yard', '~> 0.8.7'
|
data/opal/corelib/constants.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
RUBY_PLATFORM = 'opal'
|
2
2
|
RUBY_ENGINE = 'opal'
|
3
|
-
RUBY_VERSION = '2.2.
|
4
|
-
RUBY_ENGINE_VERSION = '0.10.
|
5
|
-
RUBY_RELEASE_DATE = '
|
3
|
+
RUBY_VERSION = '2.2.6'
|
4
|
+
RUBY_ENGINE_VERSION = '0.10.4'
|
5
|
+
RUBY_RELEASE_DATE = '2017-05-06'
|
6
6
|
RUBY_PATCHLEVEL = 0
|
7
7
|
RUBY_REVISION = 0
|
8
8
|
RUBY_COPYRIGHT = 'opal - Copyright (C) 2013-2015 Adam Beynon'
|
@@ -3,9 +3,9 @@ require 'opal/cli_runners/phantomjs'
|
|
3
3
|
require 'stringio'
|
4
4
|
|
5
5
|
describe Opal::CliRunners::Phantomjs do
|
6
|
-
# FIXME: Unfotunately there are some issues on
|
6
|
+
# FIXME: Unfotunately there are some issues on 1.9.3, probably
|
7
7
|
# related to IO.pipe and process spawning in general.
|
8
|
-
before { pending if
|
8
|
+
before { pending if RUBY_VERSION == '1.9.3' }
|
9
9
|
|
10
10
|
it 'accepts arguments' do
|
11
11
|
expect(output_of(%{
|
data/spec/lib/config_spec.rb
CHANGED
@@ -2,12 +2,109 @@ require 'lib/spec_helper'
|
|
2
2
|
require 'opal/config'
|
3
3
|
|
4
4
|
describe Opal::Config do
|
5
|
+
before { described_class.reset! }
|
6
|
+
after { described_class.reset! }
|
7
|
+
|
5
8
|
describe '.default_config' do
|
6
9
|
it 'is new each time' do
|
7
10
|
default_config1 = described_class.default_config
|
8
11
|
default_config2 = described_class.default_config
|
9
12
|
expect(default_config1).to eq(default_config2)
|
10
13
|
expect(default_config1).not_to equal(default_config2)
|
14
|
+
described_class.default_config[:stubbed_files] << :foo
|
15
|
+
expect(described_class.default_config[:stubbed_files]).to eq(Set.new)
|
11
16
|
end
|
12
17
|
end
|
18
|
+
|
19
|
+
it 'has expected default values' do
|
20
|
+
expect(described_class.method_missing_enabled).to eq(true)
|
21
|
+
expect(described_class.const_missing_enabled).to eq(true)
|
22
|
+
expect(described_class.arity_check_enabled).to eq(false)
|
23
|
+
expect(described_class.freezing_stubs_enabled).to eq(true)
|
24
|
+
expect(described_class.tainting_stubs_enabled).to eq(true)
|
25
|
+
expect(described_class.dynamic_require_severity).to eq(:warning)
|
26
|
+
expect(described_class.irb_enabled).to eq(false)
|
27
|
+
expect(described_class.inline_operators_enabled).to eq(true)
|
28
|
+
expect(described_class.source_map_enabled).to eq(true)
|
29
|
+
expect(described_class.stubbed_files).to eq(Set.new)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raises an ArgumentError if provided with an unexpected value' do
|
33
|
+
expect{ described_class.method_missing_enabled = :foobar }.to raise_error(ArgumentError)
|
34
|
+
expect{ described_class.const_missing_enabled = :foobar }.to raise_error(ArgumentError)
|
35
|
+
expect{ described_class.arity_check_enabled = :foobar }.to raise_error(ArgumentError)
|
36
|
+
expect{ described_class.freezing_stubs_enabled = :foobar }.to raise_error(ArgumentError)
|
37
|
+
expect{ described_class.tainting_stubs_enabled = :foobar }.to raise_error(ArgumentError)
|
38
|
+
expect{ described_class.dynamic_require_severity = :foobar }.to raise_error(ArgumentError)
|
39
|
+
expect{ described_class.irb_enabled = :foobar }.to raise_error(ArgumentError)
|
40
|
+
expect{ described_class.inline_operators_enabled = :foobar }.to raise_error(ArgumentError)
|
41
|
+
expect{ described_class.source_map_enabled = :foobar }.to raise_error(ArgumentError)
|
42
|
+
expect{ described_class.stubbed_files = :foobar }.to raise_error(ArgumentError)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'does not raises errors if provided with an expected value' do
|
46
|
+
expect{ described_class.arity_check_enabled = false }.not_to raise_error
|
47
|
+
expect(described_class.arity_check_enabled).to eq(false)
|
48
|
+
|
49
|
+
expect{ described_class.arity_check_enabled = true }.not_to raise_error
|
50
|
+
expect(described_class.arity_check_enabled).to eq(true)
|
51
|
+
|
52
|
+
expect{ described_class.const_missing_enabled = false }.not_to raise_error
|
53
|
+
expect(described_class.const_missing_enabled).to eq(false)
|
54
|
+
|
55
|
+
expect{ described_class.const_missing_enabled = true }.not_to raise_error
|
56
|
+
expect(described_class.const_missing_enabled).to eq(true)
|
57
|
+
|
58
|
+
expect{ described_class.dynamic_require_severity = :error }.not_to raise_error
|
59
|
+
expect(described_class.dynamic_require_severity).to eq(:error)
|
60
|
+
|
61
|
+
expect{ described_class.dynamic_require_severity = :ignore }.not_to raise_error
|
62
|
+
expect(described_class.dynamic_require_severity).to eq(:ignore)
|
63
|
+
|
64
|
+
expect{ described_class.dynamic_require_severity = :warning }.not_to raise_error
|
65
|
+
expect(described_class.dynamic_require_severity).to eq(:warning)
|
66
|
+
|
67
|
+
expect{ described_class.freezing_stubs_enabled = false }.not_to raise_error
|
68
|
+
expect(described_class.freezing_stubs_enabled).to eq(false)
|
69
|
+
|
70
|
+
expect{ described_class.freezing_stubs_enabled = true }.not_to raise_error
|
71
|
+
expect(described_class.freezing_stubs_enabled).to eq(true)
|
72
|
+
|
73
|
+
expect{ described_class.inline_operators_enabled = false }.not_to raise_error
|
74
|
+
expect(described_class.inline_operators_enabled).to eq(false)
|
75
|
+
|
76
|
+
expect{ described_class.inline_operators_enabled = true }.not_to raise_error
|
77
|
+
expect(described_class.inline_operators_enabled).to eq(true)
|
78
|
+
|
79
|
+
expect{ described_class.irb_enabled = false }.not_to raise_error
|
80
|
+
expect(described_class.irb_enabled).to eq(false)
|
81
|
+
|
82
|
+
expect{ described_class.irb_enabled = true }.not_to raise_error
|
83
|
+
expect(described_class.irb_enabled).to eq(true)
|
84
|
+
|
85
|
+
expect{ described_class.method_missing_enabled = false }.not_to raise_error
|
86
|
+
expect(described_class.method_missing_enabled).to eq(false)
|
87
|
+
|
88
|
+
expect{ described_class.method_missing_enabled = true }.not_to raise_error
|
89
|
+
expect(described_class.method_missing_enabled).to eq(true)
|
90
|
+
|
91
|
+
expect{ described_class.source_map_enabled = false }.not_to raise_error
|
92
|
+
expect(described_class.source_map_enabled).to eq(false)
|
93
|
+
|
94
|
+
expect{ described_class.source_map_enabled = true }.not_to raise_error
|
95
|
+
expect(described_class.source_map_enabled).to eq(true)
|
96
|
+
|
97
|
+
expect{ described_class.stubbed_files << 'foo' }.not_to raise_error
|
98
|
+
expect(described_class.stubbed_files).to eq(['foo'].to_set)
|
99
|
+
|
100
|
+
expect{ described_class.stubbed_files = %w[foo bar].to_set }.not_to raise_error
|
101
|
+
expect(described_class.stubbed_files).to eq(%w[foo bar].to_set)
|
102
|
+
|
103
|
+
expect{ described_class.tainting_stubs_enabled = false }.not_to raise_error
|
104
|
+
expect(described_class.tainting_stubs_enabled).to eq(false)
|
105
|
+
|
106
|
+
expect{ described_class.tainting_stubs_enabled = true }.not_to raise_error
|
107
|
+
expect(described_class.tainting_stubs_enabled).to eq(true)
|
108
|
+
|
109
|
+
end
|
13
110
|
end
|
@@ -12,9 +12,9 @@ describe Opal::PathReader do
|
|
12
12
|
let(:contents) { File.read(full_path) }
|
13
13
|
|
14
14
|
before do
|
15
|
-
path_finder.
|
16
|
-
path_finder.
|
17
|
-
path_finder.
|
15
|
+
allow(path_finder).to receive(:find) {|path| nil}
|
16
|
+
allow(path_finder).to receive(:find).with(path).and_return(full_path)
|
17
|
+
allow(path_finder).to receive(:paths).and_return(Opal.paths)
|
18
18
|
end
|
19
19
|
|
20
20
|
include_examples :path_finder
|
data/spec/lib/spec_helper.rb
CHANGED
@@ -5,12 +5,96 @@ end
|
|
5
5
|
|
6
6
|
require 'opal'
|
7
7
|
|
8
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
9
|
RSpec.configure do |config|
|
9
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
|
-
config.run_all_when_everything_filtered = true
|
11
|
-
config.filter_run :focus
|
12
|
-
config.order = 'random'
|
13
10
|
config.before { Opal.reset_paths! }
|
14
11
|
config.before { Opal::Config.reset! if defined? Opal::Config }
|
15
12
|
config.before { Opal::Processor.reset_cache_key! if defined? Opal::Processor }
|
13
|
+
|
14
|
+
# rspec-expectations config goes here. You can use an alternate
|
15
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
16
|
+
# assertions if you prefer.
|
17
|
+
config.expect_with :rspec do |expectations|
|
18
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
19
|
+
# and `failure_message` of custom matchers include text for helper methods
|
20
|
+
# defined using `chain`, e.g.:
|
21
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
22
|
+
# # => "be bigger than 2 and smaller than 4"
|
23
|
+
# ...rather than:
|
24
|
+
# # => "be bigger than 2"
|
25
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
26
|
+
|
27
|
+
expectations.syntax = [:expect, :should]
|
28
|
+
end
|
29
|
+
|
30
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
31
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
32
|
+
config.mock_with :rspec do |mocks|
|
33
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
34
|
+
# a real object. This is generally recommended, and will default to
|
35
|
+
# `true` in RSpec 4.
|
36
|
+
mocks.verify_partial_doubles = true
|
37
|
+
|
38
|
+
mocks.syntax = [:expect, :should]
|
39
|
+
end
|
40
|
+
|
41
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
42
|
+
# have no way to turn it off -- the option exists only for backwards
|
43
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
44
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
45
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
46
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
47
|
+
|
48
|
+
# This allows you to limit a spec run to individual examples or groups
|
49
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
50
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
51
|
+
# aliases for `it`, `||\describe`, and `context` that include `:focus`
|
52
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
53
|
+
config.filter_run_when_matching :focus
|
54
|
+
|
55
|
+
# Allows RSpec to persist some state between runs in order to support
|
56
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
57
|
+
# you configure your source control system to ignore this file.
|
58
|
+
config.example_status_persistence_file_path = "tmp/examples.txt"
|
59
|
+
|
60
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
61
|
+
# recommended. For more details, see:
|
62
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
63
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
64
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
65
|
+
# config.disable_monkey_patching!
|
66
|
+
|
67
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
68
|
+
# be too noisy due to issues in dependencies.
|
69
|
+
# config.warnings = true
|
70
|
+
|
71
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
72
|
+
# file, and it's useful to allow more verbose output when running an
|
73
|
+
# individual spec file.
|
74
|
+
if config.files_to_run.one?
|
75
|
+
# Use the documentation formatter for detailed output,
|
76
|
+
# unless a formatter has already been configured
|
77
|
+
# (e.g. via a command-line flag).
|
78
|
+
config.default_formatter = 'doc'
|
79
|
+
else
|
80
|
+
# The RSpec specs are stored in spec/lib.
|
81
|
+
config.pattern = 'spec/lib/**/*_spec.rb'
|
82
|
+
end
|
83
|
+
|
84
|
+
# Print the 10 slowest examples and example groups at the
|
85
|
+
# end of the spec run, to help surface which specs are running
|
86
|
+
# particularly slow.
|
87
|
+
config.profile_examples = 10
|
88
|
+
|
89
|
+
# Run specs in random order to surface order dependencies. If you find an
|
90
|
+
# order dependency and want to debug it, you can fix the order by providing
|
91
|
+
# the seed, which is printed after each run.
|
92
|
+
# --seed 1234
|
93
|
+
config.order = :random
|
94
|
+
|
95
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
96
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
97
|
+
# test failures related to randomization by passing the same `--seed` value
|
98
|
+
# as the one that triggered the failure.
|
99
|
+
Kernel.srand config.seed
|
16
100
|
end
|
@@ -19,7 +19,7 @@ describe Opal::ERB::Processor do
|
|
19
19
|
) }
|
20
20
|
let(:required_assets) { [] }
|
21
21
|
let(:template) { described_class.new { |t| %Q{<% print("") %><a href="<%= url %>"><%= name %></a>} } }
|
22
|
-
before { sprockets_context.
|
22
|
+
before { allow(sprockets_context).to receive(:require_asset) {|asset| required_assets << asset } }
|
23
23
|
|
24
24
|
let(:ext) { 'opalerb' }
|
25
25
|
|
@@ -45,13 +45,13 @@ describe Opal::Processor do
|
|
45
45
|
let(:config) { Opal::Config }
|
46
46
|
|
47
47
|
it 'usually require files' do
|
48
|
-
sprockets_context.
|
48
|
+
expect(sprockets_context).to receive(:require_asset).with(stubbed_file)
|
49
49
|
template.render(sprockets_context)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'skips require of stubbed file' do
|
53
53
|
config.stubbed_files << stubbed_file.to_s
|
54
|
-
sprockets_context.
|
54
|
+
expect(sprockets_context).not_to receive(:require_asset).with(stubbed_file)
|
55
55
|
template.render(sprockets_context)
|
56
56
|
end
|
57
57
|
|
@@ -61,7 +61,7 @@ describe Opal::Processor do
|
|
61
61
|
environment.stub(:[]).with('bar.js') { asset }
|
62
62
|
environment.stub(:engines) { {'.rb' => described_class, '.opal' => described_class} }
|
63
63
|
|
64
|
-
code = ::Opal::Sprockets.load_asset('bar'
|
64
|
+
code = ::Opal::Sprockets.load_asset('bar')
|
65
65
|
code.should match stubbed_file
|
66
66
|
end
|
67
67
|
end
|
data/spec/lib/sprockets_spec.rb
CHANGED
@@ -7,21 +7,28 @@ describe Opal::Sprockets do
|
|
7
7
|
|
8
8
|
describe '.load_asset' do
|
9
9
|
it 'loads the main asset' do
|
10
|
-
code = described_class.load_asset('console'
|
10
|
+
code = described_class.load_asset('console')
|
11
11
|
expect(code).to include('Opal.load("console");')
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'marks as loaded "opal" plus all non opal assets' do
|
15
|
-
code = described_class.load_asset('corelib/runtime'
|
15
|
+
code = described_class.load_asset('corelib/runtime')
|
16
16
|
expect(code).to include('Opal.loaded(["opal","corelib/runtime"]);')
|
17
17
|
end
|
18
18
|
|
19
|
-
it '
|
20
|
-
code = described_class.load_asset('foo'
|
21
|
-
expect(code).to
|
19
|
+
it 'tries to load an asset if it is registered as opal module' do
|
20
|
+
code = described_class.load_asset('foo')
|
21
|
+
expect(code).to include('if (Opal.modules["foo"]) Opal.load("foo");')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'warns the user that passing an env is not needed, only once' do
|
26
|
+
expect(described_class).to receive(:warn).once
|
27
|
+
described_class.load_asset('foo', env)
|
28
|
+
described_class.load_asset('foo', env)
|
29
|
+
described_class.load_asset('foo', env)
|
30
|
+
end
|
31
|
+
|
25
32
|
describe '.javascript_include_tag' do
|
26
33
|
it 'works with trailing / in the prefix' do
|
27
34
|
code = described_class.javascript_include_tag('corelib/runtime', prefix: '/', sprockets: env, debug: false)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sourcemap
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 3.5.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 3.5.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: octokit
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1156,7 +1156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1156
1156
|
version: '0'
|
1157
1157
|
requirements: []
|
1158
1158
|
rubyforge_project:
|
1159
|
-
rubygems_version: 2.6.
|
1159
|
+
rubygems_version: 2.6.8
|
1160
1160
|
signing_key:
|
1161
1161
|
specification_version: 4
|
1162
1162
|
summary: Ruby runtime and core library for JavaScript
|