Skip to content

Commit 4f6a09f

Browse files
committed
Mark PartContract#elements as @api private
Also migrated tests that accessed raw Element objects to use the public paths API instead.
1 parent d6dc81c commit 4f6a09f

3 files changed

Lines changed: 25 additions & 25 deletions

File tree

lib/wsdl/contract/part_contract.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ def initialize(elements, section:)
1414

1515
# Returns the frozen collection of elements for this part.
1616
#
17-
# The array itself is frozen; individual elements should be treated as
18-
# read-only introspection objects.
19-
#
17+
# @api private
2018
# @return [Array<WSDL::XML::Element>]
2119
attr_reader :elements
2220

spec/acceptance/schema_patterns_spec.rb

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,24 @@ def roundtrip(operation, hash)
8888
let(:operation) { client.operation(:GetEvent) }
8989

9090
it 'sets list flag and itemType on list-derived attributes' do
91-
elements = operation.contract.response.body.elements
92-
tags = elements.first.attributes.find { |a| a.name == 'tags' }
93-
scores = elements.first.attributes.find { |a| a.name == 'scores' }
94-
95-
expect(tags.list?).to be true
96-
expect(tags.base_type).to eq 'xsd:string'
97-
expect(scores.list?).to be true
98-
expect(scores.base_type).to eq 'xsd:int'
91+
paths = operation.contract.response.body.paths
92+
root = paths.find { |p| p[:path].size == 1 }
93+
tags = root[:attributes].find { |a| a[:name] == 'tags' }
94+
scores = root[:attributes].find { |a| a[:name] == 'scores' }
95+
96+
expect(tags[:list]).to be true
97+
expect(tags[:type]).to eq 'xsd:string'
98+
expect(scores[:list]).to be true
99+
expect(scores[:type]).to eq 'xsd:int'
99100
end
100101

101102
it 'uses first memberType for union-derived attributes' do
102-
elements = operation.contract.response.body.elements
103-
code = elements.first.attributes.find { |a| a.name == 'code' }
103+
paths = operation.contract.response.body.paths
104+
root = paths.find { |p| p[:path].size == 1 }
105+
code = root[:attributes].find { |a| a[:name] == 'code' }
104106

105-
expect(code.list?).to be false
106-
expect(code.base_type).to eq 'xsd:string'
107+
expect(code[:list]).to be false
108+
expect(code[:type]).to eq 'xsd:string'
107109
end
108110

109111
it 'round-trips list attributes with whitespace splitting and type coercion' do
@@ -167,10 +169,10 @@ def roundtrip(operation, hash)
167169
let(:operation) { client.operation(:GetMeasurement) }
168170

169171
it 'uses first member type as base_type' do
170-
elements = operation.contract.response.body.elements
171-
value_el = elements.first.children.find { |c| c.name == 'value' }
172+
paths = operation.contract.response.body.paths
173+
value = paths.find { |p| p[:path].last == 'value' }
172174

173-
expect(value_el.base_type).to eq 'xsd:string'
175+
expect(value[:type]).to eq 'xsd:string'
174176
end
175177

176178
it 'round-trips response data' do
@@ -188,11 +190,11 @@ def roundtrip(operation, hash)
188190
let(:operation) { client.operation(:GetTags) }
189191

190192
it 'marks list elements with list flag' do
191-
elements = operation.contract.response.body.elements
192-
tags = elements.first.children.find { |c| c.name == 'tags' }
193+
paths = operation.contract.response.body.paths
194+
tags = paths.find { |p| p[:path].last == 'tags' }
193195

194-
expect(tags.list?).to be true
195-
expect(tags.base_type).to eq 'xsd:string'
196+
expect(tags[:list]).to be true
197+
expect(tags[:type]).to eq 'xsd:string'
196198
end
197199

198200
it 'round-trips string list values' do

spec/wsdl/client_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ def initialize(cache_key)
498498
client = described_class.new(f.path)
499499
operation = client.operation('S', 'P', 'Op')
500500

501-
expect(operation.contract.response.body.elements).to eq([])
502-
expect(operation.contract.response.header.elements).to eq([])
503-
expect(operation.contract.request.body.elements).not_to be_empty
501+
expect(operation.contract.response.body.paths).to eq([])
502+
expect(operation.contract.response.header.paths).to eq([])
503+
expect(operation.contract.request.body.paths).not_to be_empty
504504
expect(operation.output_style).to be_nil
505505
end
506506
end

0 commit comments

Comments
 (0)