From c6d4334eac0ac94c48dc1931c002e0dbf954a12f Mon Sep 17 00:00:00 2001 From: WU Jun Date: Wed, 27 Nov 2013 23:06:56 +0800 Subject: [PATCH 1/2] Remove cached files before testing. --- test/test_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 1e26a313c..c900e9690 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 } From d42d295a2d6883958312a120c1b6183c327c32c6 Mon Sep 17 00:00:00 2001 From: WU Jun Date: Thu, 28 Nov 2013 13:41:51 +0800 Subject: [PATCH 2/2] Fix JSX when execjs uses therubyracer. --- Appraisals | 5 +++++ lib/react/jsx.rb | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Appraisals b/Appraisals index 3002ea395..5086c4d45 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 767fc419b..c9cfa24c1 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