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

Commit

Permalink
(maint) bump up code coverage
Browse files Browse the repository at this point in the history
* add a comment on SLV-116 to fix tech-debt in `RototillerParam`
* add some tests around `#parent_name=`
* add some docs around `RototillerParam`'s methods
  • Loading branch information
Eric Thompson committed May 3, 2018
1 parent 5a7e540 commit 8161c71
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/rototiller/task/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def message
return ''
end

# FIXME: (SLV-116) we shouldn't have env_var specific stuff in here
# we don't use this in other params, but if we did it would break them
# this breaks encapsulation a bit
# Record parent parameter's name so we can message appropriately
# @param [String] name parent's parameter instance name
# @api public
# @example param.parent_name = otherparam.name
def parent_name=(name)
name.each_char do |char|
message = "You have defined an environment variable with an illegal character: #{char}"
Expand All @@ -29,6 +36,10 @@ def parent_name=(name)
@parent_name = name
end

# Record parent param's message so we can message appropriately
# @param [String] name parent parameter's message
# @api public
# @example param.parent_message = otherparam.message
def parent_message=(message)
@parent_message = message
end
Expand Down
14 changes: 14 additions & 0 deletions spec/rototiller/task/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ module Task
expect(described_class.new.message).to eq('')
end
end
context '#parent_name=' do
let (:param) {described_class.new}
it 'sets @parent_name' do
param.parent_name = 'superkoolname'
expect(param.parent_name).to eq('superkoolname')
end
it 'protects against illegal env_vars' do
#raise ArgumentError.new(message) unless char =~ /[a-zA-Z]|\d|_/
# no hyphens
expect{ param.parent_name = '-' }.to raise_error(ArgumentError)
# no special chars
expect{ param.parent_name = '%' }.to raise_error(ArgumentError)
end
end
end

end
Expand Down

0 comments on commit 8161c71

Please sign in to comment.