CHEF-3237: code review + help needed for rspec test


#1

Hello,

I am trying to fix CHEF-3237 based on the suggestion of Bryan McLellan to
check for the existence of the HOME environment variable rather than
checking for root.

http://tickets.opscode.com/browse/CHEF-3237

I have changed some code and tried to add an RSpec test to it, but I’m
failing miserably on that part.

https://github.com/atriso/chef/commit/767d4bff1ea801c22f195b94e50b197f239ecea7

Two questions:

  1. Can someone review my changes for the Mac OS X service provider?
  2. What am I doing wrong with my rspec test? I tried numerous things but
    always get an error about ‘new_resource’ not being defined.

Failures:

  1. Chef::Provider::Service::Macosx loading
    Chef::Provider::Service::Macosx with HOME defined expands PLIST_DIRS with
    ~/Library/LaunchAgents
    Failure/Error: let(:provider) { described_class.new(new_resource,
    run_context) }
    NameError:
    undefined local variable or method `new_resource’ for
    #RSpec::Core::ExampleGroup::Nested_1::Nested_3::Nested_1:0x1085f90c0

    ./spec/unit/provider/service/macosx_spec.rb:25

    ./spec/unit/provider/service/macosx_spec.rb:30

Greetings,

Ringo


#2

I’m no Ruby expert, but you’ve gone and replaced the initialize method
which is part of the default constructor? Won’t that cause problems?

  • Julian

On Tue, Feb 5, 2013 at 11:23 AM, Ringo De Smet ringo.desmet@gmail.comwrote:

Hello,

I am trying to fix CHEF-3237 based on the suggestion of Bryan McLellan to
check for the existence of the HOME environment variable rather than
checking for root.

http://tickets.opscode.com/browse/CHEF-3237

I have changed some code and tried to add an RSpec test to it, but I’m
failing miserably on that part.

https://github.com/atriso/chef/commit/767d4bff1ea801c22f195b94e50b197f239ecea7

Two questions:

  1. Can someone review my changes for the Mac OS X service provider?
  2. What am I doing wrong with my rspec test? I tried numerous things but
    always get an error about ‘new_resource’ not being defined.

Failures:

  1. Chef::Provider::Service::Macosx loading
    Chef::Provider::Service::Macosx with HOME defined expands PLIST_DIRS with
    ~/Library/LaunchAgents
    Failure/Error: let(:provider) { described_class.new(new_resource,
    run_context) }
    NameError:
    undefined local variable or method `new_resource’ for
    #RSpec::Core::ExampleGroup::Nested_1::Nested_3::Nested_1:0x1085f90c0

    ./spec/unit/provider/service/macosx_spec.rb:25

    ./spec/unit/provider/service/macosx_spec.rb:30

Greetings,

Ringo


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]