On Tue, Apr 10, 2012 at 11:00 PM, Wil Cooley <wilcoo...@gmail.com> wrote:
> I have been working on adding some predicate functions to puppetlabs-stdlib
> that test things based on 'interfaces' and related facts.

Sweet!

> The functions themselves seem to work fine in my manifest-based smoketests,
> but I am running into trouble that may or may not be due to my ignorance
> about rspec or Facter. Something needs to be done to initialize Facter
> because lookupvar('interfaces') just returns :undefined. I have not found
> any examples in the existing rspec tests; getvar_spec.rb seems like it
> should have something but the tests it does are pretty basic.

In general, you should assume the spec_helper for stdlib will
initialize facter for you.  In fact, you don't need to do require
'facter' in your example specification.

> You can see some of what I've been trying at
> https://github.com/wcooley/puppetlabs-stdlib/blob/master/spec/unit/puppet/parser/functions/has_interface_with_spec.rb

Cool, I went ahead and pulled down your branch.  If I might make a
suggestion, I notice you're developing on the "master branch" and you
have a number of commits that have not actually been merged into the
"master" branch of the puppetlabs repository.

This situation of having two different branches, both named master, is
confusing and makes it a bit difficult to work with.

When using Git, creating new branches is almost effortless.  It's just
two commands.

When you start hacking please create a topic branch:

# Create a branch indicating this is a new feature based on master
having something to do with an interface function
git branch feature/master/has_interface_with_function origin/master
# Checkout the branch
git checkout feature/master/has_interface_with_spec
# Hack away

It's also fairly easy to rename your current topic branch which is
named "master"

# Rename your local master branch to a topic branch
git branch rename master  feature/master/has_interface_with_function

# Push the new name to your github repository
git push wcooley
feature/master/has_interface_with_function:feature/master/has_interface_with_function

# Set your local topic branch to track the published copy of it.
git branch --set-upstream feature/master/has_interface_with_function
wcooley/feature/master/has_interface_with_function

# Re-synchronize the Puppet Labs master branch (I assume origin is
git://github.com/puppetlabs/puppetlabs-stdlib.git)
git fetch origin

# Create your local master tracking Puppet Labs master  (These should
always be in sync.  Don't commit on this branch...)
git branch master --track origin/master

# Replace your own master branch on Github with the Puppet Labs master
branch (because it's not actually master right now)
git push wcooley +origin/master:master

# Finally, work in your topic branch
git co feature/master/has_interface_with_function

> Is there something obvious I'm missing?

The setup looks to be quite strange.  You shouldn't ever need to
define a get_scope method.  I recommend looking at the
validate_re_spec.rb for a good example.

I'm also re-working your topic branch in my own if you'd like to take
a look at the changes.

-Jeff

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to