diff --git a/Appraisals b/Appraisals index 3002ea39..5086c4d4 100644 --- a/Appraisals +++ b/Appraisals @@ -9,3 +9,8 @@ end appraise "rails-4.0" do gem 'rails', '~> 4.0' end + +appraise "rails-4.0-with-therubyracer" do + gem 'rails', '~> 4.0' + gem 'therubyracer', '0.12.0', :platform => :mri +end diff --git a/lib/react/jsx.rb b/lib/react/jsx.rb index 767fc419..c9cfa24c 100644 --- a/lib/react/jsx.rb +++ b/lib/react/jsx.rb @@ -6,7 +6,11 @@ module React module JSX def self.context # TODO: create React::Source::contents_for - contents = File.read(React::Source.bundled_path_for('JSXTransformer.js')) + contents = + # If execjs uses therubyracer, there is no 'global'. Make sure + # we have it so JSX script can work properly. + 'var global = global || this;' + + File.read(React::Source.bundled_path_for('JSXTransformer.js')) @context ||= ExecJS.compile(contents) end diff --git a/test/test_helper.rb b/test/test_helper.rb index 1e26a313..c900e969 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -6,6 +6,12 @@ Rails.backtrace_cleaner.remove_silencers! +# Remove cached files +Rails.root.join('tmp').tap do |tmp| + tmp.rmtree + tmp.mkpath +end + # Load support files Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }