Autoloader for f-n's doesn't work well with other tests #44

Closed
haf opened this Issue Aug 31, 2012 · 8 comments

Comments

Projects
None yet
4 participants
@haf

haf commented Aug 31, 2012

Create two specs. One testing a class, one testing a function. Use an already defined puppet in the class.

If you test both, e.g. rspec spec/, then the one executed 2nd will raise this error:

     Failure/Error: output = subject.call({
     Puppet::Error:
       Could not autoload /home/xyz/labs/puppet-riak/spec/fixtures/modules/hiera-puppet/lib/puppet/parser/functions/hiera.rb: Function hiera already defined

From line 10 in function_example.rb, Puppet::Parser::Functions.autoloader.loadall.

Gem 0.1.4.

Note, that the current master doesn't load functions in the same way; so if you're not very much against it, a release would be welcome to try out the new code.

@baron1405

This comment has been minimized.

Show comment Hide comment
@baron1405

baron1405 Oct 30, 2012

I just hit this as well in 0.1.4. I have a test of a class that loads an erb that calls my function. This causes the function to get loaded explicitly by the autloader (i.e. load). Later the function test machinery calls autoloader.loadall but since the autoloader thinks the function is already loaded, it is not loaded again and never makes it into the Scope. So I end up with a NameError due to an undefined method on Puppet::Parser::Scope. Not sure how to work around this yet.

I just hit this as well in 0.1.4. I have a test of a class that loads an erb that calls my function. This causes the function to get loaded explicitly by the autloader (i.e. load). Later the function test machinery calls autoloader.loadall but since the autoloader thinks the function is already loaded, it is not loaded again and never makes it into the Scope. So I end up with a NameError due to an undefined method on Puppet::Parser::Scope. Not sure how to work around this yet.

@baron1405

This comment has been minimized.

Show comment Hide comment
@baron1405

baron1405 Oct 31, 2012

A work around is to force the loading of the function as a before method in the describe:

describe 'foofunc' do
    before(:each) do
        Puppet::Parser::Functions.function(:foofunc)
    end
    ...

A work around is to force the loading of the function as a before method in the describe:

describe 'foofunc' do
    before(:each) do
        Puppet::Parser::Functions.function(:foofunc)
    end
    ...
@duritong

This comment has been minimized.

Show comment Hide comment
@duritong

duritong Dec 20, 2012

In combination with rspec-hiera-puppet I also encountered this problem, as this would load the hiera functions.

I solved it by commenting https://github.com/rodjek/rspec-puppet/blob/v0.1.4/lib/rspec-puppet/example/function_example_group.rb#L10

And then adding the mentioned block above.

Yes, this is also on 0.1.4 - didn't yet test with the latest version. This is more ftr.

In combination with rspec-hiera-puppet I also encountered this problem, as this would load the hiera functions.

I solved it by commenting https://github.com/rodjek/rspec-puppet/blob/v0.1.4/lib/rspec-puppet/example/function_example_group.rb#L10

And then adding the mentioned block above.

Yes, this is also on 0.1.4 - didn't yet test with the latest version. This is more ftr.

@haf

This comment has been minimized.

Show comment Hide comment
@haf

haf Jan 29, 2013

Bugfixing for puppet critical infrastructure doesn't go too fast...

haf commented Jan 29, 2013

Bugfixing for puppet critical infrastructure doesn't go too fast...

@rodjek

This comment has been minimized.

Show comment Hide comment
@rodjek

rodjek Jan 29, 2013

Owner

@haf sorry, I must have missed your pull request where you fixed this?

Other people have full time jobs too, sometimes this doesn't leave as much time for hacking on side projects as we'd like.

Also, I still haven't seen anyone mention whether they can reproduce this on the current version...

Owner

rodjek commented Jan 29, 2013

@haf sorry, I must have missed your pull request where you fixed this?

Other people have full time jobs too, sometimes this doesn't leave as much time for hacking on side projects as we'd like.

Also, I still haven't seen anyone mention whether they can reproduce this on the current version...

@haf

This comment has been minimized.

Show comment Hide comment
@haf

haf Jan 30, 2013

I didn't mean that you fix it. I just think that TDDing would be such an obviously great feature for puppetlabs that it would be fixed by them within five months. Or at least be commented on by them. And your project is the de-facto standard.

I do spend a great deal of time sending pull requests, amongst those there are some towards puppetlabs' projects, actually. The last pull request in that direction went towards improving their PostgreSQL puppet repo. In this case, it's too deep into the code base for me, at my current puppet knowledge level.

haf commented Jan 30, 2013

I didn't mean that you fix it. I just think that TDDing would be such an obviously great feature for puppetlabs that it would be fixed by them within five months. Or at least be commented on by them. And your project is the de-facto standard.

I do spend a great deal of time sending pull requests, amongst those there are some towards puppetlabs' projects, actually. The last pull request in that direction went towards improving their PostgreSQL puppet repo. In this case, it's too deep into the code base for me, at my current puppet knowledge level.

@rodjek

This comment has been minimized.

Show comment Hide comment
@rodjek

rodjek Feb 24, 2013

Owner

Can anyone confirm that they're still seeing this issue in the latest version of rspec-puppet (0.1.6)?

Owner

rodjek commented Feb 24, 2013

Can anyone confirm that they're still seeing this issue in the latest version of rspec-puppet (0.1.6)?

@rodjek

This comment has been minimized.

Show comment Hide comment
@rodjek

rodjek Apr 5, 2013

Owner

Closing for now. Please re-open it if you can recreate the issue on 0.1.6.

Owner

rodjek commented Apr 5, 2013

Closing for now. Please re-open it if you can recreate the issue on 0.1.6.

@rodjek rodjek closed this Apr 5, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment