spec/unit/puppet-strings/json_spec.rb in puppet-strings-2.2.0 vs spec/unit/puppet-strings/json_spec.rb in puppet-strings-2.3.0

- old
+ new

@@ -19,30 +19,44 @@ # @param param1 First param. # @param param2 Second param. # @param param3 Third param. define dt(Integer $param1, $param2, String $param3 = hi) { } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) if TEST_PUPPET_PLANS # A simple plan. # @param param1 First param. # @param param2 Second param. # @param param3 Third param. plan plann(String $param1, $param2, Integer $param3 = 1) { } -SOURCE + SOURCE # Only include Puppet functions for 4.1+ YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) if TEST_PUPPET_FUNCTIONS # A simple function. # @param param1 First param. # @param param2 Second param. # @param param3 Third param. # @return [Undef] Returns nothing. function func(Integer $param1, $param2, String $param3 = hi) { } + SOURCE + + # Only include Puppet types for 5.0+ + YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) if TEST_PUPPET_DATATYPES +# Basic Puppet Data Type in Ruby +# +# @param msg A message parameter +Puppet::DataTypes.create_type('RubyDataType') do + interface <<-PUPPET + attributes => { + msg => String[1] + } + PUPPET +end SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :json) { "description": "Allows you to backup your database to local file.", @@ -64,11 +78,11 @@ "description": "Path to file you want backup to", "type": "String[1]" } } } -SOURCE + SOURCE YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby) Puppet::Parser::Functions.newfunction(:func3x, doc: <<-DOC An example 3.x function. @param [String] first The first parameter. @@ -197,17 +211,22 @@ autorequires: { file: '$source', # will evaluate to the value of the `source` attribute package: 'apt', }, ) -SOURCE + SOURCE end RSpec.shared_examples "correct JSON" do it 'should include data for Puppet Classes' do puppet_class_json = YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash).to_json expect(json_output).to include_json(puppet_class_json) + end + + it 'should include data for Puppet Data Types' do + data_types_json = YARD::Registry.all(:puppet_data_type).sort_by!(&:name).map!(&:to_hash).to_json + expect(json_output).to include_json(data_types_json) end it 'should include data for Puppet Defined Types' do defined_types_json = YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash).to_json