Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Garrett Honeycutt
On 6/4/14, 2:30 PM, Brian Wilkins wrote:
> I am trying to write unit tests of my puppet modules. In my
> profiles::logstash::install, I disambiguate the call to
> /etc/puppet/modules/logstash by using ::logstash in my class definition
> like so:
> 
> class profiles::logstash::install() {
>   $ensure = $profiles::logstash::enable ? {true => present, default =>
> absent}
>   $status = $profiles::logstash::start ? {true => enabled, default =>
> disabled}
> 
>   class { '::logstash':
> ensure  => $ensure,
> status  => $status,
> version => $profiles::logstash::version
>   }
> }
> 
> However, when I run my spec file:
> 
> require 'spec_helper'
> 
> describe "profiles::logstash" do
>   it { should contain_class("::logstash") }
>   it { should contain_class("profiles::logstash::install") }
>   it { should contain_class("profiles::logstash::config") }
> end
> 
> I get the errors:
> 
> 1) profiles::logstash
>  Failure/Error: it { should contain_class("::logstash") }
>  Puppet::Error:
>Puppet::Parser::AST::Resource failed with error ArgumentError:
> Could not find declared class ::logstash at
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
> on node els4167.els.dev
>  # ./spec/classes/logstash_spec.rb:4
> 
>   2) profiles::logstash
>  Failure/Error: it { should
> contain_class("profiles::logstash::install") }
>  Puppet::Error:
>Puppet::Parser::AST::Resource failed with error ArgumentError:
> Could not find declared class ::logstash at
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
> on node els4167.els.dev
>  # ./spec/classes/logstash_spec.rb:5
> 
>   3) profiles::logstash
>  Failure/Error: it { should
> contain_class("profiles::logstash::config") }
>  Puppet::Error:
>Puppet::Parser::AST::Resource failed with error ArgumentError:
> Could not find declared class ::logstash at
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
> on node els4167.els.dev
>  # ./spec/classes/logstash_spec.rb:6
> 
> How do I get rspec to find my class /etc/puppet/modules/logstash and get
> it to reference ::logstash as a disambiguation?

Hi Brian,

Using ::class is not needed and should not be done. If you still want to
do that in your class, try changing the spec by dropping the preceding
double colons.

Best regards,
-g

-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/538F6F49.6080508%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Brian Wilkins
I think you missed the part where it is complaining about line 10 in my 
profiles::logstash::install module

class { '::logstash': 

Removing ::logstash from the spec file has the same complaint.

Brian

On Wednesday, June 4, 2014 3:11:14 PM UTC-4, Garrett Honeycutt wrote:
>
> On 6/4/14, 2:30 PM, Brian Wilkins wrote: 
> > I am trying to write unit tests of my puppet modules. In my 
> > profiles::logstash::install, I disambiguate the call to 
> > /etc/puppet/modules/logstash by using ::logstash in my class definition 
> > like so: 
> > 
> > class profiles::logstash::install() { 
> >   $ensure = $profiles::logstash::enable ? {true => present, default => 
> > absent} 
> >   $status = $profiles::logstash::start ? {true => enabled, default => 
> > disabled} 
> > 
> >   class { '::logstash': 
> > ensure  => $ensure, 
> > status  => $status, 
> > version => $profiles::logstash::version 
> >   } 
> > } 
> > 
> > However, when I run my spec file: 
> > 
> > require 'spec_helper' 
> > 
> > describe "profiles::logstash" do 
> >   it { should contain_class("::logstash") } 
> >   it { should contain_class("profiles::logstash::install") } 
> >   it { should contain_class("profiles::logstash::config") } 
> > end 
> > 
> > I get the errors: 
> > 
> > 1) profiles::logstash 
> >  Failure/Error: it { should contain_class("::logstash") } 
> >  Puppet::Error: 
> >Puppet::Parser::AST::Resource failed with error ArgumentError: 
> > Could not find declared class ::logstash at 
> > 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  
>
> > on node els4167.els.dev 
> >  # ./spec/classes/logstash_spec.rb:4 
> > 
> >   2) profiles::logstash 
> >  Failure/Error: it { should 
> > contain_class("profiles::logstash::install") } 
> >  Puppet::Error: 
> >Puppet::Parser::AST::Resource failed with error ArgumentError: 
> > Could not find declared class ::logstash at 
> > 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  
>
> > on node els4167.els.dev 
> >  # ./spec/classes/logstash_spec.rb:5 
> > 
> >   3) profiles::logstash 
> >  Failure/Error: it { should 
> > contain_class("profiles::logstash::config") } 
> >  Puppet::Error: 
> >Puppet::Parser::AST::Resource failed with error ArgumentError: 
> > Could not find declared class ::logstash at 
> > 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  
>
> > on node els4167.els.dev 
> >  # ./spec/classes/logstash_spec.rb:6 
> > 
> > How do I get rspec to find my class /etc/puppet/modules/logstash and get 
> > it to reference ::logstash as a disambiguation? 
>
> Hi Brian, 
>
> Using ::class is not needed and should not be done. If you still want to 
> do that in your class, try changing the spec by dropping the preceding 
> double colons. 
>
> Best regards, 
> -g 
>
> -- 
> Garrett Honeycutt 
> @learnpuppet 
> Puppet Training with LearnPuppet.com 
> Mobile: +1.206.414.8658 
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/213a161f-c1a4-4524-a0e0-d798fde6ef82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Garrett Honeycutt
On 6/4/14, 3:13 PM, Brian Wilkins wrote:
> I think you missed the part where it is complaining about line 10 in my
> profiles::logstash::install module
> 
> class { '::logstash':
> 
> Removing ::logstash from the spec file has the same complaint.
> 
> Brian
> 
> On Wednesday, June 4, 2014 3:11:14 PM UTC-4, Garrett Honeycutt wrote:
> 
> On 6/4/14, 2:30 PM, Brian Wilkins wrote:
> > I am trying to write unit tests of my puppet modules. In my
> > profiles::logstash::install, I disambiguate the call to
> > /etc/puppet/modules/logstash by using ::logstash in my class
> definition
> > like so:
> >
> > class profiles::logstash::install() {
> >   $ensure = $profiles::logstash::enable ? {true => present,
> default =>
> > absent}
> >   $status = $profiles::logstash::start ? {true => enabled, default =>
> > disabled}
> >
> >   class { '::logstash':
> > ensure  => $ensure,
> > status  => $status,
> > version => $profiles::logstash::version
> >   }
> > }
> >
> > However, when I run my spec file:
> >
> > require 'spec_helper'
> >
> > describe "profiles::logstash" do
> >   it { should contain_class("::logstash") }
> >   it { should contain_class("profiles::logstash::install") }
> >   it { should contain_class("profiles::logstash::config") }
> > end
> >
> > I get the errors:
> >
> > 1) profiles::logstash
> >  Failure/Error: it { should contain_class("::logstash") }
> >  Puppet::Error:
> >Puppet::Parser::AST::Resource failed with error ArgumentError:
> > Could not find declared class ::logstash at
> >
> 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
> 
> > on node els4167.els.dev
> >  # ./spec/classes/logstash_spec.rb:4
> >
> >   2) profiles::logstash
> >  Failure/Error: it { should
> > contain_class("profiles::logstash::install") }
> >  Puppet::Error:
> >Puppet::Parser::AST::Resource failed with error ArgumentError:
> > Could not find declared class ::logstash at
> >
> 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
> 
> > on node els4167.els.dev
> >  # ./spec/classes/logstash_spec.rb:5
> >
> >   3) profiles::logstash
> >  Failure/Error: it { should
> > contain_class("profiles::logstash::config") }
> >  Puppet::Error:
> >Puppet::Parser::AST::Resource failed with error ArgumentError:
> > Could not find declared class ::logstash at
> >
> 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
> 
> > on node els4167.els.dev
> >  # ./spec/classes/logstash_spec.rb:6
> >
> > How do I get rspec to find my class /etc/puppet/modules/logstash
> and get
> > it to reference ::logstash as a disambiguation?
> 
> Hi Brian,
> 
> Using ::class is not needed and should not be done. If you still
> want to
> do that in your class, try changing the spec by dropping the preceding
> double colons.
> 
> Best regards,
> -g
> 
> -- 
> Garrett Honeycutt
> @learnpuppet
> Puppet Training with LearnPuppet.com
> Mobile: +1.206.414.8658
> 

Hi Brian,

Recommend dropping the preceding double colons all around. It is not
needed at all.

Br,
-g



-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/538F78D3.8050806%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Brian Wilkins
It is needed to disambiguate from profiles::logstash and just logstash 
classes. If I remove it, then it will complain that logstash is already 
loaded when it tries to load profiles::logstash.

On Wednesday, June 4, 2014 3:52:01 PM UTC-4, Garrett Honeycutt wrote:
>
> On 6/4/14, 3:13 PM, Brian Wilkins wrote: 
> > I think you missed the part where it is complaining about line 10 in my 
> > profiles::logstash::install module 
> > 
> > class { '::logstash': 
> > 
> > Removing ::logstash from the spec file has the same complaint. 
> > 
> > Brian 
> > 
> > On Wednesday, June 4, 2014 3:11:14 PM UTC-4, Garrett Honeycutt wrote: 
> > 
> > On 6/4/14, 2:30 PM, Brian Wilkins wrote: 
> > > I am trying to write unit tests of my puppet modules. In my 
> > > profiles::logstash::install, I disambiguate the call to 
> > > /etc/puppet/modules/logstash by using ::logstash in my class 
> > definition 
> > > like so: 
> > > 
> > > class profiles::logstash::install() { 
> > >   $ensure = $profiles::logstash::enable ? {true => present, 
> > default => 
> > > absent} 
> > >   $status = $profiles::logstash::start ? {true => enabled, default 
> => 
> > > disabled} 
> > > 
> > >   class { '::logstash': 
> > > ensure  => $ensure, 
> > > status  => $status, 
> > > version => $profiles::logstash::version 
> > >   } 
> > > } 
> > > 
> > > However, when I run my spec file: 
> > > 
> > > require 'spec_helper' 
> > > 
> > > describe "profiles::logstash" do 
> > >   it { should contain_class("::logstash") } 
> > >   it { should contain_class("profiles::logstash::install") } 
> > >   it { should contain_class("profiles::logstash::config") } 
> > > end 
> > > 
> > > I get the errors: 
> > > 
> > > 1) profiles::logstash 
> > >  Failure/Error: it { should contain_class("::logstash") } 
> > >  Puppet::Error: 
> > >Puppet::Parser::AST::Resource failed with error 
> ArgumentError: 
> > > Could not find declared class ::logstash at 
> > > 
> > 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  
>
> > 
> > > on node els4167.els.dev 
> > >  # ./spec/classes/logstash_spec.rb:4 
> > > 
> > >   2) profiles::logstash 
> > >  Failure/Error: it { should 
> > > contain_class("profiles::logstash::install") } 
> > >  Puppet::Error: 
> > >Puppet::Parser::AST::Resource failed with error 
> ArgumentError: 
> > > Could not find declared class ::logstash at 
> > > 
> > 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  
>
> > 
> > > on node els4167.els.dev 
> > >  # ./spec/classes/logstash_spec.rb:5 
> > > 
> > >   3) profiles::logstash 
> > >  Failure/Error: it { should 
> > > contain_class("profiles::logstash::config") } 
> > >  Puppet::Error: 
> > >Puppet::Parser::AST::Resource failed with error 
> ArgumentError: 
> > > Could not find declared class ::logstash at 
> > > 
> > 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  
>
> > 
> > > on node els4167.els.dev 
> > >  # ./spec/classes/logstash_spec.rb:6 
> > > 
> > > How do I get rspec to find my class /etc/puppet/modules/logstash 
> > and get 
> > > it to reference ::logstash as a disambiguation? 
> > 
> > Hi Brian, 
> > 
> > Using ::class is not needed and should not be done. If you still 
> > want to 
> > do that in your class, try changing the spec by dropping the 
> preceding 
> > double colons. 
> > 
> > Best regards, 
> > -g 
> > 
> > -- 
> > Garrett Honeycutt 
> > @learnpuppet 
> > Puppet Training with LearnPuppet.com 
> > Mobile: +1.206.414.8658 
> > 
>
> Hi Brian, 
>
> Recommend dropping the preceding double colons all around. It is not 
> needed at all. 
>
> Br, 
> -g 
>
>
>
> -- 
> Garrett Honeycutt 
> @learnpuppet 
> Puppet Training with LearnPuppet.com 
> Mobile: +1.206.414.8658 
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/141ee867-2464-4187-9e55-5aab364c1700%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Johan De Wit

Hi,

the scoping of the class is indeed needed, but i believe that is a 
parser issue.


I did the test wit class { '::vim': version => '7.4' }

on my master with puppet master --compile  i got following :

{
  "metadata": {
"api_version": 1
  },
  "data": {
"classes": [
  "settings",

 

 "vim",



And that is what you should check in your rspec file.

In your manifests, you need indeed the scoping, in your spec, you don't

hth

jo


On 04/06/14 21:56, Brian Wilkins wrote:
It is needed to disambiguate from profiles::logstash and just logstash 
classes. If I remove it, then it will complain that logstash is 
already loaded when it tries to load profiles::logstash.


On Wednesday, June 4, 2014 3:52:01 PM UTC-4, Garrett Honeycutt wrote:

On 6/4/14, 3:13 PM, Brian Wilkins wrote:
> I think you missed the part where it is complaining about line
10 in my
> profiles::logstash::install module
>
> class { '::logstash':
>
> Removing ::logstash from the spec file has the same complaint.
>
> Brian
>
> On Wednesday, June 4, 2014 3:11:14 PM UTC-4, Garrett Honeycutt
wrote:
>
> On 6/4/14, 2:30 PM, Brian Wilkins wrote:
> > I am trying to write unit tests of my puppet modules. In my
> > profiles::logstash::install, I disambiguate the call to
> > /etc/puppet/modules/logstash by using ::logstash in my class
> definition
> > like so:
> >
> > class profiles::logstash::install() {
> >   $ensure = $profiles::logstash::enable ? {true => present,
> default =>
> > absent}
> >   $status = $profiles::logstash::start ? {true => enabled,
default =>
> > disabled}
> >
> >   class { '::logstash':
> > ensure  => $ensure,
> > status  => $status,
> > version => $profiles::logstash::version
> >   }
> > }
> >
> > However, when I run my spec file:
> >
> > require 'spec_helper'
> >
> > describe "profiles::logstash" do
> >   it { should contain_class("::logstash") }
> >   it { should contain_class("profiles::logstash::install") }
> >   it { should contain_class("profiles::logstash::config") }
> > end
> >
> > I get the errors:
> >
> > 1) profiles::logstash
> >  Failure/Error: it { should contain_class("::logstash") }
> >  Puppet::Error:
> >Puppet::Parser::AST::Resource failed with error
ArgumentError:
> > Could not find declared class ::logstash at
> >
>
/etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10


>
> > on node els4167.els.dev
> >  # ./spec/classes/logstash_spec.rb:4
> >
> >   2) profiles::logstash
> >  Failure/Error: it { should
> > contain_class("profiles::logstash::install") }
> >  Puppet::Error:
> >Puppet::Parser::AST::Resource failed with error
ArgumentError:
> > Could not find declared class ::logstash at
> >
>
/etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10


>
> > on node els4167.els.dev
> >  # ./spec/classes/logstash_spec.rb:5
> >
> >   3) profiles::logstash
> >  Failure/Error: it { should
> > contain_class("profiles::logstash::config") }
> >  Puppet::Error:
> >Puppet::Parser::AST::Resource failed with error
ArgumentError:
> > Could not find declared class ::logstash at
> >
>
/etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10


>
> > on node els4167.els.dev
> >  # ./spec/classes/logstash_spec.rb:6
> >
> > How do I get rspec to find my class
/etc/puppet/modules/logstash
> and get
> > it to reference ::logstash as a disambiguation?
>
> Hi Brian,
>
> Using ::class is not needed and should not be done. If you
still
> want to
> do that in your class, try changing the spec by dropping the
preceding
> double colons.
>
> Best regards,
> -g
>
> --
> Garrett Honeycutt
> @learnpuppet
> Puppet Training with LearnPuppet.com
> Mobile: +1.206.414.8658
>

Hi Brian,

Recommend dropping the preceding double colons all around. It is not
needed at all.

Br,
-g



-- 
Garrett Honeycutt

@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

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

Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Brian Wilkins
Thanks Johan. It turns out that I had to set my path's explicitly in my 
spec_helper.rb. For some reason, the automatically created spec_helper.rb 
created by rspec-puppet-init did not create a usuable file. My tests are 
running successfully now.

Brian

On Wednesday, June 4, 2014 5:05:05 PM UTC-4, Johan De Wit wrote:
>
>  Hi, 
>
> the scoping of the class is indeed needed, but i believe that is a parser 
> issue.
>
> I did the test wit class { '::vim': version => '7.4' }
>
> on my master with puppet master --compile  i got following :
>
> {
>   "metadata": {
> "api_version": 1
>   },
>   "data": {
> "classes": [
>   "settings",
>
>   
>
>  "vim",
>
> 
>
> And that is what you should check in your rspec file.  
>
> In your manifests, you need indeed the scoping, in your spec, you don't
>
> hth
>
> jo   
>
>
> On 04/06/14 21:56, Brian Wilkins wrote:
>  
> It is needed to disambiguate from profiles::logstash and just logstash 
> classes. If I remove it, then it will complain that logstash is already 
> loaded when it tries to load profiles::logstash.
>
> On Wednesday, June 4, 2014 3:52:01 PM UTC-4, Garrett Honeycutt wrote: 
>>
>> On 6/4/14, 3:13 PM, Brian Wilkins wrote: 
>> > I think you missed the part where it is complaining about line 10 in my 
>> > profiles::logstash::install module 
>> > 
>> > class { '::logstash': 
>> > 
>> > Removing ::logstash from the spec file has the same complaint. 
>> > 
>> > Brian 
>> > 
>> > On Wednesday, June 4, 2014 3:11:14 PM UTC-4, Garrett Honeycutt wrote: 
>> > 
>> > On 6/4/14, 2:30 PM, Brian Wilkins wrote: 
>> > > I am trying to write unit tests of my puppet modules. In my 
>> > > profiles::logstash::install, I disambiguate the call to 
>> > > /etc/puppet/modules/logstash by using ::logstash in my class 
>> > definition 
>> > > like so: 
>> > > 
>> > > class profiles::logstash::install() { 
>> > >   $ensure = $profiles::logstash::enable ? {true => present, 
>> > default => 
>> > > absent} 
>> > >   $status = $profiles::logstash::start ? {true => enabled, 
>> default => 
>> > > disabled} 
>> > > 
>> > >   class { '::logstash': 
>> > > ensure  => $ensure, 
>> > > status  => $status, 
>> > > version => $profiles::logstash::version 
>> > >   } 
>> > > } 
>> > > 
>> > > However, when I run my spec file: 
>> > > 
>> > > require 'spec_helper' 
>> > > 
>> > > describe "profiles::logstash" do 
>> > >   it { should contain_class("::logstash") } 
>> > >   it { should contain_class("profiles::logstash::install") } 
>> > >   it { should contain_class("profiles::logstash::config") } 
>> > > end 
>> > > 
>> > > I get the errors: 
>> > > 
>> > > 1) profiles::logstash 
>> > >  Failure/Error: it { should contain_class("::logstash") } 
>> > >  Puppet::Error: 
>> > >Puppet::Parser::AST::Resource failed with error 
>> ArgumentError: 
>> > > Could not find declared class ::logstash at 
>> > > 
>> > 
>> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>>  
>>
>> > 
>> > > on node els4167.els.dev 
>> > >  # ./spec/classes/logstash_spec.rb:4 
>> > > 
>> > >   2) profiles::logstash 
>> > >  Failure/Error: it { should 
>> > > contain_class("profiles::logstash::install") } 
>> > >  Puppet::Error: 
>> > >Puppet::Parser::AST::Resource failed with error 
>> ArgumentError: 
>> > > Could not find declared class ::logstash at 
>> > > 
>> > 
>> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>>  
>>
>> > 
>> > > on node els4167.els.dev 
>> > >  # ./spec/classes/logstash_spec.rb:5 
>> > > 
>> > >   3) profiles::logstash 
>> > >  Failure/Error: it { should 
>> > > contain_class("profiles::logstash::config") } 
>> > >  Puppet::Error: 
>> > >Puppet::Parser::AST::Resource failed with error 
>> ArgumentError: 
>> > > Could not find declared class ::logstash at 
>> > > 
>> > 
>> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>>  
>>
>> > 
>> > > on node els4167.els.dev 
>> > >  # ./spec/classes/logstash_spec.rb:6 
>> > > 
>> > > How do I get rspec to find my class /etc/puppet/modules/logstash 
>> > and get 
>> > > it to reference ::logstash as a disambiguation? 
>> > 
>> > Hi Brian, 
>> > 
>> > Using ::class is not needed and should not be done. If you still 
>> > want to 
>> > do that in your class, try changing the spec by dropping the 
>> preceding 
>> > double colons. 
>> > 
>> > Best regards, 
>> > -g 
>> > 
>> > -- 
>> > Garrett Honeycutt 
>> > @learnpuppet 
>> > Puppet Training with LearnPuppet.com 
>> > Mobile: +1.206.414.8658 
>> > 
>>
>> Hi Brian, 
>>
>> Recomm

Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-04 Thread Wolf Noble
Hi Brian,

I've found having my spec test print out a catalog is a good way to build out a 
suite of tests


context 'when the do_stuff param has the value of hell_yeah' do
  let (:facts) {{'osfamily' => 'RainbowOS }}
  let (:params) {{'do_stuff' => 'hell_yeah'}}
  It 'print a catalog for spec building' do
   p subject.resources
  end
end
context 'when the do_stuff param has the value of nope' do
  let (:facts) {{'osfamily' => 'RainbowOS }}
  let (:params) {{'do_stuff' => 'nope'}}
  It 'print a catalog for spec building' do
   p subject.resources
  end
end

Then I do some simple formatting on the subsequently generated catalogs in 
sublime text and review all the resources. With just a few tweaks it's pretty 
easy to grab the resources you actually care about from the catalog as rspec 
sees it.


HTH
-W
Sent from my iPad

> On Jun 4, 2014, at 1:30 PM, Brian Wilkins  wrote:
> 
> I am trying to write unit tests of my puppet modules. In my 
> profiles::logstash::install, I disambiguate the call to 
> /etc/puppet/modules/logstash by using ::logstash in my class definition like 
> so:
> 
> class profiles::logstash::install() {
>   $ensure = $profiles::logstash::enable ? {true => present, default => absent}
>   $status = $profiles::logstash::start ? {true => enabled, default => 
> disabled}
> 
>   class { '::logstash':
> ensure  => $ensure,
> status  => $status,
> version => $profiles::logstash::version
>   }
> }
> 
> However, when I run my spec file:
> 
> require 'spec_helper'
> 
> describe "profiles::logstash" do
>   it { should contain_class("::logstash") }
>   it { should contain_class("profiles::logstash::install") }
>   it { should contain_class("profiles::logstash::config") }
> end
> 
> I get the errors:
> 
> 1) profiles::logstash
>  Failure/Error: it { should contain_class("::logstash") }
>  Puppet::Error:
>Puppet::Parser::AST::Resource failed with error ArgumentError: Could 
> not find declared class ::logstash at 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  on node els4167.els.dev
>  # ./spec/classes/logstash_spec.rb:4
> 
>   2) profiles::logstash
>  Failure/Error: it { should contain_class("profiles::logstash::install") }
>  Puppet::Error:
>Puppet::Parser::AST::Resource failed with error ArgumentError: Could 
> not find declared class ::logstash at 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  on node els4167.els.dev
>  # ./spec/classes/logstash_spec.rb:5
> 
>   3) profiles::logstash
>  Failure/Error: it { should contain_class("profiles::logstash::config") }
>  Puppet::Error:
>Puppet::Parser::AST::Resource failed with error ArgumentError: Could 
> not find declared class ::logstash at 
> /etc/puppet/modules/profiles/spec/fixtures/modules/profiles/manifests/logstash/install.pp:10
>  on node els4167.els.dev
>  # ./spec/classes/logstash_spec.rb:6
> 
> How do I get rspec to find my class /etc/puppet/modules/logstash and get it 
> to reference ::logstash as a disambiguation?
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/a47b6fdb-519a-453c-92ec-40787c7d2470%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/BAD12348-3208-4763-B20D-70FD1C721B8B%40wolfspyre.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-05 Thread Felix Frank
On 06/04/2014 11:04 PM, Johan De Wit wrote:
> 
> And that is what you should check in your rspec file. 
> 
> In your manifests, you need indeed the scoping, in your spec, you don't

Humm, unfortunate.

Doesn't that (in theory) open you up for regressions in the form of
"does no longer include the properly scoped class, gets resolved to the
wrong class" like Brian described?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/53903EE3.6020809%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] rspec - Unable to find class ::logstash

2014-06-05 Thread Johan De Wit

On 05/06/14 11:56, Felix Frank wrote:

On 06/04/2014 11:04 PM, Johan De Wit wrote:

And that is what you should check in your rspec file.

In your manifests, you need indeed the scoping, in your spec, you don't

Humm, unfortunate.

Doesn't that (in theory) open you up for regressions in the form of
"does no longer include the properly scoped class, gets resolved to the
wrong class" like Brian described?


this is something to be tested I believe ...

TBC


--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer  (805008667232363)
Puppet Certified Professional 2013/2014 (PCP006)
_
 
Open-Future Phone +32 (0)2/255 70 70

Zavelstraat 72  Fax   +32 (0)2/255 70 71
3071 KORTENBERG Mobile+32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_
 


Next Events:
Puppet Advanced Training | 
https://www.open-future.be/puppet-advanced-training-10-till-12th-june
Puppet Introduction Course | 
https://www.open-future.be/puppet-introduction-course-13th-june
Linux Training | https://www.open-future.be/linux-training-16-till-20th-june
Subscribe to our newsletter | http://eepurl.com/BUG8H

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/53905191.2080802%40open-future.be.
For more options, visit https://groups.google.com/d/optout.