spec/configurators/ruby_configurator_spec.rb in rconf-0.7.8 vs spec/configurators/ruby_configurator_spec.rb in rconf-0.7.9

- old
+ new

@@ -18,16 +18,12 @@ def success_result(output=nil) flexmock('res', :success? => true, :output => output) end before(:each) do - lang = RightConf::Language.parse('ruby { version "0"; rubygems "1" }') - @configurator = lang.configurators.first - [:report_check, :report_result, :report_success, :report].each do |meth| - flexmock(@configurator).should_receive(meth) - end - flexmock(@configurator).should_receive(:report_fatal).and_return { |*args| raise args.join(' ') } + @configurator = create_configurator('ruby { version "0"; rubygems "1" }') + flexmock(File).should_receive(:exist?).with('.rvmrc').and_return(true) end it 'should succeed on linux when rvm succeeds' do should_execute('rvm', '--version').once.and_return(success_result("rvm #{RVM_VERSION}")) should_execute('rvm', 'list').once.and_return(success_result("=> rvm #{RVM_VERSION}")) @@ -59,55 +55,56 @@ should_execute('rvm', '0@', 'gem', '--version').once.and_return(success_result('0')) should_execute('rvm', '0@', 'rubygems', '1', {:abort_on_failure=>'Failed to install rubygems'}).once.and_return(success_result) @configurator.run_linux end +end - describe 'bashrc update' do +describe 'bashrc update' do - before(:each) do - flexmock(File).should_receive(:exist?).once.with(File.join(ENV['HOME'], '.bashrc')).once.and_return(true) - flexmock(FileUtils).should_receive(:mv).and_return(true) - f = flexmock('f') - f.should_receive(:puts).and_return { |c| @bashrc_content = c } - flexmock(File).should_receive(:open).and_yield(f) - @rvm_bash_activation = @configurator.__send__(:rvm_bash_activation) - end + before(:each) do + flexmock(File).should_receive(:exist?).with(File.join(ENV['HOME'], '.bashrc')).once.and_return(true) + flexmock(File).should_receive(:exist?).with('.rvmrc').and_return(true) + flexmock(FileUtils).should_receive(:mv).and_return(true) + f = flexmock('f') + f.should_receive(:puts).and_return { |c| @bashrc_content = c } + flexmock(File).should_receive(:open).and_yield(f) + @configurator = create_configurator('ruby { version "0"; rubygems "1" }', :enable_updater => true) + @rvm_bash_activation = @configurator.__send__(:rvm_bash_activation) + end - it 'should install rvm hook in bashrc when not present' do - flexmock(IO).should_receive(:read).and_return('test') - @configurator.__send__(:setup_bashrc) - @bashrc_content.should == "#{@rvm_bash_activation}\ntest" - end + it 'should install rvm hook in bashrc when not present' do + flexmock(IO).should_receive(:read).and_return('test') + @configurator.__send__(:setup_bashrc) + @bashrc_content.should == "#{@rvm_bash_activation}\ntest" + end - it 'should not install rvm hook in bashrc when present' do - flexmock(IO).should_receive(:read).and_return('test' + @rvm_bash_activation) - @configurator.__send__(:setup_bashrc) - @bashrc_content.should be_nil - end + it 'should not install rvm hook in bashrc when present' do + flexmock(IO).should_receive(:read).and_return('test' + @rvm_bash_activation) + @configurator.__send__(:setup_bashrc) + @bashrc_content.should be_nil + end - it 'should install rvm hook after path is set' do - flexmock(IO).should_receive(:read).and_return(<<-EOS + it 'should install rvm hook after path is set' do + flexmock(IO).should_receive(:read).and_return(<<-EOS echo 'zobi la mouche' radio killed the radio star #PATH=something:should be fine this should not: PATH=something AFTER EOS - ) - @configurator.__send__(:setup_bashrc) - @bashrc_content.should == <<-EOS + ) + @configurator.__send__(:setup_bashrc) + @bashrc_content.should == <<-EOS echo 'zobi la mouche' radio killed the radio star #PATH=something:should be fine this should not: PATH=something #{@rvm_bash_activation} AFTER - EOS - end - + EOS end end