spec/sprinkle/installers/source_spec.rb in sprinkle-0.3.3 vs spec/sprinkle/installers/source_spec.rb in sprinkle-0.3.4

- old
+ new

@@ -1,12 +1,14 @@ -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path("../../spec_helper", File.dirname(__FILE__)) describe Sprinkle::Installers::Source do include Sprinkle::Deployment before do - @source = 'ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz' + @filename = "ruby-1.8.6-p111" + @tarball = "#{@filename}.tar.gz" + @source = "ftp://ftp.ruby-lang.org/pub/ruby/1.8/#{@tarball}" @deployment = deployment do delivery :capistrano source do prefix '/usr' @@ -22,20 +24,21 @@ enable %w( headers ssl deflate so ) disable %w( cache proxy rewrite ) with %w( debug extras ) - without %w( fancyisms ) + without %w( fancyisms pandas ) option %w( foo bar baz ) end @installer.defaults(@deployment) end def create_source(source, version = nil, &block) @package = mock(Sprinkle::Package, :name => 'package', :version => version) + Sprinkle::Installers::Source.new(@package, source, &block) end describe 'when created' do @@ -68,105 +71,128 @@ lambda { @installer.install_sequence }.should raise_error end end - describe 'customized configuration' do + describe 'customized configuration' do it 'should support specification of "enable" options' do - @installer.enable.should == %w( headers ssl deflate so ) + @installer.enable.first.should == %w( headers ssl deflate so ) end it 'should support specification of "disable" options' do - @installer.disable.should == %w( cache proxy rewrite ) + @installer.disable.first.should == %w( cache proxy rewrite ) end it 'should support specification of "with" options' do - @installer.with.should == %w( debug extras ) + @installer.with.first.should == %w( debug extras ) end it 'should support specification of "without" options' do - @installer.without.should == %w( fancyisms ) + @installer.without.first.should == %w( fancyisms pandas ) end it 'should support specification of "option" options' do - @installer.option.should == %w( foo bar baz ) + @installer.option.first.should == %w( foo bar baz ) end it 'should support customized build area' do - @installer.prefix.should == '/usr/local' + @installer.prefix.first.should == '/usr/local' end it 'should support customized source area' do - @installer.archives.should == '/usr/local/archives' + @installer.archives.first.should == '/usr/local/archives' end it 'should support customized install area' do - @installer.builds.should == '/usr/local/builds' + @installer.builds.first.should == '/usr/local/builds' end - end describe 'during gnu source archive style installation' do it 'should prepare the build, installation and source archives area' do - @installer.should_receive(:prepare).and_return( - [ + @installer.should_receive(:prepare).and_return [] + end + + it "should prepare the build, installation and source archives area with correct paths" do + @installer.send(:prepare).should == + [ 'mkdir -p /usr/local', 'mkdir -p /usr/local/builds', - 'mkdir -p /usr/local/archives' - ] - ) - + 'mkdir -p /usr/local/archives' + ] end - + it 'should download the source archive' do - @installer.should_receive(:download).and_return( + @installer.should_receive(:download).and_return [] + end + + it 'should download the source archive to the correct path' do + @installer.send(:download).should == [ "wget -cq --directory-prefix='/usr/local/archives' #{@source}" ] - ) end - + it 'should extract the source archive' do - @installer.should_receive(:extract).and_return( + @installer.should_receive(:extract).and_return [] + end + + it 'should extract the source to the correct path' do + @installer.send(:extract).should == [ - "bash -c 'cd /usr/local/builds && tar xzf /usr/local/archives/ruby-1.8.6-p111.tar.gz" + "bash -c 'cd /usr/local/builds && tar xzf /usr/local/archives/ruby-1.8.6-p111.tar.gz'" ] - ) end it 'should configure the source' do + @installer.should_receive(:configure).and_return [] + end + + it 'should configure the source in the correct path and with the correct prefix and options' do enable = %w( headers ssl deflate so ).inject([]) { |m, value| m << "--enable-#{value}"; m } disable = %w( cache proxy rewrite ).inject([]) { |m, value| m << "--disable-#{value}"; m } with = %w( debug extras ).inject([]) { |m, value| m << "--with-#{value}"; m } - without = %w( fancyisms ).inject([]) { |m, value| m << "--without-#{value}"; m } + without = %w( fancyisms pandas ).inject([]) { |m, value| m << "--without-#{value}"; m } - options = "#{enable.join(' ')} #{disable.join(' ')} #{with.join(' ')} #{without.join(' ')}" + option = %w( foo bar baz ).inject([]) { |m, value| m << "--#{value}"; m } - @installer.should_receive(:build).and_return( - [ - "bash -c 'cd /usr/local/builds && ./configure --prefix=/usr/local #{options} > #{@package.name}-configure.log 2>&1'" - ] - ) + configure_command = @installer.send(:configure).first + + configure_command.should =~ %r{^bash -c 'cd /usr/local/builds/#{@filename} && ./configure --prefix=/usr/local} + configure_command.should =~ %r{ > #{@package.name}-configure.log 2>&1'$} + + # order of options is arbitrary in ruby 1.8 ! + configure_command.should =~ /#{enable.join(' ')}/ + configure_command.should =~ /#{disable.join(' ')}/ + configure_command.should =~ /#{with.join(' ')}/ + configure_command.should =~ /#{without.join(' ')}/ + configure_command.should =~ /#{option.join(' ')}/ end - + it 'should build the source' do - @installer.should_receive(:build).and_return( + @installer.should_receive(:build).and_return [] + end + + it 'should build the source in the correct build path' do + @installer.send(:build).should == [ - "bash -c 'cd /usr/local/builds && make > #{@package.name}-build.log 2>&1'" + "bash -c 'cd /usr/local/builds/#{@filename} && make > #{@package.name}-build.log 2>&1'" ] - ) end it 'should install the source' do - @installer.should_receive(:install).and_return( + @installer.should_receive(:install).and_return [] + end + + it 'should install the source from the correct build path' do + @installer.send(:install).should == [ - "bash -c 'cd /usr/local/builds && make install > #{@package.name}-install.log 2>&1'" + "bash -c 'cd /usr/local/builds/#{@filename} && make install > #{@package.name}-install.log 2>&1'" ] - ) end describe 'with a custom archive definition' do before do @installer.options[:custom_archive] = 'super-foo.tar' @@ -190,10 +216,10 @@ @installer.defaults(@deployment) end it 'should store the custom install commands' do - @installer.options[:custom_install].should == 'ruby setup.rb' + @installer.options[:custom_install].first.should == 'ruby setup.rb' end it 'should identify as having a custom install command' do @installer.should be_custom_install end