-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from rodjek/sdk-256
(SDK-256) Acceptance tests for metadata validator behavior and output
- Loading branch information
Showing
4 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'Running metadata validation' do | ||
let(:spinner_text) { %r{checking metadata\.json}i } | ||
|
||
context 'with a fresh module' do | ||
include_context 'in a new module', 'foo' | ||
|
||
describe command('pdk validate metadata') do | ||
its(:exit_status) { is_expected.to eq(0) } | ||
its(:stdout) { is_expected.to match(%r{\A\Z}) } | ||
its(:stderr) { is_expected.to match(spinner_text) } | ||
end | ||
|
||
describe command('pdk validate metadata --format junit') do | ||
its(:exit_status) { is_expected.to eq(0) } | ||
its(:stderr) { is_expected.to match(spinner_text) } | ||
it_behaves_like :it_generates_valid_junit_xml | ||
|
||
its(:stdout) do | ||
is_expected.to have_xpath('/testsuites/testsuite[@name="metadata-json-lint"]').with_attributes( | ||
'failures' => '0', | ||
'tests' => '1', | ||
) | ||
end | ||
|
||
its(:stdout) do | ||
is_expected.to have_xpath('/testsuites/testsuite[@name="metadata-json-lint"]/testcase').with_attributes( | ||
'classname' => 'metadata-json-lint', | ||
'name' => 'metadata.json', | ||
) | ||
end | ||
end | ||
end | ||
|
||
context 'with a metadata violation' do | ||
include_context 'in a new module', 'foo' | ||
|
||
before(:all) do | ||
metadata = JSON.parse(File.read('metadata.json')) | ||
metadata['dependencies'].first['version_requirement'] = '>= 1.0.0' | ||
File.open('metadata.json', 'w') do |f| | ||
f.puts metadata.to_json | ||
end | ||
end | ||
|
||
describe command('pdk validate metadata') do | ||
its(:exit_status) { is_expected.not_to eq(0) } | ||
its(:stdout) { is_expected.to match(%r{^metadata\.json:.+warning.+open ended dependency}) } | ||
its(:stderr) { is_expected.to match(spinner_text) } | ||
end | ||
|
||
describe command('pdk validate metadata --format junit') do | ||
its(:exit_status) { is_expected.not_to eq(0) } | ||
its(:stderr) { is_expected.to match(spinner_text) } | ||
it_behaves_like :it_generates_valid_junit_xml | ||
|
||
its(:stdout) do | ||
is_expected.to have_xpath('/testsuites/testsuite[@name="metadata-json-lint"]').with_attributes( | ||
'failures' => '1', | ||
'tests' => '1', | ||
) | ||
end | ||
|
||
its(:stdout) do | ||
is_expected.to have_xpath('/testsuites/testsuite[@name="metadata-json-lint"]/testcase').with_attributes( | ||
'classname' => 'metadata-json-lint.dependencies', | ||
'name' => 'metadata.json', | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters