odata4 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +2 -0
  3. data/.gitignore +24 -0
  4. data/.rspec +2 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +75 -0
  8. data/CHANGELOG.md +120 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.txt +23 -0
  11. data/README.md +287 -0
  12. data/Rakefile +7 -0
  13. data/TODO.md +55 -0
  14. data/lib/odata4.rb +37 -0
  15. data/lib/odata4/complex_type.rb +76 -0
  16. data/lib/odata4/complex_type/property.rb +114 -0
  17. data/lib/odata4/entity.rb +319 -0
  18. data/lib/odata4/entity_set.rb +162 -0
  19. data/lib/odata4/enum_type.rb +95 -0
  20. data/lib/odata4/enum_type/property.rb +62 -0
  21. data/lib/odata4/navigation_property.rb +29 -0
  22. data/lib/odata4/navigation_property/proxy.rb +76 -0
  23. data/lib/odata4/properties.rb +25 -0
  24. data/lib/odata4/properties/binary.rb +50 -0
  25. data/lib/odata4/properties/boolean.rb +37 -0
  26. data/lib/odata4/properties/date.rb +27 -0
  27. data/lib/odata4/properties/date_time.rb +83 -0
  28. data/lib/odata4/properties/date_time_offset.rb +17 -0
  29. data/lib/odata4/properties/decimal.rb +50 -0
  30. data/lib/odata4/properties/float.rb +67 -0
  31. data/lib/odata4/properties/geography.rb +13 -0
  32. data/lib/odata4/properties/geography/base.rb +162 -0
  33. data/lib/odata4/properties/geography/line_string.rb +33 -0
  34. data/lib/odata4/properties/geography/point.rb +31 -0
  35. data/lib/odata4/properties/geography/polygon.rb +38 -0
  36. data/lib/odata4/properties/guid.rb +17 -0
  37. data/lib/odata4/properties/integer.rb +107 -0
  38. data/lib/odata4/properties/number.rb +14 -0
  39. data/lib/odata4/properties/string.rb +72 -0
  40. data/lib/odata4/properties/time.rb +40 -0
  41. data/lib/odata4/properties/time_of_day.rb +27 -0
  42. data/lib/odata4/property.rb +118 -0
  43. data/lib/odata4/property_registry.rb +41 -0
  44. data/lib/odata4/query.rb +231 -0
  45. data/lib/odata4/query/criteria.rb +92 -0
  46. data/lib/odata4/query/criteria/comparison_operators.rb +49 -0
  47. data/lib/odata4/query/criteria/date_functions.rb +61 -0
  48. data/lib/odata4/query/criteria/geography_functions.rb +21 -0
  49. data/lib/odata4/query/criteria/lambda_operators.rb +27 -0
  50. data/lib/odata4/query/criteria/string_functions.rb +40 -0
  51. data/lib/odata4/query/in_batches.rb +58 -0
  52. data/lib/odata4/query/result.rb +84 -0
  53. data/lib/odata4/query/result/atom.rb +41 -0
  54. data/lib/odata4/query/result/json.rb +42 -0
  55. data/lib/odata4/railtie.rb +19 -0
  56. data/lib/odata4/service.rb +344 -0
  57. data/lib/odata4/service_registry.rb +52 -0
  58. data/lib/odata4/version.rb +3 -0
  59. data/odata4.gemspec +34 -0
  60. data/spec/fixtures/files/entity_to_xml.xml +17 -0
  61. data/spec/fixtures/files/metadata.xml +150 -0
  62. data/spec/fixtures/files/product_0.json +10 -0
  63. data/spec/fixtures/files/product_0.xml +28 -0
  64. data/spec/fixtures/files/products.json +106 -0
  65. data/spec/fixtures/files/products.xml +308 -0
  66. data/spec/fixtures/files/supplier_0.json +26 -0
  67. data/spec/fixtures/files/supplier_0.xml +32 -0
  68. data/spec/fixtures/vcr_cassettes/complex_type_specs.yml +127 -0
  69. data/spec/fixtures/vcr_cassettes/entity_set_specs.yml +1348 -0
  70. data/spec/fixtures/vcr_cassettes/entity_set_specs/bad_entry.yml +183 -0
  71. data/spec/fixtures/vcr_cassettes/entity_set_specs/existing_entry.yml +256 -0
  72. data/spec/fixtures/vcr_cassettes/entity_set_specs/new_entry.yml +185 -0
  73. data/spec/fixtures/vcr_cassettes/entity_specs.yml +285 -0
  74. data/spec/fixtures/vcr_cassettes/navigation_property_proxy_specs.yml +346 -0
  75. data/spec/fixtures/vcr_cassettes/query/result_specs.yml +189 -0
  76. data/spec/fixtures/vcr_cassettes/query_specs.yml +663 -0
  77. data/spec/fixtures/vcr_cassettes/service_registry_specs.yml +129 -0
  78. data/spec/fixtures/vcr_cassettes/service_specs.yml +127 -0
  79. data/spec/fixtures/vcr_cassettes/usage_example_specs.yml +749 -0
  80. data/spec/odata4/complex_type_spec.rb +116 -0
  81. data/spec/odata4/entity/shared_examples.rb +82 -0
  82. data/spec/odata4/entity_set_spec.rb +168 -0
  83. data/spec/odata4/entity_spec.rb +151 -0
  84. data/spec/odata4/enum_type_spec.rb +134 -0
  85. data/spec/odata4/navigation_property/proxy_spec.rb +44 -0
  86. data/spec/odata4/navigation_property_spec.rb +55 -0
  87. data/spec/odata4/properties/binary_spec.rb +50 -0
  88. data/spec/odata4/properties/boolean_spec.rb +72 -0
  89. data/spec/odata4/properties/date_spec.rb +23 -0
  90. data/spec/odata4/properties/date_time_offset_spec.rb +30 -0
  91. data/spec/odata4/properties/date_time_spec.rb +23 -0
  92. data/spec/odata4/properties/decimal_spec.rb +24 -0
  93. data/spec/odata4/properties/float_spec.rb +45 -0
  94. data/spec/odata4/properties/geography/line_string_spec.rb +33 -0
  95. data/spec/odata4/properties/geography/point_spec.rb +29 -0
  96. data/spec/odata4/properties/geography/polygon_spec.rb +55 -0
  97. data/spec/odata4/properties/geography/shared_examples.rb +72 -0
  98. data/spec/odata4/properties/guid_spec.rb +17 -0
  99. data/spec/odata4/properties/integer_spec.rb +58 -0
  100. data/spec/odata4/properties/string_spec.rb +46 -0
  101. data/spec/odata4/properties/time_of_day_spec.rb +23 -0
  102. data/spec/odata4/properties/time_spec.rb +15 -0
  103. data/spec/odata4/property_registry_spec.rb +16 -0
  104. data/spec/odata4/property_spec.rb +32 -0
  105. data/spec/odata4/query/criteria_spec.rb +229 -0
  106. data/spec/odata4/query/result_spec.rb +53 -0
  107. data/spec/odata4/query_spec.rb +196 -0
  108. data/spec/odata4/service_registry_spec.rb +18 -0
  109. data/spec/odata4/service_spec.rb +80 -0
  110. data/spec/odata4/usage_example_spec.rb +176 -0
  111. data/spec/spec_helper.rb +32 -0
  112. data/spec/support/coverage.rb +2 -0
  113. data/spec/support/vcr.rb +9 -0
  114. metadata +380 -0
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::Float do
4
+ describe 'double precision' do
5
+ let(:subject) { OData4::Properties::Double.new('Float', '678.90325') }
6
+
7
+ it { expect(subject.type).to eq('Edm.Double') }
8
+ it { expect(subject.value).to eq(678.90325) }
9
+
10
+ it { expect { subject.value = (1.7 * (10**308) * 2) }.to raise_error(ArgumentError) }
11
+ it { expect { subject.value = (-1.7 * (10**308) * 2) }.to raise_error(ArgumentError) }
12
+
13
+ it { expect(lambda {
14
+ subject.value = '19.89043256'
15
+ subject.value
16
+ }.call).to eq(19.89043256) }
17
+
18
+ it { expect(lambda {
19
+ subject.value = 19.89043256
20
+ subject.value
21
+ }.call).to eq(19.89043256) }
22
+ end
23
+
24
+ describe 'single precision' do
25
+ let(:subject) { OData4::Properties::Single.new('Float', '678.90325') }
26
+
27
+ it { expect(subject.type).to eq('Edm.Single') }
28
+ it { expect(subject.value).to eq(678.90325) }
29
+
30
+ it { expect(subject.url_value).to eq('678.90325F') }
31
+
32
+ it { expect { subject.value = (3.4 * (10**38) * 2) }.to raise_error(ArgumentError) }
33
+ it { expect { subject.value = (-3.4 * (10**38) * 2) }.to raise_error(ArgumentError) }
34
+
35
+ it { expect(lambda {
36
+ subject.value = '19.89043256'
37
+ subject.value
38
+ }.call).to eq(19.89043256) }
39
+
40
+ it { expect(lambda {
41
+ subject.value = 19.89043256
42
+ subject.value
43
+ }.call).to eq(19.89043256) }
44
+ end
45
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require_relative 'shared_examples'
3
+
4
+ describe OData4::Properties::Geography::LineString do
5
+ let(:klass) { OData4::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 OData4::Properties::Geography::Point do
5
+ let(:klass) { OData4::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 OData4::Properties::Geography::Polygon do
5
+ let(:klass) { OData4::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(OData4::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(OData4::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 OData4::Properties::Guid do
4
+ let(:guid) { SecureRandom.uuid }
5
+ let(:guid2) { SecureRandom.uuid }
6
+ let(:subject) { OData4::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 OData4::Properties::Integer do
4
+ let(:subject) { OData4::Properties::Integer.new('Integer', '32') }
5
+ let(:subject16) { OData4::Properties::Int16.new('Int16', '32') }
6
+ let(:subject32) { OData4::Properties::Int32.new('Int32', '32') }
7
+ let(:subject64) { OData4::Properties::Int64.new('Int64', '32') }
8
+ let(:subjectbyte) { OData4::Properties::Byte.new('Byte', '32') }
9
+ let(:subjectsbyte) { OData4::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 OData4::Properties::String do
4
+ let(:subject) { OData4::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) { OData4::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) { OData4::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) { OData4::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 OData4::Properties::TimeOfDay do
4
+ let(:subject) { OData4::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 OData4::Properties::Time do
4
+ let(:subject) { OData4::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 OData4::PropertyRegistry do
4
+ let(:subject) { OData4::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', OData4::Properties::Guid)
12
+ end
13
+
14
+ it { expect(subject['Edm.Guid']).to eq(OData4::Properties::Guid) }
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Property do
4
+ let(:subject) { OData4::Property.new('PropertyName', '1') }
5
+ let(:good_comparison) { OData4::Property.new('GoodComparison', '1') }
6
+ let(:bad_comparison) { OData4::Property.new('BadComparison', '2') }
7
+
8
+ it { expect(subject).to respond_to(:name) }
9
+ it { expect(subject.name).to eq('PropertyName') }
10
+
11
+ it { expect(subject).to respond_to(:value) }
12
+ it { expect(subject.value).to eq('1') }
13
+
14
+ it { expect(subject).to respond_to(:xml_value) }
15
+ it { expect(subject.xml_value).to eq('1') }
16
+
17
+ it { expect(subject).to respond_to(:url_value) }
18
+ it { expect(subject.url_value).to eq('1') }
19
+
20
+ it { expect(subject).to respond_to(:type) }
21
+ it { expect(lambda {subject.type}).to raise_error(NotImplementedError) }
22
+
23
+ it { expect(subject).to respond_to(:allows_nil?) }
24
+ it { expect(subject.allows_nil?).to eq(true) }
25
+
26
+ it { expect(subject).to respond_to(:concurrency_mode) }
27
+ it { expect(subject.concurrency_mode).to eq(:none) }
28
+
29
+ it { expect(subject).to respond_to(:==) }
30
+ it { expect(subject == good_comparison).to eq(true) }
31
+ it { expect(subject == bad_comparison).to eq(false) }
32
+ end