# How to test a bash code snippet

**URL:** <https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252>\
**Category:** Chef Infra (archive)\
**Created:** [July 8, 2013, 2:56pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252 "2013-07-08T14:56:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rudi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/rudi/32/149_2.png) [@Rudi](https://discourse.chef.io/u/Rudi)\
**Post date:** [July 8, 2013, 2:56pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/1 "2013-07-08T14:56:11Z")

</div>

Hi,

I’m using chefspec with chef 11 and have this working piece of code but  
don’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” do  
user "vagrant"  
cwd "/vagrant"  
flags "–login"  
code \<\<-EOH  
rvm use ruby-1.9.2-p290  
bundle --verbose  
EOH

# 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’) }  
end

Prior to this code I was testing the execute command with this:

describe ‘main::install\_bundle’ do  
let (:chef\_run) { ChefSpec::ChefRunner.new.converge ‘main::install\_bundle’  
}

it “installs with bundler” do  
expect(chef\_run).to execute\_command(“cd /vagrant && rvm use  
ruby-1.9.2-p290 && bundle --verbose”)  
end  
end

But 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!

---

<div class="post-metadata">

**Author:** ![dcondomitti](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dcondomitti/32/104_2.png) [@dcondomitti](https://discourse.chef.io/u/dcondomitti)\
**Post date:** [July 8, 2013, 3:56pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/2 "2013-07-08T15:56:21Z")

</div>

This isn't directly related to your testing but you can just run `bundle check` and it will tell you if any gems need to be installed or upgraded. If you're only testing for xpath 0.1.4's existence then if another gem gets upgraded you won't be able to boot your application.

On Monday, July 8, 2013 at 10:56 AM, Rudi wrote:

> Hi,
> 
> I'm using chefspec with chef 11 and have this working piece of code but  
> don'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" do  
> user "vagrant"  
> cwd "/vagrant"  
> flags "--login"  
> code \<\<-EOH  
> rvm use ruby-1.9.2-p290  
> bundle --verbose  
> EOH
> 
> # 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') }  
> end
> 
> Prior to this code I was testing the execute command with this:
> 
> describe 'main::install\_bundle' do  
> let (:chef\_run) { ChefSpec::ChefRunner.new.converge 'main::install\_bundle' }
> 
> it "installs with bundler" do  
> expect(chef\_run).to execute\_command("cd /vagrant && rvm use ruby-1.9.2-p290 && bundle --verbose")  
> end  
> end
> 
> But 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!

---

<div class="post-metadata">

**Author:** ![Rudi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/rudi/32/149_2.png) [@Rudi](https://discourse.chef.io/u/Rudi)\
**Post date:** [July 8, 2013, 9:44pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/3 "2013-07-08T21:44:46Z")

</div>

Thanks Daniel - that's makes good sense and I"ll update code for that.

I'm still not sure the best way to test the actual bash code being run by  
chef\_run though?

On Mon, Jul 8, 2013 at 11:56 PM, Daniel Condomitti [daniel@condomitti.com](mailto:daniel@condomitti.com)wrote:

> This isn't directly related to your testing but you can just run `bundle check` and it will tell you if any gems need to be installed or upgraded.  
> If you're only testing for xpath 0.1.4's existence then if another gem gets  
> upgraded you won't be able to boot your application.
> 
> On Monday, July 8, 2013 at 10:56 AM, Rudi wrote:
> 
> Hi,
> 
> I'm using chefspec with chef 11 and have this working piece of code but  
> don'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" do  
> user "vagrant"  
> cwd "/vagrant"  
> flags "--login"  
> code \<\<-EOH  
> rvm use ruby-1.9.2-p290  
> bundle --verbose  
> EOH
> 
> # 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') }  
> end
> 
> Prior to this code I was testing the execute command with this:
> 
> describe 'main::install\_bundle' do  
> let (:chef\_run) { ChefSpec::ChefRunner.new.converge 'main::install\_bundle'  
> }
> 
> it "installs with bundler" do  
> expect(chef\_run).to execute\_command("cd /vagrant && rvm use  
> ruby-1.9.2-p290 && bundle --verbose")  
> end  
> end
> 
> But 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!

---

<div class="post-metadata">

**Author:** ![John\_Dewey](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/john_dewey/32/457_2.png) [@John\_Dewey](https://discourse.chef.io/u/John_Dewey)\
**Post date:** [July 8, 2013, 10:21pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/4 "2013-07-08T22:21:20Z")

</div>

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.

> **[GitHub - chefspec/chefspec: Write RSpec examples and generate coverage...](https://github.com/chefspec/chefspec#evaluating-guards)**
>
> Write RSpec examples and generate coverage reports for Chef recipes! - GitHub - chefspec/chefspec: Write RSpec examples and generate coverage reports for Chef recipes!

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 but  
> don'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" do  
> user "vagrant"  
> cwd "/vagrant"  
> flags "--login"  
> code \<\<-EOH  
> rvm use ruby-1.9.2-p290  
> bundle --verbose  
> EOH
> 
> # 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') }  
> end
> 
> Prior to this code I was testing the execute command with this:
> 
> describe 'main::install\_bundle' do  
> let (:chef\_run) { ChefSpec::ChefRunner.new.converge 'main::install\_bundle' }
> 
> it "installs with bundler" do  
> expect(chef\_run).to execute\_command("cd /vagrant && rvm use ruby-1.9.2-p290 && bundle --verbose")  
> end  
> end
> 
> But 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!

---

<div class="post-metadata">

**Author:** ![Rudi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/rudi/32/149_2.png) [@Rudi](https://discourse.chef.io/u/Rudi)\
**Post date:** [July 8, 2013, 10:39pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/5 "2013-07-08T22:39:03Z")

</div>

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

On Tue, Jul 9, 2013 at 6:21 AM, John Dewey [john@dewey.ws](mailto:john@dewey.ws) 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.  
> [GitHub - chefspec/chefspec: Write RSpec examples and generate coverage reports for Chef recipes!](https://github.com/acrmp/chefspec#evaluating-guards)
> 
> 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 but  
> don'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" do  
> user "vagrant"  
> cwd "/vagrant"  
> flags "--login"  
> code \<\<-EOH  
> rvm use ruby-1.9.2-p290  
> bundle --verbose  
> EOH
> 
> # 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') }  
> end
> 
> Prior to this code I was testing the execute command with this:
> 
> describe 'main::install\_bundle' do  
> let (:chef\_run) { ChefSpec::ChefRunner.new.converge 'main::install\_bundle'  
> }
> 
> it "installs with bundler" do  
> expect(chef\_run).to execute\_command("cd /vagrant && rvm use  
> ruby-1.9.2-p290 && bundle --verbose")  
> end  
> end
> 
> But 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!

---

<div class="post-metadata">

**Author:** ![John\_Dewey](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/john_dewey/32/457_2.png) [@John\_Dewey](https://discourse.chef.io/u/John_Dewey)\
**Post date:** [July 8, 2013, 10:46pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/6 "2013-07-08T22:46:05Z")

</div>

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).
> 
> On Tue, Jul 9, 2013 at 6:21 AM, John Dewey \<john@dewey.ws ([mailto:john@dewey.ws](mailto:john@dewey.ws))\> 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.  
> > [GitHub - chefspec/chefspec: Write RSpec examples and generate coverage reports for Chef recipes!](https://github.com/acrmp/chefspec#evaluating-guards)
> > 
> > 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 but  
> > > don'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" do  
> > > user "vagrant"  
> > > cwd "/vagrant"  
> > > flags "--login"  
> > > code \<\<-EOH  
> > > rvm use ruby-1.9.2-p290  
> > > bundle --verbose  
> > > EOH
> > > 
> > > # 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') }  
> > > end
> > > 
> > > Prior to this code I was testing the execute command with this:
> > > 
> > > describe 'main::install\_bundle' do  
> > > let (:chef\_run) { ChefSpec::ChefRunner.new.converge 'main::install\_bundle' }
> > > 
> > > it "installs with bundler" do  
> > > expect(chef\_run).to execute\_command("cd /vagrant && rvm use ruby-1.9.2-p290 && bundle --verbose")  
> > > end  
> > > end
> > > 
> > > But 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!

---

<div class="post-metadata">

**Author:** ![Rudi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/rudi/32/149_2.png) [@Rudi](https://discourse.chef.io/u/Rudi)\
**Post date:** [July 8, 2013, 10:47pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/7 "2013-07-08T22:47:55Z")

</div>

Very nice! Thanks man.

On Tue, Jul 9, 2013 at 6:46 AM, John Dewey [john@dewey.ws](mailto:john@dewey.ws) 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).
> 
> On Tue, Jul 9, 2013 at 6:21 AM, John Dewey [john@dewey.ws](mailto:john@dewey.ws) 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.  
> [GitHub - chefspec/chefspec: Write RSpec examples and generate coverage reports for Chef recipes!](https://github.com/acrmp/chefspec#evaluating-guards)
> 
> 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 but  
> don'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" do  
> user "vagrant"  
> cwd "/vagrant"  
> flags "--login"  
> code \<\<-EOH  
> rvm use ruby-1.9.2-p290  
> bundle --verbose  
> EOH
> 
> # 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') }  
> end
> 
> Prior to this code I was testing the execute command with this:
> 
> describe 'main::install\_bundle' do  
> let (:chef\_run) { ChefSpec::ChefRunner.new.converge 'main::install\_bundle'  
> }
> 
> it "installs with bundler" do  
> expect(chef\_run).to execute\_command("cd /vagrant && rvm use  
> ruby-1.9.2-p290 && bundle --verbose")  
> end  
> end
> 
> But 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!

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [July 8, 2013, 11:51pm UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/8 "2013-07-08T23:51:05Z")

</div>

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 \<john@dewey.ws ([mailto:john@dewey.ws](mailto:john@dewey.ws))\> 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

---

<div class="post-metadata">

**Author:** ![Rudi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/rudi/32/149_2.png) [@Rudi](https://discourse.chef.io/u/Rudi)\
**Post date:** [July 9, 2013, 12:58am UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/9 "2013-07-09T00:58:11Z")

</div>

> 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 [dan@kallistec.com](mailto:dan@kallistec.com) 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 [john@dewey.ws](mailto:john@dewey.ws) 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

---

<div class="post-metadata">

**Author:** ![Mike](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mike/32/18_2.png) [@Mike](https://discourse.chef.io/u/Mike)\
**Post date:** [July 9, 2013, 11:20am UTC](https://discourse.chef.io/t/how-to-test-a-bash-code-snippet/4252/10 "2013-07-09T11:20:28Z")

</div>

You might be looking for:

expct(chef\_run).to execute\_bash\_script(command)

Ref  
[https://github.com/acrmp/chefspec/blob/master/lib/chefspec/matchers/script.rb#L5](https://github.com/acrmp/chefspec/blob/master/lib/chefspec/matchers/script.rb#L5)

-M

On Monday, July 8, 2013, Rudi wrote:

> > 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 \<[dan@kallistec.com](mailto:dan@kallistec.com)\<javascript:\_e({}, 'cvml', 'dan@kallistec.com');\>
> 
> > 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 \<john@dewey.ws\<javascript:\_e({}, 'cvml', 'john@dewey.ws');\>
> > 
> > > 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
