rspec-puppet not working

892 views
Skip to first unread message

Guy Knights

unread,
Aug 30, 2013, 6:58:43 PM8/30/13
to puppet...@googlegroups.com
I'm trying to get rspec-puppet working and have run into a problem. I have a VM running ubuntu lucid, have installed rubygems 1.3.5 from the apt package and have install rspec-puppet (and other required gems), and rake, using gem install.

I've run rspec-puppet-init in the module I want to test, and have created a very basic spec file for one of the classes in my module. However, when I run 'rake spec' from the top level of the module directory, I get the following error:

(in /modules/couchbase)
/usr/bin/ruby1.8 -S rspec spec/classes/init_spec.rb
/usr/bin/ruby1.8: No such file or directory -- rspec (LoadError)
/usr/bin/ruby1.8 -S rspec spec/classes/init_spec.rb failed

It seems like it can't load rspec, but if I do 'gem list --local' it shows in the list of locally installed gems:

vagrant@ubuntu-server-10044-x64-vbox4210-nocm:/modules/couchbase$ gem list --local

*** LOCAL GEMS ***

diff-lcs (1.2.4)
metaclass (0.0.1)
mocha (0.14.0)
puppet-lint (0.3.2)
puppetlabs_spec_helper (0.4.1)
rake (10.1.0)
rspec (2.14.1)
rspec-core (2.14.5)
rspec-expectations (2.14.2)
rspec-mocks (2.14.3)
rspec-puppet (0.1.6)

Does anyone know why it's not working? I've searched for an answer online, but I'm not overly familiar with ruby, gems, rake, etc and I'm at a bit of a loss.

Thanks,
Guy

Ashley Penney

unread,
Aug 30, 2013, 7:20:30 PM8/30/13
to puppet...@googlegroups.com
As an alternative to the rspec-puppet-init stuff try installing the 'puppetlabs_spec_helper' gem and then update spec_helper.rb to be:

require 'puppetlabs_spec_helper/module_spec_helper'

Then you can just 'rake spec' and see if that works out better for you.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Ashley Penney
Module Engineer

Join us at PuppetConf 2014September 23-24 in San Francisco

Guy Knights

unread,
Aug 30, 2013, 7:23:29 PM8/30/13
to puppet...@googlegroups.com
Do I need to replace the entire contents of spec_helper.rb with that file? Also, do I need to change my rake file from the following content?

require 'rake'

require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec) do |t|
  t.pattern = 'spec/*/*_spec.rb'
end



--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/l2YHBCvdKF0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.

To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Guy Knights
Lead Systems Administrator

www.eastsidegamestudio.com
g...@eastsidegamestudio.com

Guy Knights

unread,
Aug 30, 2013, 8:03:23 PM8/30/13
to puppet...@googlegroups.com
Ok, I found the solution - it was a simple case of adding the path to the rspec bin directory to my PATH. Rake is using the -S switch, which uses PATH to find the rspec binary.

Thanks,
Guy
Reply all
Reply to author
Forward
0 new messages