Skip to content

Commit cfb5905

Browse files
fkchangajjahn
authored andcommitted
make specs run under jruby
1 parent 82f8ce3 commit cfb5905

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

lib/reactive-ruby/server_rendering/contextual_renderer.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
module ReactiveRuby
22
module ServerRendering
3+
def self.context_instance_var_name
4+
if RUBY_PLATFORM == 'java'
5+
'@rhino_context'
6+
else
7+
'@v8_context'
8+
end
9+
end
10+
311
class ContextualRenderer < React::ServerRendering::SprocketsRenderer
412
def initialize(options = {})
513
super(options)
@@ -24,10 +32,8 @@ def render(component_name, props, prerender_options)
2432
def v8_runtime?
2533
ExecJS.runtime.name == "(V8)" || ExecJS.runtime.name == "therubyrhino (Rhino)"
2634
end
27-
2835
def v8_context
29-
@v8_context ||= @context.instance_variable_get("@v8_context")
30-
@v8_context ||= @context.instance_variable_get("@rhino_context")
36+
@v8_context ||= @context.instance_variable_get(ReactiveRuby::ServerRendering.context_instance_var_name)
3137
end
3238
end
3339
end

reactive-ruby.gemspec

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,12 @@ Gem::Specification.new do |s|
2828
s.add_development_dependency 'timecop'
2929
s.add_development_dependency 'opal-rspec'
3030
s.add_development_dependency 'sinatra'
31-
s.add_development_dependency 'sqlite3' # For Test Rails App
31+
32+
if RUBY_PLATFORM == 'java'
33+
s.add_development_dependency 'jdbc-sqlite3' # For Test Rails App
34+
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter' if RUBY_PLATFORM == 'java' # For Test Rails App
35+
s.add_development_dependency 'therubyrhino'
36+
else
37+
s.add_development_dependency 'sqlite3' # For Test Rails App
38+
end
3239
end

spec/reactive-ruby/component_loader_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
let(:js) { ::Rails.application.assets['components'].to_s }
1212
let(:context) { ExecJS.compile(GLOBAL_WRAPPER + js) }
13-
let(:v8_context) { context.instance_variable_get(:@v8_context) }
13+
let(:v8_context) { context.instance_variable_get(ReactiveRuby::ServerRendering.context_instance_var_name) }
1414

1515
describe '.new' do
1616
it 'raises a meaningful exception when initialized without a context' do

spec/reactive-ruby/isomorphic_helpers_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_context(files = nil)
7373
end
7474
js = "#{React::ServerRendering::ExecJSRenderer::GLOBAL_WRAPPER}#{js}"
7575
ctx = ExecJS.compile(js)
76-
ctx = ctx.instance_variable_get("@v8_context")
76+
ctx = ctx.instance_variable_get(ReactiveRuby::ServerRendering.context_instance_var_name)
7777
end
7878

7979
def react_context

0 commit comments

Comments
 (0)