File tree Expand file tree Collapse file tree
lib/java_buildpack/repository
spec/java_buildpack/repository Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ def platform
8585 redhat_release = Pathname . new ( '/etc/redhat-release' )
8686
8787 if redhat_release . exist?
88- "centos#{ redhat_release . read . match ( /CentOS release (\d )/ ) [ 1 ] } "
88+ tokens = redhat_release . read . match ( /(\w +) (?:Linux )?release (\d +)/ )
89+ "#{ tokens [ 1 ] . downcase } #{ tokens [ 2 ] } "
8990 elsif `uname -s` =~ /Darwin/
9091 'mountainlion'
9192 elsif !`which lsb_release 2> /dev/null` . empty?
Original file line number Diff line number Diff line change 8484 end
8585
8686 it 'handles Mac OS X' do
87+ allow ( Pathname ) . to receive ( :new ) . and_call_original
88+ non_redhat = double ( 'non-redhat' , exist? : false )
89+ allow ( Pathname ) . to receive ( :new ) . with ( '/etc/redhat-release' ) . and_return ( non_redhat )
90+
8791 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'uname -s' ) . and_return ( 'Darwin' )
8892 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'uname -m' ) . and_return ( 'x86_64' )
8993 allow ( application_cache ) . to receive ( :get ) . with ( 'mountainlion/x86_64/test-uri/index.yml' )
9599 end
96100
97101 it 'handles Ubuntu' do
102+ allow ( Pathname ) . to receive ( :new ) . and_call_original
103+ non_redhat = double ( 'non-redhat' , exist? : false )
104+ allow ( Pathname ) . to receive ( :new ) . with ( '/etc/redhat-release' ) . and_return ( non_redhat )
105+
98106 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'uname -s' ) . and_return ( 'Linux' )
99107 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'uname -m' ) . and_return ( 'x86_64' )
100108 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'which lsb_release 2> /dev/null' )
109117 end
110118
111119 it 'handles unknown OS' do
120+ allow ( Pathname ) . to receive ( :new ) . and_call_original
121+ non_redhat = double ( 'non-redhat' , exist? : false )
122+ allow ( Pathname ) . to receive ( :new ) . with ( '/etc/redhat-release' ) . and_return ( non_redhat )
123+
112124 allow_any_instance_of ( File ) . to receive ( :exists? ) . with ( '/etc/redhat-release' ) . and_return ( false )
113125 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'uname -s' ) . and_return ( 'Linux' )
114126 allow_any_instance_of ( described_class ) . to receive ( :` ) . with ( 'which lsb_release 2> /dev/null' ) . and_return ( '' )
You can’t perform that action at this time.
0 commit comments