From 2a5d23f82bb55be43d99c8bd52590bdf40c73e97 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Fri, 2 Mar 2018 11:02:36 -0800 Subject: [PATCH 1/2] (PDOC-223) prepare travis for dropping old version support This gets rid of test cells for old versions of ruby (< 2.1.9) and old versions of puppet (< 4) and also updates the test command to run all 100+ unit tests instead of a whopping 27 that rake spec runs --- .travis.yml | 10 +++------- .../yard/handlers/puppet/class_handler_spec.rb | 2 +- .../yard/handlers/puppet/defined_type_handler_spec.rb | 2 +- .../puppet-strings/yard/parsers/puppet/parser_spec.rb | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd49020a3..5a4ed7d3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,17 +14,13 @@ before_install: matrix: fast_finish: true include: - - rvm: 1.9.3 - env: PUPPET_GEM_VERSION="~> 3" CHECK=spec - - rvm: 2.0.0 - env: PUPPET_GEM_VERSION="~> 3" CHECK=spec - - rvm: 2.1.9 - env: PUPPET_GEM_VERSION="~> 3" CHECK=spec - rvm: 2.1.9 env: PUPPET_GEM_VERSION="~> 4" CHECK=spec + - rvm: 2.4.1 + env: PUPPET_GEM_VERSION="~> 4" CHECK=spec - rvm: 2.4.1 env: PUPPET_GEM_VERSION="~> 5" CHECK=spec - rvm: 2.1.9 env: PUPPET_GEM_VERSION="~> 4" CHECK=rubocop -script: 'SPEC_OPTS="--format documentation" COVERAGE="yes" bundle exec rake $CHECK' +script: 'SPEC_OPTS="--format documentation" COVERAGE="yes" bundle exec rspec spec/unit/puppet-strings/*/*' diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index 597fb833f..6e62717ef 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -19,7 +19,7 @@ let(:source) { 'class foo{' } it 'should log an error' do - expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of file/).to_stdout_from_any_process + expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of input/).to_stdout_from_any_process expect(subject.empty?).to eq(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb index 24035f2a2..bc63a2acf 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb @@ -19,7 +19,7 @@ let(:source) { 'define foo{' } it 'should log an error' do - expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of file/).to_stdout_from_any_process + expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of input/).to_stdout_from_any_process expect(subject.empty?).to eq(true) end end diff --git a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb index c59ec2883..b5f27bcdc 100644 --- a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb @@ -29,7 +29,7 @@ class foo { } it 'should raise an exception' do - expect{ subject.parse }.to output(/\[error\]: Failed to parse test.pp: Syntax error at end of file/).to_stdout_from_any_process + expect{ subject.parse }.to output(/\[error\]: Failed to parse test.pp: Syntax error at end of input/).to_stdout_from_any_process end end From be444fa6adc3bb899b620216c5e018ffea11b844 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Mon, 19 Mar 2018 15:52:45 -0700 Subject: [PATCH 2/2] (PDOC-223) revert rsapi changes and remove markdown test First, there were some rspec problems we originally connected to directory naming (e.g. 'yard'), but now we think it's a possible bug in rspec (https://github.com/rspec/rspec-core/issues/2184). this removes the markdown_spec.rb test that was both triggering the bug and, as it turns out, is an unnecessary test. Reverted some of the changes made to the rsapi handler during markdown output work. Those changes were made because of a typo in the spec tests, so the typo has been fixed and most of the handler returned to its original state. --- .travis.yml | 2 +- .../yard/handlers/ruby/rsapi_handler.rb | 2 +- spec/unit/puppet-strings/json_spec.rb | 2 +- spec/unit/puppet-strings/markdown_spec.rb | 8 +------- .../yard/handlers/puppet/class_handler_spec.rb | 2 +- .../handlers/puppet/defined_type_handler_spec.rb | 2 +- .../yard/handlers/ruby/rsapi_handler_spec.rb | 14 +++++++------- .../yard/parsers/puppet/parser_spec.rb | 2 +- 8 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a4ed7d3f..7fa768ac1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,4 @@ matrix: - rvm: 2.1.9 env: PUPPET_GEM_VERSION="~> 4" CHECK=rubocop -script: 'SPEC_OPTS="--format documentation" COVERAGE="yes" bundle exec rspec spec/unit/puppet-strings/*/*' +script: 'SPEC_OPTS="--format documentation" COVERAGE="yes" bundle exec rake $CHECK' diff --git a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb index 80f898928..19b6e60d5 100644 --- a/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +++ b/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb @@ -24,7 +24,7 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H object = PuppetStrings::Yard::CodeObjects::Type.new(schema['name']) register object - docstring = schema['desc'] || "" + docstring = schema['docs'] if docstring register_docstring(object, PuppetStrings::Yard::Util.scrub_string(docstring.to_s), nil) else diff --git a/spec/unit/puppet-strings/json_spec.rb b/spec/unit/puppet-strings/json_spec.rb index c81adf803..86cd4fb45 100644 --- a/spec/unit/puppet-strings/json_spec.rb +++ b/spec/unit/puppet-strings/json_spec.rb @@ -126,7 +126,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar { 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 diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index 8c0c052bc..30b01b428 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -187,7 +187,7 @@ class noparams () {} 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 @@ -239,10 +239,4 @@ class noparams () {} end end end - - describe 'rendering markdown to stdout' do - it 'should output the expected markdown content' do - expect{ PuppetStrings::Markdown.render }.to output(baseline).to_stdout - end - end end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb index 6e62717ef..6dac537cb 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb @@ -19,7 +19,7 @@ let(:source) { 'class foo{' } it 'should log an error' do - expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of input/).to_stdout_from_any_process + expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)/).to_stdout_from_any_process expect(subject.empty?).to eq(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb index bc63a2acf..0f89e28d8 100644 --- a/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb @@ -19,7 +19,7 @@ let(:source) { 'define foo{' } it 'should log an error' do - expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of input/).to_stdout_from_any_process + expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of (file|input)/).to_stdout_from_any_process expect(subject.empty?).to eq(true) end end diff --git a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb index 1e65a2614..983558ba0 100644 --- a/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +++ b/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb @@ -133,19 +133,19 @@ expect(object.properties[1].docstring).to eq('What state the database should be in.') expect(object.properties[1].isnamevar).to eq(false) expect(object.properties[1].default).to eq('up') - expect(object.properties[1].values).to eq(['Enum[present, absent, up, down]']) + expect(object.properties[1].data_type).to eq('Enum[present, absent, up, down]') expect(object.properties[1].aliases).to eq({}) expect(object.properties[2].name).to eq('file') expect(object.properties[2].docstring).to eq('The database file to use.') expect(object.properties[2].isnamevar).to eq(false) expect(object.properties[2].default).to be_nil - expect(object.properties[2].values).to eq(['String']) + expect(object.properties[2].data_type).to eq('String') expect(object.properties[2].aliases).to eq({}) expect(object.properties[3].name).to eq('log_level') expect(object.properties[3].docstring).to eq('The log level to use.') expect(object.properties[3].isnamevar).to eq(false) expect(object.properties[3].default).to eq('warn') - expect(object.properties[3].values).to eq(['Enum[debug, warn, error]']) + expect(object.properties[3].data_type).to eq('Enum[debug, warn, error]') expect(object.properties[3].aliases).to eq({}) expect(object.parameters.size).to eq(5) expect(object.parameters[0].name).to eq('dynamic_param') @@ -156,25 +156,25 @@ expect(object.parameters[1].docstring).to eq('The database server name.') expect(object.parameters[1].isnamevar).to eq(true) expect(object.parameters[1].default).to be_nil - expect(object.parameters[1].values).to eq(['String']) + expect(object.parameters[1].data_type).to eq('String') expect(object.parameters[1].aliases).to eq({}) expect(object.parameters[2].name).to eq('encrypt') expect(object.parameters[2].docstring).to eq('Whether or not to encrypt the database.') expect(object.parameters[2].isnamevar).to eq(false) expect(object.parameters[2].default).to eq(false) - expect(object.parameters[2].values).to eq(["Boolean"]) + expect(object.parameters[2].data_type).to eq("Boolean") expect(object.parameters[2].aliases).to eq({}) expect(object.parameters[3].name).to eq('encryption_key') expect(object.parameters[3].docstring).to eq('The encryption key to use.') expect(object.parameters[3].isnamevar).to eq(false) expect(object.parameters[3].default).to be_nil - expect(object.parameters[3].values).to eq(["Optional[String]"]) + expect(object.parameters[3].data_type).to eq("Optional[String]") expect(object.parameters[3].aliases).to eq({}) expect(object.parameters[4].name).to eq('backup') expect(object.parameters[4].docstring).to eq('How often to backup the database.') expect(object.parameters[4].isnamevar).to eq(false) expect(object.parameters[4].default).to eq('never') - expect(object.parameters[4].values).to eq(["Enum[daily, monthly, never]"]) + expect(object.parameters[4].data_type).to eq("Enum[daily, monthly, never]") end end diff --git a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb index b5f27bcdc..f0ddb0152 100644 --- a/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +++ b/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb @@ -29,7 +29,7 @@ class foo { } it 'should raise an exception' do - expect{ subject.parse }.to output(/\[error\]: Failed to parse test.pp: Syntax error at end of input/).to_stdout_from_any_process + expect{ subject.parse }.to output(/\[error\]: Failed to parse test.pp: Syntax error at end of (file|input)/).to_stdout_from_any_process end end