Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VERSION 9.0: Fixing rails 3.2 test run #926

Merged
merged 9 commits into from
Sep 10, 2017
2 changes: 1 addition & 1 deletion lib/react_on_rails/server_rendering_pool/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.reset_pool_if_server_bundle_was_modified

server_bundle_js_file_path = ReactOnRails::Utils.server_bundle_js_file_path

if Webpacker.dev_server.running?
if Utils.using_webpacker? && Webpacker.dev_server.running?
return if @last_loaded_server_bundle == server_bundle_js_file_path
@last_loaded_server_bundle = server_bundle_js_file_path
else
Expand Down
15 changes: 10 additions & 5 deletions lib/react_on_rails/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ def self.server_bundle_js_file_path
return @server_bundle_path if @server_bundle_path && !Rails.env.development?

bundle_name = ReactOnRails.configuration.server_bundle_js_file
@server_bundle_path = begin
bundle_js_file_path(bundle_name)
rescue Webpacker::Manifest::MissingEntryError
Rails.root.join(File.join(Webpacker.config.public_output_path, bundle_name)).to_s
end
@server_bundle_path = if using_webpacker?
begin
bundle_js_file_path(bundle_name)
rescue Webpacker::Manifest::MissingEntryError
Rails.root.join(File.join(Webpacker.config.public_output_path,
bundle_name)).to_s
end
else
bundle_js_file_path(bundle_name)
end
end

def self.bundle_js_file_path(bundle_name)
Expand Down
6 changes: 3 additions & 3 deletions rakelib/run_rspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ namespace :run_rspec do

desc "Run RSpec with rails32 gemfile"
task :gem_rails32 do
rspec_args = "spec/react_on_rails --exclude-pattern "\
"\"**/generators/*_spec.rb,**/utils_spec.rb,"\
"**/webpack_assets_status_checker_spec.rb,**/test_helper/*_spec.rb\""
rspec_args = "spec/react_on_rails --tag ~webpacker --exclude-pattern "\
"\"**/generators/*_spec.rb,"\
"**/test_helper/webpack_*_spec.rb\""
run_tests_in("",
rspec_args: rspec_args,
env_vars: "BUNDLE_GEMFILE=spec/dummy_no_webpacker/Gemfile.rails32")
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy_no_webpacker/Gemfile.rails32
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ group :test do
gem "rspec-retry"
gem "selenium-webdriver"
gem "rails3-before_action"
gem 'test-unit', '~> 3.0'
gem 'test-unit', '~> 3.0', :require => false
gem "equivalent-xml", github: "mbklein/equivalent-xml"
end
6 changes: 6 additions & 0 deletions spec/react_on_rails/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
Rails.backtrace_cleaner.remove_silencers!

require_relative "./simplecov_helper"
# prevent Test::Unit's AutoRunner from executing during RSpec's rake task
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)

unless File.basename(ENV["BUNDLE_GEMFILE"] || "") == "Gemfile.rails32"
require "webpacker"
end

# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
Expand Down
5 changes: 2 additions & 3 deletions spec/react_on_rails/utils_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require_relative "spec_helper"
require "webpacker"

module ReactOnRails
RSpec.describe Utils do
Expand All @@ -15,7 +14,7 @@ module ReactOnRails
Utils.bundle_js_file_path("webpack-bundle.js")
end

context "With Webpacker enabled and file in manifest" do
context "With Webpacker enabled and file in manifest", :webpacker do
before do
allow(Rails).to receive(:root).and_return(Pathname.new("."))
allow(Webpacker).to receive_message_chain("dev_server.running?")
Expand Down Expand Up @@ -43,7 +42,7 @@ module ReactOnRails
Utils.server_bundle_js_file_path
end

context "With Webpacker enabled and server file not in manifest" do
context "With Webpacker enabled and server file not in manifest", :webpacker do
before do
allow(Rails).to receive(:root).and_return(Pathname.new("."))
allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file")
Expand Down