diff --git a/itamae.gemspec b/itamae.gemspec index daf751c1..65c70f46 100644 --- a/itamae.gemspec +++ b/itamae.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_runtime_dependency "thor" - spec.add_runtime_dependency "specinfra", [">= 2.29.0", "< 3.0.0"] + spec.add_runtime_dependency "specinfra", [">= 2.31.0", "< 3.0.0"] spec.add_runtime_dependency "hashie" spec.add_runtime_dependency "ansi" spec.add_runtime_dependency "schash", "~> 0.1.0" diff --git a/lib/itamae/resource/link.rb b/lib/itamae/resource/link.rb index 672f449e..27206734 100644 --- a/lib/itamae/resource/link.rb +++ b/lib/itamae/resource/link.rb @@ -6,6 +6,7 @@ class Link < Base define_attribute :action, default: :create define_attribute :link, type: String, default_name: true define_attribute :to, type: String, required: true + define_attribute :force, default: false def pre_action case @current_action @@ -24,7 +25,7 @@ def set_current_attributes def action_create(options) unless run_specinfra(:check_file_is_linked_to, attributes.link, attributes.to) - run_specinfra(:link_file_to, attributes.link, attributes.to) + run_specinfra(:link_file_to, attributes.link, attributes.to, force: attributes.force) end end end diff --git a/spec/integration/default_spec.rb b/spec/integration/default_spec.rb index f417c2c8..d5a9e6b6 100644 --- a/spec/integration/default_spec.rb +++ b/spec/integration/default_spec.rb @@ -97,6 +97,10 @@ end end +describe file('/tmp-link-force') do + it { should be_linked_to '/tmp' } +end + describe command('cd /tmp/git_repo && git rev-parse HEAD') do its(:stdout) { should match(/3116e170b89dc0f7315b69c1c1e1fd7fab23ac0d/) } end diff --git a/spec/integration/recipes/default.rb b/spec/integration/recipes/default.rb index 0a1f1c74..e72d5ed7 100644 --- a/spec/integration/recipes/default.rb +++ b/spec/integration/recipes/default.rb @@ -170,6 +170,12 @@ to "/tmp" end +execute "touch /tmp-link-force" +link "/tmp-link-force" do + to "/tmp" + force true +end + ##### local_ruby_block "greeting" do