This repository was archived by the owner on Oct 19, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
lib/generators/reactive_ruby/test_app/templates/assets/javascripts Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1
1
require 'opal'
2
- require 'react-server.js'
3
2
require 'hyper-react'
4
3
require_tree './components'
Original file line number Diff line number Diff line change 3
3
if ruby?
4
4
RSpec . describe ReactiveRuby ::ComponentLoader do
5
5
GLOBAL_WRAPPER = <<-JS
6
- var global = global || this;
7
- var self = self || this;
6
+ #{ React ::ServerRendering ::ExecJSRenderer ::GLOBAL_WRAPPER }
8
7
var console = {
9
8
warn: function(s) { }
10
9
};
11
10
JS
12
11
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
14
21
let ( :context ) { ExecJS . compile ( GLOBAL_WRAPPER + js ) }
15
22
let ( :v8_context ) { ReactiveRuby ::ServerRendering . context_instance_for ( context ) }
16
23
Original file line number Diff line number Diff line change @@ -77,7 +77,12 @@ def test_context(files = nil)
77
77
end
78
78
79
79
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
81
86
end
82
87
83
88
let ( :v8_context ) { TestV8Context . new }
You can’t perform that action at this time.
0 commit comments