Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "force" attribute to link resource #128

Merged
merged 1 commit into from
May 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion itamae.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion lib/itamae/resource/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/integration/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/integration/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down