spec/unit/puppet-strings/json_spec.rb in puppet-strings-1.2.1 vs spec/unit/puppet-strings/json_spec.rb in puppet-strings-2.0.0
- old
+ new
@@ -19,10 +19,19 @@
# @param param3 Third param.
define dt(Integer $param1, $param2, String $param3 = hi) {
}
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
+
# 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.
@@ -30,10 +39,35 @@
# @return [Undef] Returns nothing.
function func(Integer $param1, $param2, String $param3 = hi) {
}
SOURCE
+ YARD::Parser::SourceParser.parse_string(<<-SOURCE, :json)
+{
+ "description": "Allows you to backup your database to local file.",
+ "input_method": "stdin",
+ "parameters": {
+ "database": {
+ "description": "Database to connect to",
+ "type": "Optional[String[1]]"
+ },
+ "user": {
+ "description": "The user",
+ "type": "Optional[String[1]]"
+ },
+ "password": {
+ "description": "The password",
+ "type": "Optional[String[1]]"
+ },
+ "sql": {
+ "description": "Path to file you want backup to",
+ "type": "String[1]"
+ }
+ }
+}
+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.
@param second The second parameter.
@@ -124,11 +158,11 @@
end
end
Puppet::ResourceApi.register_type(
name: 'apt_key',
- desc: <<-EOS,
+ docs: <<-EOS,
@summary Example resource type using the new API.
@raise SomeError
This type provides Puppet with the capabilities to manage GPG keys needed
by apt to perform package validation. Apt has it's own GPG keyring that can
be manipulated through the `apt-key` command.
@@ -164,10 +198,16 @@
},
)
SOURCE
end
- let(:filename) { TEST_PUPPET_FUNCTIONS ? 'output.json' : 'output_without_puppet_function.json' }
+ let(:filename) do
+ if TEST_PUPPET_PLANS
+ 'output_with_plan.json'
+ else
+ TEST_PUPPET_FUNCTIONS ? 'output.json' : 'output_without_puppet_function.json'
+ end
+ end
let(:baseline_path) { File.join(File.dirname(__FILE__), "../../fixtures/unit/json/#{filename}") }
let(:baseline) { File.read(baseline_path) }
describe 'rendering JSON to a file' do
it 'should output the expected JSON content' do