Skip to content

Commit

Permalink
fix bug when using passed in project_dir when using the API directly
Browse files Browse the repository at this point in the history
  • Loading branch information
logicminds committed May 18, 2015
1 parent 2cf75b0 commit 6963ccb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source 'https://rubygems.org'
gemspec

gem 'pry'
2 changes: 1 addition & 1 deletion lib/librarian/puppet/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Receiver < Librarian::Dsl::Receiver

# save the specfile and call librarian
def run(specfile = nil)
@working_path = specfile.kind_of?(Pathname) ? specfile.parent : Pathname.new(Dir.pwd)
@working_path = specfile.path.kind_of?(Pathname) ? specfile.path.parent : (Dir.pwd)
@specfile = specfile
super
end
Expand Down
20 changes: 20 additions & 0 deletions spec/receiver_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

describe 'Librarian::Puppet::Receiver' do

describe '#run' do

it 'working_dir from pwd' do
rec = Librarian::Puppet::Receiver.new(target)
rec.run(nil)
expect(rec.working_dir).to eq(Dir.pwd)
end

it 'working_dir from given path' do
rec = Librarian::Puppet::Receiver.new(target)
specfile = Pathname.new('/tmp/tmp_module/Puppetfile')
rec.run(specfile)
expect(rec.working_dir).to eq('/tmp/tmp_module')
end
end
end

0 comments on commit 6963ccb

Please sign in to comment.