Chef 11.6.0 - Chefspec test failures on template resource


#1

Hey everyone, i noticed something today when running chefspec with chef
11.6.0 and dealing with the template resource.

I did see some larger changes to the template resource as part of the
release and wondering if anyone knows what might be going on.
http://docs.opscode.com/release_notes.html#resource-template-attributes

I have a simple recipe and template (and specific chefspec test)

In the gist you can see that the test fails with a odd error:

  1. recipe::default should include correct content
    Failure/Error: @chef_run.should create_file_with_content @file,
    NameError:
    undefined local variable or method `node’ for
    #Erubis::Context:0x007fccc30b9bf8

    (erubis):3:in `block in evaluate’

    ./spec/default_spec.rb:20:in `block (2 levels) in <top (required)>’

If I converge the recipe - everything works as expected - and the file
is written out with the correct value from the attribute.

If I run this with 11.4.4 the tests pass, but fail with 11.6.0

Reading the 11.6.0 release notes I know there are better ways to do
this (that i’ll be using) but i’m curious why it fails in this case as
there are a bunch of templates that have things like: <%=
node[“foo”][“bar”][“baz”] %>

Any ideas?


#2

Actually did some more testing and it seems that the test works in chef
11.4.2 but fails in 11.4.4 - So not actually an 11.6 problem.

-Pete

On Wed, Jul 24, 2013 at 2:37 PM, Pete Cheslock petecheslock@gmail.comwrote:

Hey everyone, i noticed something today when running chefspec with chef
11.6.0 and dealing with the template resource.

I did see some larger changes to the template resource as part of the
release and wondering if anyone knows what might be going on.
http://docs.opscode.com/release_notes.html#resource-template-attributes

I have a simple recipe and template (and specific chefspec test)
https://gist.github.com/petecheslock/999de67d5620e811a20c

In the gist you can see that the test fails with a odd error:

  1. recipe::default should include correct content
    Failure/Error: @chef_run.should create_file_with_content @file,

NameError:
undefined local variable or method node' for #<Erubis::Context:0x007fccc30b9bf8> # (erubis):3:inblock in evaluate’
# ./spec/default_spec.rb:20:in `block (2 levels) in <top (required)>’

If I converge the recipe - everything works as expected - and the file is written out with the correct value from the attribute.

If I run this with 11.4.4 the tests pass, but fail with 11.6.0

Reading the 11.6.0 release notes I know there are better ways to do this (that i’ll be using) but i’m curious why it fails in this case as there are a bunch of templates that have things like: <%= node[“foo”][“bar”][“baz”] %>

Any ideas?


#3

Damn - I was wrong. Missed something in my testing - it DOES work in
11.4.2 & 11.4.4 - but the chefspec test only failed on 11.6.0.

Which I guess would make sense as there were massive updates there - not
sure why the test fails and everything else works though.

On Wed, Jul 24, 2013 at 4:55 PM, Pete Cheslock petecheslock@gmail.comwrote:

Actually did some more testing and it seems that the test works in chef
11.4.2 but fails in 11.4.4 - So not actually an 11.6 problem.

-Pete

On Wed, Jul 24, 2013 at 2:37 PM, Pete Cheslock petecheslock@gmail.comwrote:

Hey everyone, i noticed something today when running chefspec with chef
11.6.0 and dealing with the template resource.

I did see some larger changes to the template resource as part of the
release and wondering if anyone knows what might be going on.
http://docs.opscode.com/release_notes.html#resource-template-attributes

I have a simple recipe and template (and specific chefspec test)
https://gist.github.com/petecheslock/999de67d5620e811a20c

In the gist you can see that the test fails with a odd error:

  1. recipe::default should include correct content
    Failure/Error: @chef_run.should create_file_with_content @file,

NameError:
undefined local variable or method node' for #<Erubis::Context:0x007fccc30b9bf8> # (erubis):3:inblock in evaluate’
# ./spec/default_spec.rb:20:in `block (2 levels) in <top (required)>’

If I converge the recipe - everything works as expected - and the file is written out with the correct value from the attribute.

If I run this with 11.4.4 the tests pass, but fail with 11.6.0

Reading the 11.6.0 release notes I know there are better ways to do this (that i’ll be using) but i’m curious why it fails in this case as there are a bunch of templates that have things like: <%= node[“foo”][“bar”][“baz”] %>

Any ideas?