Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-08-03 14:08:13 +0300
committerShinya Maeda <shinya@gitlab.com>2018-08-03 14:08:13 +0300
commit41f28a9ffabf4eb45c53836ea4de3b7a49229eaa (patch)
tree174d41cf6bb28ccc3c88727618886a431364a63c /spec/lib
parent06b8f47cf3b8ce65012fe905f6d3953ff175fa85 (diff)
Add factory for parsers. Add required specification in json schema matcher. Improved test code.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/parsers/junit_spec.rb (renamed from spec/lib/gitlab/ci/parsers/junit_parser_spec.rb)42
1 files changed, 13 insertions, 29 deletions
diff --git a/spec/lib/gitlab/ci/parsers/junit_parser_spec.rb b/spec/lib/gitlab/ci/parsers/junit_spec.rb
index 5459fb96610..f7ec86f5385 100644
--- a/spec/lib/gitlab/ci/parsers/junit_parser_spec.rb
+++ b/spec/lib/gitlab/ci/parsers/junit_spec.rb
@@ -1,39 +1,13 @@
require 'spec_helper'
-describe Gitlab::Ci::Parsers::JunitParser do
- describe '#initialize' do
- context 'when xml data is given' do
- let(:data) do
- <<-EOF.strip_heredoc
- <testsuite></testsuite>
- EOF
- end
-
- let(:parser) { described_class.new(data) }
-
- it 'initialize Hash from the given data' do
- expect { parser }.not_to raise_error
-
- expect(parser.data).to be_a(Hash)
- end
- end
-
- context 'when json data is given' do
- let(:data) { { testsuite: 'abc' }.to_json }
-
- it 'raises an error' do
- expect { described_class.new(data) }.to raise_error(described_class::JunitParserError)
- end
- end
- end
-
+describe Gitlab::Ci::Parsers::Junit do
describe '#parse!' do
- subject { described_class.new(junit).parse!(test_suite) }
+ subject { described_class.new.parse!(junit, test_suite) }
let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new('rspec') }
let(:test_cases) { flattened_test_cases(test_suite) }
- context 'when XML is formated as JUnit' do
+ context 'when data is JUnit style XML' do
context 'when there are no test cases' do
let(:junit) do
<<-EOF.strip_heredoc
@@ -123,6 +97,16 @@ describe Gitlab::Ci::Parsers::JunitParser do
end
end
+ context 'when data is not JUnit style XML' do
+ let(:junit) { { testsuite: 'abc' }.to_json }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(described_class::JunitParserError)
+ end
+ end
+
+ private
+
def flattened_test_cases(test_suite)
test_suite.test_cases.map do |status, value|
value.map do |key, test_case|