1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Description: Fix Library Path
Fix the path for secure_headers in spec_helper.rb
Author: Abhijith PA <abhijith@openmailbox.org>
Forwarded: not-needed
Last-Update: 2026-02-23
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -6,7 +6,7 @@ require "coveralls"
Coveralls.wear!
require 'securerandom'
-require File.join(File.dirname(__FILE__), "..", "lib", "secure_headers")
+require 'secure_headers'
--- a/spec/lib/secure_headers/railtie_spec.rb
+++ b/spec/lib/secure_headers/railtie_spec.rb
@@ -51,7 +51,17 @@ describe "SecureHeaders::Railtie" do
def load_railtie
# Load the railtie file fresh
- load File.expand_path("../../../../lib/secure_headers/railtie.rb", __FILE__)
+ begin
+ load File.expand_path("../../../../lib/secure_headers/railtie.rb", __FILE__)
+ rescue LoadError
+ spec = Gem::Specification.find_by_name("secure_headers")
+ railtie_path = File.join(spec.gem_dir, "lib", "secure_headers", "railtie.rb")
+ if File.exist?(railtie_path)
+ load railtie_path
+ else
+ raise LoadError, "secure_headers railtie not found at #{railtie_path}"
+ end
+ end
end
def run_action_controller_initializer
|