Skip to content

Commit

Permalink
Add tests for user_right_assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
raphink committed May 4, 2018
1 parent 31064f5 commit 887fe34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/type/user_right_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
desc 'The right to append users to'

validate do |value|
fail "Invalid right name #{value}" unless value =~ /^[A-Za-z]+$/
fail "Not a valid right name: '#{value}'" unless value =~ /^[A-Za-z]+$/
end

munge do |value|
Expand Down
19 changes: 18 additions & 1 deletion spec/unit/puppet/type/user_right_assignment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
require 'spec_helper'

describe Puppet::Type.type(:user_rights_assignment) do
describe Puppet::Type.type(:user_right_assignment) do
let(:valid_right) { 'seassignprimarytokenprivilege' }

context 'when validating right' do
it 'should accept a valid string' do
res = described_class.new(:title => 'abc', :right => valid_right)
expect(res[:right]).to eq(valid_right)
end

it 'should fail with an invalid right' do
expect {
described_class.new(
:title => 'abc',
:right => 'abc1',
)
}.to raise_error(Puppet::Error, /Not a valid right name: 'abc1'/)
end
end
end

0 comments on commit 887fe34

Please sign in to comment.