Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #16 from miroswan/fix/directory
Browse files Browse the repository at this point in the history
Fix/directory
  • Loading branch information
miroswan authored Aug 13, 2016
2 parents f9ac7b0 + b816eb7 commit c52de80
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/vagrant_spec/command/init.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# encoding: UTF-8

require 'fileutils'

require 'vagrant_spec/ansible_inventory'
require 'vagrant_spec/machine_data'
require 'vagrant_spec/config'
Expand Down Expand Up @@ -30,6 +32,7 @@ def initialize(argv, env)

def execute
return unless parse_opts
FileUtils.mkdir @directory unless Dir.exist? @directory
unless @ansible_inventory == DEFAULTS['ansible_inventory']
VagrantSpec::AnsibleInventory.new(@env).generate
end
Expand Down
1 change: 1 addition & 0 deletions scripts/poor_mans_smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bundle exec vagrant spec test -h
bundle exec vagrant spec no_command -h
rm -f "serverspec/spec_helper.rb"
rm -f ".vagrantspec_machine_data"
rm -f "vagrantspec_inventory"
bundle exec vagrant up
bundle exec vagrant spec init
ansible-playbook site.yml -i vagrantspec_inventory
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/vagrant_spec_test/command_spec/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def execute_proc
allow_any_instance_of(VagrantSpec::MachineData).to receive(:generate)
allow(mock_ansible_inventory).to receive(:generate)
allow(mock_machine_data).to receive(:generate)
allow(Dir).to receive(:exist?) { false }
allow(FileUtils).to receive(:mkdir)
end
end

Expand All @@ -55,6 +57,14 @@ def execute_protection_proc
end
end

context 'when the @directory does not exist' do
it '#execute creates the @directory' do
execute_protection_proc.call
expect(FileUtils).to receive(:mkdir).with(subject.directory)
subject.execute
end
end

context 'and when @ansible_inventory eq empty hash,' do
it '#execute creates an instance of VagrantSpec::SpecHelper' do
execute_protection_proc.call
Expand Down

0 comments on commit c52de80

Please sign in to comment.