Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 87a07b6

Browse files
committed
component loader error message when context is nil
1 parent 55987cb commit 87a07b6

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

lib/reactive-ruby/component_loader.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ class ComponentLoader
44
private :v8_context
55

66
def initialize(v8_context)
7+
unless v8_context
8+
raise ArgumentError.new('Could not obtain ExecJS runtime context')
9+
end
710
@v8_context = v8_context
811
end
912

spec/reactive-ruby/component_loader_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
let(:context) { ExecJS.compile(GLOBAL_WRAPPER + js) }
1313
let(:v8_context) { context.instance_variable_get(:@v8_context) }
1414

15+
describe '.new' do
16+
it 'raises a meaningful exception when initialized without a context' do
17+
expect {
18+
described_class.new(nil)
19+
}.to raise_error(/Could not obtain ExecJS runtime context/)
20+
end
21+
end
22+
1523
describe '#load' do
1624
it 'loads given asset file into context' do
1725
loader = described_class.new(v8_context)

0 commit comments

Comments
 (0)