2525 context 'when registering a minimal type' do
2626 let ( :definition ) { { name : 'minimal' , attributes : { } } }
2727
28- it { expect { described_class . register_type ( definition ) } . not_to raise_error }
28+ it {
29+ expect ( Puppet ) . to receive ( :warning ) . with ( '`minimal` has no documentation, add it using a `desc` key' )
30+ described_class . register_type ( definition )
31+ }
2932
3033 describe 'the registered type' do
3134 subject ( :type ) { Puppet ::Type . type ( :minimal ) }
4043 end
4144 end
4245
46+ context 'when registering a type with both desc and docs key' do
47+ let ( :definition ) { { name : 'both' , desc : 'the desc' , docs : 'the docs' , attributes : { } } }
48+
49+ it {
50+ expect { described_class . register_type ( definition ) } . to raise_error Puppet ::DevError , '`both` has both `desc` and `docs`, prefer using `desc`'
51+ }
52+ end
53+
54+ context 'when registering a type with a docs key' do
55+ let ( :definition ) { { name : 'both' , docs : 'the docs' , attributes : { } } }
56+
57+ it { expect { described_class . register_type ( definition ) } . not_to raise_error }
58+
59+ describe 'the registered type' do
60+ subject ( :type ) { Puppet ::Type . type ( :both ) }
61+
62+ it { is_expected . not_to be_nil }
63+ it { is_expected . to be_respond_to :instances }
64+ it { expect ( type . instance_variable_get ( :@docs ) ) . to eq 'the docs' }
65+ end
66+ end
67+
4368 context 'when registering a type with multiple attributes' do
4469 let ( :definition ) do
4570 {
4671 name : type_name ,
72+ desc : 'a test resource' ,
4773 attributes : {
4874 name : {
4975 type : 'String' ,
@@ -747,6 +773,7 @@ def set(_context, _changes); end
747773 let ( :definition ) do
748774 {
749775 name : 'init_behaviour' ,
776+ desc : 'a test resource' ,
750777 attributes : {
751778 ensure : {
752779 type : 'Enum[present, absent]' ,
@@ -1172,7 +1199,7 @@ def set(_context, _changes); end
11721199 context 'when loading a provider that doesn\'t create the correct class' do
11731200 let ( :definition ) { { name : 'no_class' , attributes : { } } }
11741201
1175- it { expect { described_class . load_provider ( 'no_class' ) } . to raise_error Puppet ::DevError , %r{Puppet::Provider::NoClass::NoClass} }
1202+ it { expect { described_class . load_provider ( 'no_class' ) } . to raise_error Puppet ::DevError , %r{provider class Puppet::Provider::NoClass::NoClass not found } }
11761203 end
11771204
11781205 context 'when loading a provider that creates the correct class' do
@@ -1792,6 +1819,7 @@ def set(_context, changes) end
17921819 let ( :definition ) do
17931820 {
17941821 name : 'test_noop_support' ,
1822+ desc : 'a test resource' ,
17951823 features : [ 'no such feature' ] ,
17961824 attributes : { } ,
17971825 }
@@ -1808,6 +1836,7 @@ def set(_context, changes) end
18081836 let ( :definition ) do
18091837 {
18101838 name : 'test_behaviour' ,
1839+ desc : 'a test resource' ,
18111840 attributes : {
18121841 id : {
18131842 type : 'String' ,
@@ -1824,6 +1853,7 @@ def set(_context, changes) end
18241853 let ( :definition ) do
18251854 {
18261855 name : 'test_behaviour' ,
1856+ desc : 'a test resource' ,
18271857 attributes : {
18281858 param : {
18291859 type : 'String' ,
@@ -1840,6 +1870,7 @@ def set(_context, changes) end
18401870 let ( :definition ) do
18411871 {
18421872 name : 'test_behaviour' ,
1873+ desc : 'a test resource' ,
18431874 attributes : {
18441875 param_ro : {
18451876 type : 'String' ,
@@ -1856,6 +1887,7 @@ def set(_context, changes) end
18561887 let ( :definition ) do
18571888 {
18581889 name : 'test_behaviour' ,
1890+ desc : 'a test resource' ,
18591891 attributes : {
18601892 param_ro : {
18611893 type : 'String' ,
@@ -1872,6 +1904,7 @@ def set(_context, changes) end
18721904 let ( :definition ) do
18731905 {
18741906 name : 'test_behaviour' ,
1907+ desc : 'a test resource' ,
18751908 attributes : {
18761909 source : {
18771910 type : 'String' ,
0 commit comments