4747 context 'when registering a minimal type' do
4848 let ( :definition ) { { name : 'minimal' , attributes : { } } }
4949
50- it { expect { described_class . register_type ( definition ) } . not_to raise_error }
50+ it {
51+ expect ( Puppet ) . to receive ( :warning ) . with ( '`minimal` has no documentation, add it using a `desc` key' )
52+ described_class . register_type ( definition )
53+ }
5154
5255 describe 'the registered type' do
5356 subject ( :type ) { Puppet ::Type . type ( :minimal ) }
6265 end
6366 end
6467
68+ context 'when registering a type with both desc and docs key' do
69+ let ( :definition ) { { name : 'both' , desc : 'the desc' , docs : 'the docs' , attributes : { } } }
70+
71+ it {
72+ expect { described_class . register_type ( definition ) } . to raise_error Puppet ::DevError , '`both` has both `desc` and `docs`, prefer using `desc`'
73+ }
74+ end
75+
76+ context 'when registering a type with a docs key' do
77+ let ( :definition ) { { name : 'both' , docs : 'the docs' , attributes : { } } }
78+
79+ it { expect { described_class . register_type ( definition ) } . not_to raise_error }
80+
81+ describe 'the registered type' do
82+ subject ( :type ) { Puppet ::Type . type ( :both ) }
83+
84+ it { is_expected . not_to be_nil }
85+ it { is_expected . to be_respond_to :instances }
86+ it { expect ( type . instance_variable_get ( :@docs ) ) . to eq 'the docs' }
87+ end
88+ end
89+
6590 context 'when registering a type with multiple attributes' do
6691 let ( :definition ) do
6792 {
6893 name : type_name ,
94+ desc : 'a test resource' ,
6995 attributes : {
7096 name : {
7197 type : 'String' ,
@@ -769,6 +795,7 @@ def set(_context, _changes); end
769795 let ( :definition ) do
770796 {
771797 name : 'init_behaviour' ,
798+ desc : 'a test resource' ,
772799 attributes : {
773800 ensure : {
774801 type : 'Enum[present, absent]' ,
@@ -1253,7 +1280,7 @@ def set(_context, _changes); end
12531280 context 'when loading a provider that doesn\'t create the correct class' do
12541281 let ( :definition ) { { name : 'no_class' , attributes : { } } }
12551282
1256- it { expect { described_class . load_provider ( 'no_class' ) } . to raise_error Puppet ::DevError , %r{Puppet::Provider::NoClass::NoClass} }
1283+ it { expect { described_class . load_provider ( 'no_class' ) } . to raise_error Puppet ::DevError , %r{provider class Puppet::Provider::NoClass::NoClass not found } }
12571284 end
12581285
12591286 context 'when loading a provider that creates the correct class' do
@@ -1810,6 +1837,7 @@ def set(_context, changes) end
18101837 let ( :definition ) do
18111838 {
18121839 name : 'test_noop_support' ,
1840+ desc : 'a test resource' ,
18131841 features : [ 'no such feature' ] ,
18141842 attributes : { } ,
18151843 }
@@ -1826,6 +1854,7 @@ def set(_context, changes) end
18261854 let ( :definition ) do
18271855 {
18281856 name : 'test_behaviour' ,
1857+ desc : 'a test resource' ,
18291858 attributes : {
18301859 id : {
18311860 type : 'String' ,
@@ -1842,6 +1871,7 @@ def set(_context, changes) end
18421871 let ( :definition ) do
18431872 {
18441873 name : 'test_behaviour' ,
1874+ desc : 'a test resource' ,
18451875 attributes : {
18461876 param : {
18471877 type : 'String' ,
@@ -1858,6 +1888,7 @@ def set(_context, changes) end
18581888 let ( :definition ) do
18591889 {
18601890 name : 'test_behaviour' ,
1891+ desc : 'a test resource' ,
18611892 attributes : {
18621893 param_ro : {
18631894 type : 'String' ,
@@ -1874,6 +1905,7 @@ def set(_context, changes) end
18741905 let ( :definition ) do
18751906 {
18761907 name : 'test_behaviour' ,
1908+ desc : 'a test resource' ,
18771909 attributes : {
18781910 param_ro : {
18791911 type : 'String' ,
@@ -1890,6 +1922,7 @@ def set(_context, changes) end
18901922 let ( :definition ) do
18911923 {
18921924 name : 'test_behaviour' ,
1925+ desc : 'a test resource' ,
18931926 attributes : {
18941927 source : {
18951928 type : 'String' ,
0 commit comments