You're right. I just realized this in refactoring my tests. Push coming soon :smile:

Seth
On Feb 25, 2013, at 6:34 PM, Seth Chisamore <notifications@github.com> wrote:

> In lib/berkshelf/config.rb:
> 
> > @@ -29,16 +20,29 @@ def path=(new_path)
> >        # @return [String, nil]
> >        def chef_config_path
> >          @chef_config_path ||= begin
> > -          possibles = KNIFE_LOCATIONS.dup
> > +          possibles = []
> > +
> > +          # (mostly for testing purposes)
> > +          possibles << ENV['BERKSHELF_CHEF_CONFIG'] if ENV['BERKSHELF_CHEF_CONFIG']
> > +
> > +          # $KNIFE_HOME/knife.rb
> > +          possibles << File.join(ENV['KNIFE_HOME'], 'knife.rb') if ENV['KNIFE_HOME']
> > +
> > +          # $PWD/knife.rb
> > +          possibles << File.join(working_dir, 'knife.rb') if working_dir
> > +
> > +          # Ascending search for .chef directory
> > +          Pathname.new(working_dir).ascend do |file|
> > +            possibles << file.expand_path if file.basename == '.chef'
> The directory check wasn't my concern, I'm confused on how this code:
> 
> Pathname.new(working_dir).ascend do |file|
>   possibles << file.expand_path if file.basename == '.chef' && file.directory?
> end
> will ever actually get a .chef directory. For example:
> 
>  % irb
> irb(main):001:0> require 'pathname'
> => true
> irb(main):002:0> p = Pathname.new(Dir.pwd)
> => #<Pathname:/Users/schisamo/dev/code/opscode-cookbooks/opscode-ci>
> irb(main):003:0> p.ascend{ |file| puts "Path = #{file}, Basename = #{file.basename}" }
> Path = /Users/schisamo/dev/code/opscode-cookbooks/opscode-ci, Basename = opscode-ci
> Path = /Users/schisamo/dev/code/opscode-cookbooks, Basename = opscode-cookbooks
> Path = /Users/schisamo/dev/code, Basename = code
> Path = /Users/schisamo/dev, Basename = dev
> Path = /Users/schisamo, Basename = schisamo
> Path = /Users, Basename = Users
> Path = /, Basename = /
> => nil
> —
> Reply to this email directly or view it on GitHub.
>