Skip to content

Commit 5151ca4

Browse files
committed
fix running jasmine when the asset_host is set in test environment
The generated spec/tmp/runner.html file uses the ActionController::Base.asset_host which needs to be nil in order for the generated HTML file to have the proper relative paths to spec/tmp/assets/*.js files.
1 parent 72b47e0 commit 5151ca4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/jasmine_rails/runner.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ def include_offline_asset_paths_helper
2626
end
2727
end
2828

29+
# temporarily override internal rails settings for the given block
30+
# and reset the settings after work is complete.
31+
#
32+
# * disable Rails assets debug setting to ensure generated application
33+
# is built into one JS file
34+
# * disable asset host so that generated runner.html file uses
35+
# relative paths to included javascript files
2936
def override_rails_config
3037
config = Rails.application.config
3138

32-
original_asssets_debug = config.assets.debug
39+
original_assets_debug = config.assets.debug
40+
original_assets_host = ActionController::Base.asset_host
3341
config.assets.debug = false
42+
ActionController::Base.asset_host = nil
3443
yield
35-
config.assets.debug = original_asssets_debug
44+
ensure
45+
config.assets.debug = original_assets_debug
46+
ActionController::Base.asset_host = original_assets_host
3647
end
3748

3849
def get_spec_runner(spec_filter)

0 commit comments

Comments
 (0)