frodata 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +2 -0
- data/.gitignore +24 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +75 -0
- data/CHANGELOG.md +150 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +427 -0
- data/Rakefile +7 -0
- data/TODO.md +55 -0
- data/frodata.gemspec +34 -0
- data/lib/frodata.rb +36 -0
- data/lib/frodata/entity.rb +332 -0
- data/lib/frodata/entity_container.rb +75 -0
- data/lib/frodata/entity_set.rb +161 -0
- data/lib/frodata/errors.rb +68 -0
- data/lib/frodata/navigation_property.rb +29 -0
- data/lib/frodata/navigation_property/proxy.rb +80 -0
- data/lib/frodata/properties.rb +32 -0
- data/lib/frodata/properties/binary.rb +50 -0
- data/lib/frodata/properties/boolean.rb +37 -0
- data/lib/frodata/properties/collection.rb +50 -0
- data/lib/frodata/properties/complex.rb +114 -0
- data/lib/frodata/properties/date.rb +27 -0
- data/lib/frodata/properties/date_time.rb +83 -0
- data/lib/frodata/properties/date_time_offset.rb +17 -0
- data/lib/frodata/properties/decimal.rb +50 -0
- data/lib/frodata/properties/enum.rb +62 -0
- data/lib/frodata/properties/float.rb +67 -0
- data/lib/frodata/properties/geography.rb +13 -0
- data/lib/frodata/properties/geography/base.rb +162 -0
- data/lib/frodata/properties/geography/line_string.rb +33 -0
- data/lib/frodata/properties/geography/point.rb +31 -0
- data/lib/frodata/properties/geography/polygon.rb +38 -0
- data/lib/frodata/properties/guid.rb +17 -0
- data/lib/frodata/properties/integer.rb +107 -0
- data/lib/frodata/properties/number.rb +14 -0
- data/lib/frodata/properties/string.rb +72 -0
- data/lib/frodata/properties/time.rb +40 -0
- data/lib/frodata/properties/time_of_day.rb +27 -0
- data/lib/frodata/property.rb +139 -0
- data/lib/frodata/property_registry.rb +41 -0
- data/lib/frodata/query.rb +233 -0
- data/lib/frodata/query/criteria.rb +92 -0
- data/lib/frodata/query/criteria/comparison_operators.rb +49 -0
- data/lib/frodata/query/criteria/date_functions.rb +61 -0
- data/lib/frodata/query/criteria/geography_functions.rb +21 -0
- data/lib/frodata/query/criteria/lambda_operators.rb +27 -0
- data/lib/frodata/query/criteria/string_functions.rb +40 -0
- data/lib/frodata/query/in_batches.rb +58 -0
- data/lib/frodata/railtie.rb +19 -0
- data/lib/frodata/schema.rb +155 -0
- data/lib/frodata/schema/complex_type.rb +79 -0
- data/lib/frodata/schema/enum_type.rb +95 -0
- data/lib/frodata/service.rb +254 -0
- data/lib/frodata/service/request.rb +85 -0
- data/lib/frodata/service/response.rb +162 -0
- data/lib/frodata/service/response/atom.rb +40 -0
- data/lib/frodata/service/response/json.rb +41 -0
- data/lib/frodata/service/response/plain.rb +36 -0
- data/lib/frodata/service/response/xml.rb +40 -0
- data/lib/frodata/service_registry.rb +52 -0
- data/lib/frodata/version.rb +3 -0
- data/spec/fixtures/files/entity_to_xml.xml +17 -0
- data/spec/fixtures/files/error.xml +5 -0
- data/spec/fixtures/files/metadata.xml +150 -0
- data/spec/fixtures/files/product_0.json +10 -0
- data/spec/fixtures/files/product_0.xml +28 -0
- data/spec/fixtures/files/products.json +106 -0
- data/spec/fixtures/files/products.xml +308 -0
- data/spec/fixtures/files/supplier_0.json +26 -0
- data/spec/fixtures/files/supplier_0.xml +32 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs.yml +1635 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs/bad_entry.yml +183 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs/existing_entry.yml +256 -0
- data/spec/fixtures/vcr_cassettes/entity_set_specs/new_entry.yml +185 -0
- data/spec/fixtures/vcr_cassettes/entity_specs.yml +285 -0
- data/spec/fixtures/vcr_cassettes/navigation_property_proxy_specs.yml +346 -0
- data/spec/fixtures/vcr_cassettes/query/result_specs.yml +189 -0
- data/spec/fixtures/vcr_cassettes/query_specs.yml +1060 -0
- data/spec/fixtures/vcr_cassettes/schema/complex_type_specs.yml +127 -0
- data/spec/fixtures/vcr_cassettes/service/request_specs.yml +193 -0
- data/spec/fixtures/vcr_cassettes/service_registry_specs.yml +129 -0
- data/spec/fixtures/vcr_cassettes/service_specs.yml +127 -0
- data/spec/fixtures/vcr_cassettes/usage_example_specs.yml +1330 -0
- data/spec/frodata/entity/shared_examples.rb +82 -0
- data/spec/frodata/entity_container_spec.rb +38 -0
- data/spec/frodata/entity_set_spec.rb +168 -0
- data/spec/frodata/entity_spec.rb +151 -0
- data/spec/frodata/errors_spec.rb +48 -0
- data/spec/frodata/navigation_property/proxy_spec.rb +44 -0
- data/spec/frodata/navigation_property_spec.rb +55 -0
- data/spec/frodata/properties/binary_spec.rb +50 -0
- data/spec/frodata/properties/boolean_spec.rb +72 -0
- data/spec/frodata/properties/collection_spec.rb +44 -0
- data/spec/frodata/properties/date_spec.rb +23 -0
- data/spec/frodata/properties/date_time_offset_spec.rb +30 -0
- data/spec/frodata/properties/date_time_spec.rb +23 -0
- data/spec/frodata/properties/decimal_spec.rb +51 -0
- data/spec/frodata/properties/float_spec.rb +45 -0
- data/spec/frodata/properties/geography/line_string_spec.rb +33 -0
- data/spec/frodata/properties/geography/point_spec.rb +29 -0
- data/spec/frodata/properties/geography/polygon_spec.rb +55 -0
- data/spec/frodata/properties/geography/shared_examples.rb +72 -0
- data/spec/frodata/properties/guid_spec.rb +17 -0
- data/spec/frodata/properties/integer_spec.rb +58 -0
- data/spec/frodata/properties/string_spec.rb +46 -0
- data/spec/frodata/properties/time_of_day_spec.rb +23 -0
- data/spec/frodata/properties/time_spec.rb +15 -0
- data/spec/frodata/property_registry_spec.rb +16 -0
- data/spec/frodata/property_spec.rb +71 -0
- data/spec/frodata/query/criteria_spec.rb +229 -0
- data/spec/frodata/query_spec.rb +199 -0
- data/spec/frodata/schema/complex_type_spec.rb +96 -0
- data/spec/frodata/schema/enum_type_spec.rb +112 -0
- data/spec/frodata/schema_spec.rb +97 -0
- data/spec/frodata/service/request_spec.rb +49 -0
- data/spec/frodata/service/response_spec.rb +85 -0
- data/spec/frodata/service_registry_spec.rb +18 -0
- data/spec/frodata/service_spec.rb +191 -0
- data/spec/frodata/usage_example_spec.rb +188 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/coverage.rb +2 -0
- data/spec/support/vcr.rb +9 -0
- metadata +401 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative 'shared_examples'
|
3
|
+
|
4
|
+
describe FrOData::Properties::Geography::LineString do
|
5
|
+
let(:klass) { FrOData::Properties::Geography::LineString }
|
6
|
+
let(:property_name) { 'Boundary' }
|
7
|
+
let(:srid) { 4326 }
|
8
|
+
let(:coordinates) { [[100.0, 0.0], [101.0, 1.0]] }
|
9
|
+
let(:property_as_text) { "geography'SRID=4326;LineString(100.0 0.0,101.0 1.0)'" }
|
10
|
+
let(:property_as_json) { {
|
11
|
+
type: 'LineString',
|
12
|
+
coordinates: [
|
13
|
+
[100.0, 0.0],
|
14
|
+
[101.0, 1.0]
|
15
|
+
],
|
16
|
+
crs: {
|
17
|
+
type: 'name',
|
18
|
+
properties: { name: 'EPSG:4326' }
|
19
|
+
}
|
20
|
+
} }
|
21
|
+
let(:property_as_xml) { <<-END }
|
22
|
+
<data:Boundary metadata:type="Edm.GeographyLineString">
|
23
|
+
<gml:LineString gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
|
24
|
+
<gml:pos>100.0 0.0</gml:pos>
|
25
|
+
<gml:pos>101.0 1.0</gml:pos>
|
26
|
+
</gml:LineString>
|
27
|
+
</data:Boundary>
|
28
|
+
END
|
29
|
+
let(:new_value) { [[0.0, 100.0], [1.0, 101.0]] }
|
30
|
+
let(:new_value_as_text) { "geography'SRID=0;LineString(0.0 100.0,1.0 101.0)'" }
|
31
|
+
|
32
|
+
it_behaves_like 'a geographic property', 'Edm.GeographyLineString'
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative 'shared_examples'
|
3
|
+
|
4
|
+
describe FrOData::Properties::Geography::Point do
|
5
|
+
let(:klass) { FrOData::Properties::Geography::Point }
|
6
|
+
let(:property_name) { 'Location' }
|
7
|
+
let(:srid) { 4326 }
|
8
|
+
let(:coordinates) { [ 142.1, 64.1 ]}
|
9
|
+
let(:property_as_text) { "geography'SRID=4326;Point(142.1 64.1)'" }
|
10
|
+
let(:property_as_json) { {
|
11
|
+
type: 'Point',
|
12
|
+
coordinates: [142.1, 64.1],
|
13
|
+
crs: {
|
14
|
+
type: 'name',
|
15
|
+
properties: { name: 'EPSG:4326' }
|
16
|
+
}
|
17
|
+
} }
|
18
|
+
let(:property_as_xml) { <<-END }
|
19
|
+
<data:Location metadata:type="Edm.GeographyPoint">
|
20
|
+
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
|
21
|
+
<gml:pos>142.1 64.1</gml:pos>
|
22
|
+
</gml:Point>
|
23
|
+
</data:Location>
|
24
|
+
END
|
25
|
+
let(:new_value) { [ 100.0, 0.0 ] }
|
26
|
+
let(:new_value_as_text) { "geography'SRID=0;Point(100.0 0.0)'" }
|
27
|
+
|
28
|
+
it_behaves_like 'a geographic property', 'Edm.GeographyPoint'
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative 'shared_examples'
|
3
|
+
|
4
|
+
describe FrOData::Properties::Geography::Polygon do
|
5
|
+
let(:klass) { FrOData::Properties::Geography::Polygon }
|
6
|
+
let(:property_name) { 'Area' }
|
7
|
+
let(:srid) { 4326 }
|
8
|
+
let(:coordinates) { [
|
9
|
+
[100.0, 0.0],
|
10
|
+
[101.0, 0.0],
|
11
|
+
[101.0, 1.0],
|
12
|
+
[100.0, 1.0],
|
13
|
+
[100.0, 0.0]
|
14
|
+
] }
|
15
|
+
let(:property_as_text) { "geography'SRID=4326;Polygon((100.0 0.0,101.0 0.0,101.0 1.0,100.0 1.0,100.0 0.0))'" }
|
16
|
+
let(:property_as_json) { {
|
17
|
+
type: 'Polygon',
|
18
|
+
coordinates: [
|
19
|
+
[100.0, 0.0],
|
20
|
+
[101.0, 0.0],
|
21
|
+
[101.0, 1.0],
|
22
|
+
[100.0, 1.0],
|
23
|
+
[100.0, 0.0]
|
24
|
+
],
|
25
|
+
crs: {
|
26
|
+
type: 'name',
|
27
|
+
properties: { name: 'EPSG:4326' }
|
28
|
+
}
|
29
|
+
} }
|
30
|
+
let(:property_as_xml) { <<-END }
|
31
|
+
<data:Area metadata:type="Edm.GeographyPolygon">
|
32
|
+
<gml:Polygon gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
|
33
|
+
<gml:exterior>
|
34
|
+
<gml:LinearRing>
|
35
|
+
<gml:pos>100.0 0.0</gml:pos>
|
36
|
+
<gml:pos>101.0 0.0</gml:pos>
|
37
|
+
<gml:pos>101.0 1.0</gml:pos>
|
38
|
+
<gml:pos>100.0 1.0</gml:pos>
|
39
|
+
<gml:pos>100.0 0.0</gml:pos>
|
40
|
+
</gml:LinearRing>
|
41
|
+
</gml:exterior>
|
42
|
+
</gml:Polygon>
|
43
|
+
</data:Area>
|
44
|
+
END
|
45
|
+
let(:new_value) { [
|
46
|
+
[200.0, 10.0],
|
47
|
+
[201.0, 10.0],
|
48
|
+
[201.0, 11.0],
|
49
|
+
[200.0, 11.0],
|
50
|
+
[200.0, 10.0]
|
51
|
+
] }
|
52
|
+
let(:new_value_as_text) { "geography'SRID=0;Polygon((200.0 10.0,201.0 10.0,201.0 11.0,200.0 11.0,200.0 10.0))'" }
|
53
|
+
|
54
|
+
it_behaves_like 'a geographic property', 'Edm.GeographyPolygon'
|
55
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
shared_examples 'a geographic property' do |type_name|
|
2
|
+
let(:subject) { klass.new(property_name, coordinates) }
|
3
|
+
|
4
|
+
describe '#type' do
|
5
|
+
it { expect(subject.type).to eq(type_name) }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#srid' do
|
9
|
+
it { expect(subject.srid).to eq(srid) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#value' do
|
13
|
+
it { expect(subject.value).to eq(coordinates) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#value=' do
|
17
|
+
it { expect { subject.value = 'invalid' }.to raise_error(ArgumentError) }
|
18
|
+
|
19
|
+
it {
|
20
|
+
subject.value = new_value_as_text
|
21
|
+
expect(subject.value).to eq(new_value)
|
22
|
+
expect(subject.srid).to eq(0)
|
23
|
+
}
|
24
|
+
|
25
|
+
it {
|
26
|
+
subject.value = new_value
|
27
|
+
expect(subject.value).to eq(new_value)
|
28
|
+
expect(subject.srid).to eq(4326)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#url_value' do
|
33
|
+
it { expect(subject.url_value).to eq(property_as_text) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#json_value' do
|
37
|
+
it 'renders property value as a hash' do
|
38
|
+
expect(subject.json_value).to eq(property_as_json)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#to_xml' do
|
43
|
+
let(:builder) do
|
44
|
+
Nokogiri::XML::Builder.new do |xml|
|
45
|
+
xml.entry(FrOData::Entity::XML_NAMESPACES) do
|
46
|
+
subject.to_xml(xml)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
let(:xml) { Nokogiri::XML(builder.to_xml) }
|
51
|
+
let(:property_xml) { xml.root.element_children.first.to_s }
|
52
|
+
|
53
|
+
it { expect(property_xml).to be_equivalent_to(property_as_xml) }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.from_xml' do
|
57
|
+
let(:subject) { klass.from_xml(property_xml) }
|
58
|
+
let(:xml_doc) do
|
59
|
+
Nokogiri::XML::Builder.new do |xml|
|
60
|
+
xml.entry(FrOData::Entity::XML_NAMESPACES)
|
61
|
+
end.to_xml
|
62
|
+
end
|
63
|
+
let(:property_xml) do
|
64
|
+
document = Nokogiri::XML(xml_doc)
|
65
|
+
document.root << property_as_xml
|
66
|
+
document.remove_namespaces!.root.element_children.first
|
67
|
+
end
|
68
|
+
|
69
|
+
it { expect(subject.value).to eq(coordinates) }
|
70
|
+
it { expect(subject.srid).to eq(srid) }
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::Properties::Guid do
|
4
|
+
let(:guid) { SecureRandom.uuid }
|
5
|
+
let(:guid2) { SecureRandom.uuid }
|
6
|
+
let(:subject) { FrOData::Properties::Guid.new('Stringy', guid) }
|
7
|
+
|
8
|
+
it { expect(subject.type).to eq('Edm.Guid') }
|
9
|
+
it { expect(subject.value).to eq(guid)}
|
10
|
+
|
11
|
+
it { expect(lambda {
|
12
|
+
subject.value = guid2
|
13
|
+
subject.value
|
14
|
+
}.call).to eq(guid2) }
|
15
|
+
|
16
|
+
it { expect(subject.url_value).to eq("guid'#{guid}'") }
|
17
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::Properties::Integer do
|
4
|
+
let(:subject) { FrOData::Properties::Integer.new('Integer', '32') }
|
5
|
+
let(:subject16) { FrOData::Properties::Int16.new('Int16', '32') }
|
6
|
+
let(:subject32) { FrOData::Properties::Int32.new('Int32', '32') }
|
7
|
+
let(:subject64) { FrOData::Properties::Int64.new('Int64', '32') }
|
8
|
+
let(:subjectbyte) { FrOData::Properties::Byte.new('Byte', '32') }
|
9
|
+
let(:subjectsbyte) { FrOData::Properties::SByte.new('SByte', '32') }
|
10
|
+
|
11
|
+
it { expect(subject.type).to eq('Edm.Int64') }
|
12
|
+
it { expect(subject.value).to eq(32) }
|
13
|
+
it { expect {subject.value = (2**63)}.to raise_error(ArgumentError) }
|
14
|
+
it { expect {subject.value = (-(2**63) - 1)}.to raise_error(ArgumentError) }
|
15
|
+
|
16
|
+
it { expect(subject16.type).to eq('Edm.Int16') }
|
17
|
+
it { expect(subject16.value).to eq(32) }
|
18
|
+
it { expect {subject16.value = (2**15)}.to raise_error(ArgumentError) }
|
19
|
+
it { expect {subject16.value = (-(2**15) - 1)}.to raise_error(ArgumentError) }
|
20
|
+
|
21
|
+
it { expect(subject32.type).to eq('Edm.Int32') }
|
22
|
+
it { expect(subject32.value).to eq(32) }
|
23
|
+
it { expect {subject32.value = (2**31)}.to raise_error(ArgumentError) }
|
24
|
+
it { expect {subject32.value = (-(2**31) - 1)}.to raise_error(ArgumentError) }
|
25
|
+
|
26
|
+
it { expect(subject64.type).to eq('Edm.Int64') }
|
27
|
+
it { expect(subject64.value).to eq(32) }
|
28
|
+
it { expect {subject64.value = (2**63)}.to raise_error(ArgumentError) }
|
29
|
+
it { expect {subject64.value = (-(2**63) - 1)}.to raise_error(ArgumentError) }
|
30
|
+
|
31
|
+
it { expect(subjectbyte.type).to eq('Edm.Byte') }
|
32
|
+
it { expect(subjectbyte.value).to eq(32) }
|
33
|
+
it { expect {subjectbyte.value = 2**8}.to raise_error(ArgumentError) }
|
34
|
+
it { expect {subjectbyte.value = -1}.to raise_error(ArgumentError) }
|
35
|
+
|
36
|
+
it { expect(subjectsbyte.type).to eq('Edm.SByte') }
|
37
|
+
it { expect(subjectsbyte.value).to eq(32) }
|
38
|
+
it { expect {subjectsbyte.value = (2**7)}.to raise_error(ArgumentError) }
|
39
|
+
it { expect {subjectsbyte.value = (-(2**7) - 1)}.to raise_error(ArgumentError) }
|
40
|
+
|
41
|
+
describe '#value=' do
|
42
|
+
before(:example) do
|
43
|
+
subject.value = 128
|
44
|
+
subject16.value = 128
|
45
|
+
subject32.value = 128
|
46
|
+
subject64.value = 128
|
47
|
+
subjectbyte.value = 12
|
48
|
+
subjectsbyte.value = 12
|
49
|
+
end
|
50
|
+
|
51
|
+
it { expect(subject.value).to eq(128) }
|
52
|
+
it { expect(subject16.value).to eq(128) }
|
53
|
+
it { expect(subject32.value).to eq(128) }
|
54
|
+
it { expect(subject64.value).to eq(128) }
|
55
|
+
it { expect(subjectbyte.value).to eq(12) }
|
56
|
+
it { expect(subjectsbyte.value).to eq(12) }
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::Properties::String do
|
4
|
+
let(:subject) { FrOData::Properties::String.new('Stringy', 'This is an example') }
|
5
|
+
|
6
|
+
it { expect(subject).to respond_to(:is_unicode?) }
|
7
|
+
it { expect(subject).to respond_to(:has_default_value?) }
|
8
|
+
it { expect(subject).to respond_to(:default_value) }
|
9
|
+
|
10
|
+
it { expect(subject.type).to eq('Edm.String') }
|
11
|
+
it { expect(subject.value).to eq('This is an example')}
|
12
|
+
|
13
|
+
it { expect(lambda {
|
14
|
+
subject.value = 'Another example'
|
15
|
+
subject.value
|
16
|
+
}.call).to eq('Another example') }
|
17
|
+
|
18
|
+
it { expect(lambda {
|
19
|
+
subject.value = nil
|
20
|
+
subject.value
|
21
|
+
}.call).to eq(nil) }
|
22
|
+
|
23
|
+
describe '#is_unicode?' do
|
24
|
+
let(:not_unicode) { FrOData::Properties::String.new('Stringy', 'This is an example', unicode: false) }
|
25
|
+
|
26
|
+
it { expect(subject.is_unicode?).to eq(true) }
|
27
|
+
it { expect(not_unicode.is_unicode?).to eq(false) }
|
28
|
+
|
29
|
+
it { expect(subject.value.encoding).to eq(Encoding::UTF_8) }
|
30
|
+
it { expect(not_unicode.value.encoding).to eq(Encoding::ASCII) }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'when #allows_nil? is false' do
|
34
|
+
let(:subject) { FrOData::Properties::String.new('Stringy', 'This is an example', allows_nil: false) }
|
35
|
+
|
36
|
+
it { expect {subject.value = nil}.to raise_error(ArgumentError) }
|
37
|
+
it { expect {subject.value = 'Test'}.not_to raise_error }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'with default_value' do
|
41
|
+
let(:subject) { FrOData::Properties::String.new('Stringy', nil, default_value: 'Sample Text') }
|
42
|
+
|
43
|
+
it { expect(subject.has_default_value?).to eq(true) }
|
44
|
+
it { expect(subject.default_value).to eq('Sample Text') }
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::Properties::TimeOfDay do
|
4
|
+
let(:subject) { FrOData::Properties::TimeOfDay.new('TimeOfDay', '16:00:00.000') }
|
5
|
+
let(:new_time) { Time.strptime('14:32:00.000', '%H:%M:%S.%L') }
|
6
|
+
|
7
|
+
it { expect(subject.type).to eq('Edm.TimeOfDay') }
|
8
|
+
it { expect(subject.value).to eq(Time.parse('16:00:00.000')) }
|
9
|
+
|
10
|
+
it { expect(subject.url_value).to eq("16:00:00.000")}
|
11
|
+
|
12
|
+
it { expect {subject.value = 'bad'}.to raise_error(ArgumentError) }
|
13
|
+
|
14
|
+
it { expect(lambda {
|
15
|
+
subject.value = '14:32:00.000'
|
16
|
+
subject.value
|
17
|
+
}.call).to eq(new_time) }
|
18
|
+
|
19
|
+
it { expect(lambda {
|
20
|
+
subject.value = new_time
|
21
|
+
subject.value
|
22
|
+
}.call).to eq(new_time) }
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::Properties::Time do
|
4
|
+
let(:subject) { FrOData::Properties::Time.new('Timely', '21:00:00-08:00') }
|
5
|
+
|
6
|
+
it { expect(subject.type).to eq('Edm.Time') }
|
7
|
+
it { expect(subject.value).to eq(Time.strptime('21:00:00-08:00', '%H:%M:%S%:z')) }
|
8
|
+
|
9
|
+
it { expect {subject.value = 'bad'}.to raise_error(ArgumentError) }
|
10
|
+
|
11
|
+
it { expect(lambda {
|
12
|
+
subject.value = Time.strptime('13:22:12+04:00', '%H:%M:%S%:z')
|
13
|
+
subject.value
|
14
|
+
}.call).to eq(Time.strptime('13:22:12+04:00', '%H:%M:%S%:z'))}
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::PropertyRegistry do
|
4
|
+
let(:subject) { FrOData::PropertyRegistry }
|
5
|
+
|
6
|
+
it { expect(subject).to respond_to(:add) }
|
7
|
+
it { expect(subject).to respond_to(:[]) }
|
8
|
+
|
9
|
+
describe '#add' do
|
10
|
+
before(:each) do
|
11
|
+
subject.add('Edm.Guid', FrOData::Properties::Guid)
|
12
|
+
end
|
13
|
+
|
14
|
+
it { expect(subject['Edm.Guid']).to eq(FrOData::Properties::Guid) }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FrOData::Property do
|
4
|
+
let(:service) do
|
5
|
+
FrOData::Service.new('http://services.odata.org/V4/OData/OData.svc', metadata_file: metadata_file)
|
6
|
+
end
|
7
|
+
let(:metadata_file) { 'spec/fixtures/files/metadata.xml' }
|
8
|
+
let(:subject) { FrOData::Property.new('PropertyName', '1') }
|
9
|
+
let(:good_comparison) { FrOData::Property.new('GoodComparison', '1') }
|
10
|
+
let(:bad_comparison) { FrOData::Property.new('BadComparison', '2') }
|
11
|
+
|
12
|
+
describe '#name' do
|
13
|
+
it { expect(subject).to respond_to(:name) }
|
14
|
+
it { expect(subject.name).to eq('PropertyName') }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#value' do
|
18
|
+
it { expect(subject).to respond_to(:value) }
|
19
|
+
it { expect(subject.value).to eq('1') }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#xml_value' do
|
23
|
+
it { expect(subject).to respond_to(:xml_value) }
|
24
|
+
it { expect(subject.xml_value).to eq('1') }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#url_value' do
|
28
|
+
it { expect(subject).to respond_to(:url_value) }
|
29
|
+
it { expect(subject.url_value).to eq('1') }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#type' do
|
33
|
+
it { expect(subject).to respond_to(:type) }
|
34
|
+
it { expect(lambda {subject.type}).to raise_error(NotImplementedError) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#allows_nil?' do
|
38
|
+
it { expect(subject).to respond_to(:allows_nil?) }
|
39
|
+
it { expect(subject.allows_nil?).to eq(true) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#strict?' do
|
43
|
+
it { expect(subject).to respond_to(:strict?) }
|
44
|
+
|
45
|
+
it 'defaults to true' do
|
46
|
+
expect(subject.strict?).to eq(true)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'can be switched off via constructor option' do
|
50
|
+
subject = FrOData::Property.new('PropertyName', '1', strict: false)
|
51
|
+
expect(subject.strict?).to eq(false)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'can be switched off via service level option' do
|
55
|
+
service.options[:strict] = false
|
56
|
+
subject = FrOData::Property.new('PropertyName', '1', service: service)
|
57
|
+
expect(subject.strict?).to eq(false)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#concurrency_mode' do
|
62
|
+
it { expect(subject).to respond_to(:concurrency_mode) }
|
63
|
+
it { expect(subject.concurrency_mode).to eq(:none) }
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#==' do
|
67
|
+
it { expect(subject).to respond_to(:==) }
|
68
|
+
it { expect(subject == good_comparison).to eq(true) }
|
69
|
+
it { expect(subject == bad_comparison).to eq(false) }
|
70
|
+
end
|
71
|
+
end
|