File tree Expand file tree Collapse file tree 2 files changed +27
-11
lines changed Expand file tree Collapse file tree 2 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -85,17 +85,17 @@ def initialize(package_json)
8585      end 
8686
8787      def  raw 
88-         return  nil  unless  File . exist? ( package_json ) 
89- 
90-         parsed_package_contents  =  JSON . parse ( package_json_contents ) 
91-         if  parsed_package_contents . key? ( "dependencies" )  &&
92-            parsed_package_contents [ "dependencies" ] . key? ( "react-on-rails" ) 
93-           parsed_package_contents [ "dependencies" ] [ "react-on-rails" ] 
94-         else 
95-           msg  =  "No 'react-on-rails' entry in the dependencies of #{ NodePackageVersion . package_json_path }   \
96-                 "which is the expected location according to ReactOnRails.configuration.node_modules_location" 
97-           Rails . logger . warn ( msg ) 
88+         if  File . exist? ( package_json ) 
89+           parsed_package_contents  =  JSON . parse ( package_json_contents ) 
90+           if  parsed_package_contents . key? ( "dependencies" )  &&
91+              parsed_package_contents [ "dependencies" ] . key? ( "react-on-rails" ) 
92+             return  parsed_package_contents [ "dependencies" ] [ "react-on-rails" ] 
93+           end 
9894        end 
95+         msg  =  "No 'react-on-rails' entry in the dependencies of #{ NodePackageVersion . package_json_path }   \
96+               "which is the expected location according to ReactOnRails.configuration.node_modules_location" 
97+         Rails . logger . warn ( msg ) 
98+         nil 
9999      end 
100100
101101      def  semver_wildcard? 
Original file line number Diff line number Diff line change @@ -250,11 +250,27 @@ def check_version_and_log(node_package_version)
250250        end 
251251      end 
252252
253+       context  "with package.json without react-on-rails dependency"  do 
254+         let ( :package_json )  {  File . expand_path ( "../../package.json" ,  __dir__ )  } 
255+ 
256+         describe  "#raw"  do 
257+           it  "returns nil"  do 
258+             root_package_json_path  =  File . expand_path ( "fixtures/nonexistent_package.json" ,  __dir__ ) 
259+             allow ( Rails ) . to  receive_message_chain ( :root ,  :join ) . and_return ( root_package_json_path ) 
260+             expect ( node_package_version . raw ) . to  be_nil 
261+           end 
262+         end 
263+       end 
264+ 
253265      context  "with non-existing package.json"  do 
254266        let ( :package_json )  {  File . expand_path ( "fixtures/nonexistent_package.json" ,  __dir__ )  } 
255267
256268        describe  "#raw"  do 
257-           specify  {  expect ( node_package_version . raw ) . to  be_nil  } 
269+           it  "returns nil"  do 
270+             root_package_json_path  =  File . expand_path ( "fixtures/nonexistent_package.json" ,  __dir__ ) 
271+             allow ( Rails ) . to  receive_message_chain ( :root ,  :join ) . and_return ( root_package_json_path ) 
272+             expect ( node_package_version . raw ) . to  be_nil 
273+           end 
258274        end 
259275      end 
260276    end 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments