Right, thats why you want to source the rvm script, before calling rvm.code <<-EOH.gsub(/^\s+/, '')source ~/.rvm/scripts/rvmrvm use ruby-1.9.2-p290bundle --verboseEOHcommand = <<-EOH.gsub(/^\s+/, '')source ~/.rvm/scripts/rvmrvm use ruby-1.9.2-p290bundle --verboseEOHexpect(chef_run).to execute_command(command)On Monday, July 8, 2013 at 3:39 PM, Rudi wrote:
Hey John,> can probably switch back to executeThe reason I left was I needed to pass in the "--login" flag. Without this it erred not being able to see rvm (non apt package).On Tue, Jul 9, 2013 at 6:21 AM, John Dewey < " target="_blank"> > wrote:To test if it executes, you will need to use the execute resource, not the bash resource. You can probably switch back to execute, and add `source ~/.rvm/scripts/rvm` before calling `rvm use …`To properly test the guard, you will want to have a look at the recent guard evaluation work that was added.On Monday, July 8, 2013 at 7:56 AM, Rudi wrote:
Hi,I'm using chefspec with chef 11 and have this working piece of code butdon't know how to test it.I hope this is the correct place to ask for any suggestions on this?I also have a crude file exists check so that bundle doesn't run every chef_run.bash "install with bundler" douser "vagrant"cwd "/vagrant"flags "--login"code <<-EOHrvm use ruby-1.9.2-p290bundle --verboseEOH# xpath is the last in the list of 125 required gems for this application (gem list --local)# If this gem is here we assume bundle has already run successfully.not_if { ::File.exists?('/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/xpath-0.1.4') }endPrior to this code I was testing the execute command with this:describe 'main::install_bundle' dolet (:chef_run) { ChefSpec::ChefRunner.new.converge 'main::install_bundle' }it "installs with bundler" doexpect(chef_run).to execute_command("cd /vagrant && rvm use ruby-1.9.2-p290 && bundle --verbose")endendBut I need the "--login" flag so that rvm can select ruby 1.9.2 so I changed to the bash resource.FYI ..chef is running with ruby 1.9.3 but the Rails app uses 1.9.2 on the /vagrant box (it's some old coder I need to maintain).Thanks!
Archive powered by MHonArc 2.6.16.