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

Commit 66bb929

Browse files
committed
Fix test when react-server might not exist
1 parent bf6fa88 commit 66bb929

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
require 'opal'
2-
require 'react-server.js'
32
require 'hyper-react'
43
require_tree './components'

spec/reactive-ruby/component_loader_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
if ruby?
44
RSpec.describe ReactiveRuby::ComponentLoader do
55
GLOBAL_WRAPPER = <<-JS
6-
var global = global || this;
7-
var self = self || this;
6+
#{React::ServerRendering::ExecJSRenderer::GLOBAL_WRAPPER}
87
var console = {
98
warn: function(s) { }
109
};
1110
JS
1211

13-
let(:js) { ::Rails.application.assets['components'].to_s }
12+
let(:js) do
13+
if ::Rails.application.assets['react-server.js'] &&
14+
!::Rails.application.assets['react-server.js'].to_s.start_with?("// A placeholder file")
15+
react_source = ::Rails.application.assets['react-server.js']
16+
else
17+
react_source = ::Rails.application.assets['react.js']
18+
end
19+
::Rails.application.assets['components'].to_s + react_source.to_s
20+
end
1421
let(:context) { ExecJS.compile(GLOBAL_WRAPPER + js) }
1522
let(:v8_context) { ReactiveRuby::ServerRendering.context_instance_for(context) }
1623

spec/reactive-ruby/isomorphic_helpers_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ def test_context(files = nil)
7777
end
7878

7979
def react_context
80-
test_context('components')
80+
if ::Rails.application.assets['react-server.js'] &&
81+
!::Rails.application.assets['react-server.js'].to_s.start_with?("// A placeholder file")
82+
test_context(['components', 'react-server.js'])
83+
else
84+
test_context(['components', 'react.js'])
85+
end
8186
end
8287

8388
let(:v8_context) { TestV8Context.new }

0 commit comments

Comments
 (0)