@@ -51,51 +51,46 @@ module JavaBuildpack::Repository
5151 end
5252 end
5353
54- it 'should handle Mac OS X 10.9 correctly' do
55- with_host ( 'darwin12.4.0' , 'x86_64' ) do
56- JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
57- RepositoryIndex . any_instance . stub ( :` ) . with ( 'sw_vers -productVersion' ) . and_return ( '10.9' )
58- application_cache . stub ( :get ) . with ( 'mountainlion/x86_64/test-uri/index.yml' ) . and_yield ( File . open ( 'spec/fixtures/test-index.yml' ) )
59- RepositoryIndex . new ( '{platform}/{architecture}/test-uri' )
60- expect ( application_cache ) . to have_received ( :get ) . with ( %r(mountainlion/x86_64/test-uri/index\. yml) )
61- end
54+ it 'should handle Centos correctly' do
55+ JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
56+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -s' ) . and_return ( 'Linux' )
57+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -m' ) . and_return ( 'x86_64' )
58+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'which lsb_release 2> /dev/null' ) . and_return ( '' )
59+ File . stub ( :exists? ) . with ( '/etc/redhat-release' ) . and_return ( true )
60+ File . stub ( :open ) . and_call_original
61+ File . stub ( :open ) . with ( '/etc/redhat-release' , 'r' ) . and_yield ( File . new ( 'spec/fixtures/redhat-release' ) )
62+ application_cache . stub ( :get ) . with ( 'centos6/x86_64/test-uri/index.yml' ) . and_yield ( File . open ( 'spec/fixtures/test-index.yml' ) )
63+ RepositoryIndex . new ( '{platform}/{architecture}/test-uri' )
64+ expect ( application_cache ) . to have_received ( :get ) . with ( %r(centos6/x86_64/test-uri/index\. yml) )
6265 end
6366
64- it 'should handle Mac OS X 10.8 correctly' do
65- with_host ( 'darwin12.3.0' , 'x86_64' ) do
66- JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
67- RepositoryIndex . any_instance . stub ( :` ) . with ( 'sw_vers -productVersion' ) . and_return ( '10.8.4' )
68- application_cache . stub ( :get ) . with ( 'mountainlion/x86_64/test-uri/index.yml' ) . and_yield ( File . open ( 'spec/fixtures/test-index.yml' ) )
69- RepositoryIndex . new ( '{platform}/{architecture}/test-uri' )
70- expect ( application_cache ) . to have_received ( :get ) . with ( %r(mountainlion/x86_64/test-uri/index\. yml) )
71- end
67+ it 'should handle Mac OS X correctly' do
68+ JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
69+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -s' ) . and_return ( 'Darwin' )
70+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -m' ) . and_return ( 'x86_64' )
71+ application_cache . stub ( :get ) . with ( 'mountainlion/x86_64/test-uri/index.yml' ) . and_yield ( File . open ( 'spec/fixtures/test-index.yml' ) )
72+ RepositoryIndex . new ( '{platform}/{architecture}/test-uri' )
73+ expect ( application_cache ) . to have_received ( :get ) . with ( %r(mountainlion/x86_64/test-uri/index\. yml) )
7274 end
7375
74- it 'should handle incorrect Mac OS X version correctly' do
75- with_host ( 'darwin12.3.0' , 'x86_64' ) do
76- JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
77- RepositoryIndex . any_instance . stub ( :` ) . with ( 'sw_vers -productVersion' ) . and_return ( '10.7.1' )
78- expect { RepositoryIndex . new ( '{platform}/{architecture}/test-uri' ) } . to raise_error ( /Unsupported OS X version/ )
79- end
76+ it 'should handle Ubuntu correctly' do
77+ JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
78+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -s' ) . and_return ( 'Linux' )
79+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -m' ) . and_return ( 'x86_64' )
80+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'which lsb_release 2> /dev/null' ) . and_return ( '/usr/bin/lsb_release' )
81+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'lsb_release -cs' ) . and_return ( 'precise' )
82+ application_cache . stub ( :get ) . with ( 'precise/x86_64/test-uri/index.yml' ) . and_yield ( File . open ( 'spec/fixtures/test-index.yml' ) )
83+ RepositoryIndex . new ( '{platform}/{architecture}/test-uri' )
84+ expect ( application_cache ) . to have_received ( :get ) . with ( %r(precise/x86_64/test-uri/index\. yml) )
8085 end
8186
82- it 'should handle Linux correctly' do
83- with_host ( 'linux-gnu' , 'x86_64' ) do
84- JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
85- RepositoryIndex . any_instance . stub ( :` ) . with ( 'lsb_release -cs' ) . and_return ( 'precise' )
86- application_cache . stub ( :get ) . with ( 'precise/x86_64/test-uri/index.yml' ) . and_yield ( File . open ( 'spec/fixtures/test-index.yml' ) )
87- RepositoryIndex . new ( '{platform}/{architecture}/test-uri' )
88- expect ( application_cache ) . to have_received ( :get ) . with ( %r(precise/x86_64/test-uri/index\. yml) )
89- end
90- end
87+ it 'should handle unknown OS correctly' do
88+ JavaBuildpack ::Util ::DownloadCache . stub ( :new ) . and_return ( application_cache )
89+ File . stub ( :exists? ) . with ( '/etc/redhat-release' ) . and_return ( false )
90+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'uname -s' ) . and_return ( 'Linux' )
91+ RepositoryIndex . any_instance . stub ( :` ) . with ( 'which lsb_release 2> /dev/null' ) . and_return ( '' )
9192
92- def with_host ( host_os , host_cpu )
93- previous_host_os , RbConfig ::CONFIG [ 'host_os' ] = RbConfig ::CONFIG [ 'host_os' ] , host_os
94- previous_host_cpu , RbConfig ::CONFIG [ 'host_cpu' ] = RbConfig ::CONFIG [ 'host_cpu' ] , host_cpu
95- yield
96- ensure
97- RbConfig ::CONFIG [ 'host_os' ] = previous_host_os
98- RbConfig ::CONFIG [ 'host_cpu' ] = previous_host_cpu
93+ expect { RepositoryIndex . new ( '{platform}/{architecture}/test-uri' ) } . to raise_error ( 'Unable to determine platform' )
9994 end
10095
10196 def with_buildpack_cache ( directory )
0 commit comments