[chef] Re: Re: Re: Re: Re: Re: How to test a bash code snippet


Chronological Thread 
  • From: Rudi < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: How to test a bash code snippet
  • Date: Tue, 9 Jul 2013 08:58:11 +0800

I'd encourage you to submit a patch to chefspec to support script/bash resources if you're able.

I like the idea too but I'm not really able to (just not smart enough to be honest)

What I was initially looking for was something like 

expect(chef_run).to execute_bash(command)

But I don't think that exists right?




On Tue, Jul 9, 2013 at 7:51 AM, Daniel DeLeo < " target="_blank"> > wrote:

On Monday, July 8, 2013 at 3:47 PM, Rudi wrote:

Very nice! Thanks man.


On Tue, Jul 9, 2013 at 6:46 AM, John Dewey < " target="_blank"> > wrote:
Right, thats why you want to source the rvm script, before calling rvm.

code <<-EOH.gsub(/^\s+/, '')
  source ~/.rvm/scripts/rvm
  rvm use ruby-1.9.2-p290
  bundle --verbose
EOH

command = <<-EOH.gsub(/^\s+/, '')
  source ~/.rvm/scripts/rvm
  rvm use ruby-1.9.2-p290
  bundle --verbose
EOH

expect(chef_run).to execute_command(command)

On Monday, July 8, 2013 at 3:39 PM, Rudi wrote:

Hey John,

 can probably switch back to execute

The 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).

The fact that an execute resource runs bin/sh as an intermediate step is an implementation detail (admittedly, one we're unlikely to change), so adding the `--login` flag to the bash resource is better chef code, in my opinion.

I'd encourage you to submit a patch to chefspec to support script/bash resources if you're able.


-- 
Daniel DeLeo





Archive powered by MHonArc 2.6.16.

§