Skip to content

Commit

Permalink
(maint) Refactor XSD validation in acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek authored and scotje committed Jun 26, 2017
1 parent 8461bfb commit d28c11e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions spec/acceptance/support/it_generates_valid_junit_xml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RSpec.shared_examples_for :it_generates_valid_junit_xml do
its(:stdout) do
xsd = File.join(RSpec.configuration.fixtures_path, 'JUnit.xsd')
is_expected.to pass_validation(xsd)
end
end
5 changes: 2 additions & 3 deletions spec/acceptance/validate_metadata_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec_helper_acceptance'

describe 'Running metadata validation' do
let(:junit_xsd) { File.join(RSpec.configuration.fixtures_path, 'JUnit.xsd') }
let(:spinner_text) { %r{checking metadata\.json}i }

context 'with a fresh module' do
Expand All @@ -16,7 +15,7 @@
describe command('pdk validate metadata --format junit') do
its(:exit_status) { is_expected.to eq(0) }
its(:stderr) { is_expected.to match(spinner_text) }
its(:stdout) { is_expected.to pass_validation(junit_xsd) }
it_behaves_like :it_generates_valid_junit_xml

its(:stdout) do
is_expected.to have_xpath('/testsuites/testsuite[@name="metadata-json-lint"]').with_attributes(
Expand Down Expand Up @@ -54,7 +53,7 @@
describe command('pdk validate metadata --format junit') do
its(:exit_status) { is_expected.to eq(1) }
its(:stderr) { is_expected.to match(spinner_text) }
its(:stdout) { is_expected.to pass_validation(junit_xsd) }
it_behaves_like :it_generates_valid_junit_xml

its(:stdout) do
is_expected.to have_xpath('/testsuites/testsuite[@name="metadata-json-lint"]').with_attributes(
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/validate_ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
describe command('pdk validate ruby --format junit') do
its(:exit_status) { is_expected.to eq(0) }
its(:stderr) { is_expected.to match(%r{checking ruby code style}i) }
its(:stdout) { is_expected.to pass_validation(junit_xsd) }
it_behaves_like :it_generates_valid_junit_xml

its(:stdout) do
is_expected.to have_xpath('/testsuites/testsuite[@name="rubocop"]').with_attributes(
Expand Down Expand Up @@ -96,7 +96,7 @@
describe command('pdk validate ruby --format junit') do
its(:exit_status) { is_expected.not_to eq(0) }
its(:stderr) { is_expected.to match(%r{checking ruby code style}i) }
its(:stdout) { is_expected.to pass_validation(junit_xsd) }
it_behaves_like :it_generates_valid_junit_xml

its(:stdout) do
is_expected.to have_xpath('/testsuites/testsuite[@name="rubocop"]').with_attributes(
Expand Down

0 comments on commit d28c11e

Please sign in to comment.