odata4 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,134 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::EnumType, vcr: {cassette_name: 'enum_type_specs'} do
4
+ before(:example) do
5
+ OData4::Service.open('http://services.odata.org/V4/OData/OData.svc', name: 'ODataDemo', metadata_file: metadata_file)
6
+ end
7
+
8
+ let(:metadata_file) { 'spec/fixtures/files/metadata.xml' }
9
+ let(:service) { OData4::ServiceRegistry['ODataDemo'] }
10
+
11
+ describe '.new' do
12
+ it 'requires type name' do
13
+ expect {
14
+ OData4::EnumType.new(service: service)
15
+ }.to raise_error(ArgumentError)
16
+ end
17
+
18
+ it 'requires service instance' do
19
+ expect {
20
+ OData4::EnumType.new(name: 'Address')
21
+ }.to raise_error(ArgumentError)
22
+ end
23
+
24
+ it 'requires name to refer to a valid enum type' do
25
+ expect {
26
+ OData4::EnumType.new(name: 'NotAType', service: service)
27
+ }.to raise_error(ArgumentError)
28
+ end
29
+ end
30
+
31
+ let(:enum_type) { service.enum_types['ProductStatus'] }
32
+ let(:subject) { enum_type.property_class.new('ProductStatus', nil) }
33
+
34
+ describe 'is properly parsed from service metadata' do
35
+ it { expect(enum_type.name).to eq('ProductStatus') }
36
+ it { expect(enum_type.namespace).to eq('ODataDemo') }
37
+ it { expect(enum_type.type).to eq('ODataDemo.ProductStatus') }
38
+ it { expect(enum_type.is_flags?).to eq(false) }
39
+ it { expect(enum_type.underlying_type).to eq('Edm.Byte') }
40
+ it { expect(enum_type.members.values).to eq(%w{Available LowStock Backordered Discontinued}) }
41
+ end
42
+
43
+ # Check property instance inheritance hierarchy
44
+ it { expect(subject).to be_a(OData4::Property) }
45
+ it { expect(subject).to be_a(OData4::EnumType::Property) }
46
+
47
+ it { expect(subject).to respond_to(:name) }
48
+ it { expect(subject).to respond_to(:type) }
49
+ it { expect(subject).to respond_to(:members) }
50
+
51
+ describe '#value=' do
52
+ it 'allows setting a valid value' do
53
+ subject.value = 'Available'
54
+ expect(subject.value).to eq('Available')
55
+ end
56
+
57
+ it 'ignores invalid values' do
58
+ expect {
59
+ subject.value = 'Invalid'
60
+ }.not_to raise_error
61
+
62
+ expect(subject.value).to be_nil
63
+ end
64
+
65
+ it 'allows setting by numeric value' do
66
+ expect {
67
+ subject.value = 1
68
+ }.not_to raise_error
69
+ expect(subject.value).to eq('LowStock')
70
+ end
71
+
72
+ context 'when `IsFlags` is false' do
73
+ it 'does not allow setting multiple values' do
74
+ expect {
75
+ subject.value = 'Available, Backordered'
76
+ }.to raise_error(ArgumentError)
77
+ end
78
+ end
79
+
80
+ context 'when `IsFlags` is true' do
81
+ before do
82
+ subject.define_singleton_method(:is_flags?) { true }
83
+ end
84
+
85
+ it 'allows setting multiple values' do
86
+ subject.value = 'Available, Backordered'
87
+ expect(subject.value).to eq(%w[Available Backordered])
88
+ end
89
+
90
+ it 'allows setting an invalid value' do
91
+ expect {
92
+ subject.value = 'Available, Invalid'
93
+ }.not_to raise_error
94
+
95
+ expect(subject.value).to eq(['Available'])
96
+ end
97
+
98
+ it 'allows setting by numeric value' do
99
+ expect {
100
+ subject.value = '0, 1'
101
+ }.not_to raise_error
102
+ expect(subject.value).to eq(%w[Available LowStock])
103
+ end
104
+ end
105
+ end
106
+
107
+ describe 'strict mode' do
108
+ let(:subject) { enum_type.property_class.new('ProductStatus', nil, strict: true) }
109
+
110
+ describe '#strict?' do
111
+ it { expect(subject).to be_strict }
112
+ end
113
+
114
+ describe '#value=' do
115
+ it 'does not allow setting an invalid value' do
116
+ expect {
117
+ subject.value = 'Invalid'
118
+ }.to raise_error(ArgumentError)
119
+ end
120
+
121
+ context 'when is_flags=true' do
122
+ before do
123
+ subject.define_singleton_method(:is_flags?) { true }
124
+ end
125
+
126
+ it 'does not allow setting invalid values' do
127
+ expect {
128
+ subject.value = 'Available, Invalid'
129
+ }.to raise_error(ArgumentError)
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::NavigationProperty::Proxy, vcr: {cassette_name: 'navigation_property_proxy_specs'} do
4
+ before :each do
5
+ OData4::Service.open('http://services.odata.org/V4/OData/OData.svc', name: 'ODataDemo')
6
+ end
7
+
8
+ let(:entity) { OData4::ServiceRegistry['ODataDemo']['Products'][1] }
9
+
10
+ let(:categories_proxy) { OData4::NavigationProperty::Proxy.new(entity, 'Categories') }
11
+ let(:detail_proxy) { OData4::NavigationProperty::Proxy.new(entity, 'ProductDetail') }
12
+ let(:supplier_proxy) { OData4::NavigationProperty::Proxy.new(entity, 'Supplier') }
13
+
14
+ describe 'value' do
15
+ it { expect(categories_proxy.value).to be_a(Enumerable) }
16
+ it { expect(supplier_proxy.value).to be_a(OData4::Entity) }
17
+ it { expect(detail_proxy.value).to be_a(OData4::Entity) }
18
+
19
+ context 'when value was explicitly set' do
20
+ let(:supplier) { double('supplier') }
21
+
22
+ it 'returns the set value' do
23
+ supplier_proxy.value = supplier
24
+ expect(supplier_proxy.value).to eq(supplier)
25
+ end
26
+ end
27
+
28
+ context 'when no links exist for an entity' do
29
+ before(:each) do
30
+ expect(entity).to receive(:links) do
31
+ { 'Categories' => nil, 'Supplier' => nil }
32
+ end
33
+ end
34
+
35
+ context 'for a many NavigationProperty' do
36
+ it { expect(categories_proxy.value).to eq([]) }
37
+ end
38
+
39
+ context 'for a singular NavigationProperty' do
40
+ it { expect(supplier_proxy.value).to eq(nil) }
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::NavigationProperty do
4
+ let(:options) { {
5
+ name: 'Categories',
6
+ type: 'Collection(ODataDemo.Category)',
7
+ partner: 'Products',
8
+ } }
9
+ let(:subject) do
10
+ OData4::NavigationProperty.new(options)
11
+ end
12
+
13
+ it { expect(subject).to respond_to(:name) }
14
+ it { expect(subject.name).to eq('Categories') }
15
+
16
+ it { expect(subject).to respond_to(:type) }
17
+ it { expect(subject.type).to eq('Collection(ODataDemo.Category)') }
18
+
19
+ it { expect(subject).to respond_to(:nav_type) }
20
+ it { expect(subject.nav_type).to eq(:collection) }
21
+
22
+ it { expect(subject).to respond_to(:nullable) }
23
+
24
+ it { expect(subject).to respond_to(:partner) }
25
+ it { expect(subject.partner).to eq('Products') }
26
+
27
+ describe '.new' do
28
+ it 'requires name' do
29
+ expect {
30
+ OData4::NavigationProperty.new(type: 'Collection(ODataDemo.Category)')
31
+ }.to raise_error(ArgumentError)
32
+ end
33
+
34
+ it 'requires type' do
35
+ expect {
36
+ OData4::NavigationProperty.new(name: 'Categories')
37
+ }.to raise_error(ArgumentError)
38
+ end
39
+ end
40
+
41
+ describe '#build' do
42
+ let(:metadata_file) { File.read 'spec/fixtures/files/metadata.xml' }
43
+ let(:metadata_xml) { Nokogiri::XML(metadata_file).remove_namespaces! }
44
+ let(:navigation_properties) { metadata_xml.xpath('//NavigationProperty') }
45
+ let(:subject) {
46
+ OData4::NavigationProperty.build(navigation_properties.first)
47
+ }
48
+
49
+ it { expect(subject.name).to eq('Categories') }
50
+ it { expect(subject.type).to eq('Collection(ODataDemo.Category)') }
51
+ it { expect(subject.partner).to eq('Products') }
52
+ it { expect(subject.nullable).to eq(true) }
53
+ it { expect(subject.nav_type).to eq(:collection) }
54
+ end
55
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::Binary do
4
+ let(:subject) { OData4::Properties::Binary.new('On', '1') }
5
+
6
+ it { expect(subject.type).to eq('Edm.Binary') }
7
+ it { expect(subject.value).to eq(1) }
8
+
9
+ it { expect {subject.value = 'bad'}.to raise_error(ArgumentError) }
10
+
11
+ it { expect(subject.url_value).to eq("binary'1'") }
12
+
13
+ describe 'setting to 0' do
14
+ it { expect(lambda {
15
+ subject.value = 0
16
+ subject.value
17
+ }.call).to eq(0) }
18
+
19
+ it { expect(lambda {
20
+ subject.value = false
21
+ subject.value
22
+ }.call).to eq(0) }
23
+
24
+ it { expect(lambda {
25
+ subject.value = '0'
26
+ subject.value
27
+ }.call).to eq(0) }
28
+ end
29
+
30
+ describe 'setting to 1' do
31
+ let(:subject) { OData4::Properties::Binary.new('On', '0') }
32
+
33
+ it { expect(subject.value).to eq(0) }
34
+
35
+ it { expect(lambda {
36
+ subject.value = 1
37
+ subject.value
38
+ }.call).to eq(1) }
39
+
40
+ it { expect(lambda {
41
+ subject.value = true
42
+ subject.value
43
+ }.call).to eq(1) }
44
+
45
+ it { expect(lambda {
46
+ subject.value = '1'
47
+ subject.value
48
+ }.call).to eq(1) }
49
+ end
50
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::Boolean do
4
+ let(:truthy1) { OData4::Properties::Boolean.new('Truthy', 'true') }
5
+ let(:truthy2) { OData4::Properties::Boolean.new('Truthy', '1') }
6
+ let(:falsey1) { OData4::Properties::Boolean.new('Falsey', 'false') }
7
+ let(:falsey2) { OData4::Properties::Boolean.new('Falsey', '0') }
8
+ let(:nily) { OData4::Properties::Boolean.new('Nily', nil) }
9
+
10
+ it { expect(truthy1.type).to eq('Edm.Boolean') }
11
+ it { expect(truthy1.value).to eq(true) }
12
+ it { expect(truthy2.value).to eq(true) }
13
+
14
+ it { expect(falsey1.value).to eq(false) }
15
+ it { expect(falsey2.value).to eq(false) }
16
+
17
+ it { expect(nily.value).to eq(nil) }
18
+
19
+ it { expect {truthy1.value = 'bad'}.to raise_error(ArgumentError) }
20
+
21
+ describe 'setting to false' do
22
+ let(:subject) { OData4::Properties::Boolean.new('Truthy', 'true') }
23
+
24
+ it { expect(subject.value).to eq(true) }
25
+
26
+ it { expect(lambda {
27
+ subject.value = false
28
+ subject.value
29
+ }.call).to eq(false) }
30
+
31
+ it { expect(lambda {
32
+ subject.value = 'false'
33
+ subject.value
34
+ }.call).to eq(false) }
35
+
36
+ it { expect(lambda {
37
+ subject.value = '0'
38
+ subject.value
39
+ }.call).to eq(false) }
40
+ end
41
+
42
+ describe 'setting to true' do
43
+ let(:subject) { OData4::Properties::Boolean.new('Falsey', 'false') }
44
+
45
+ it { expect(subject.value).to eq(false) }
46
+
47
+ it { expect(lambda {
48
+ subject.value = true
49
+ subject.value
50
+ }.call).to eq(true) }
51
+
52
+ it { expect(lambda {
53
+ subject.value = 'true'
54
+ subject.value
55
+ }.call).to eq(true) }
56
+
57
+ it { expect(lambda {
58
+ subject.value = '1'
59
+ subject.value
60
+ }.call).to eq(true) }
61
+ end
62
+
63
+ describe 'setting to null' do
64
+ let(:subject) { OData4::Properties::Boolean.new('Truthy', 'true') }
65
+
66
+ it { expect(subject.allows_nil?).to eq(true) }
67
+ it { expect(lambda {
68
+ subject.value = nil
69
+ subject.value
70
+ }.call).to eq(nil) }
71
+ end
72
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::Date do
4
+ let(:subject) { OData4::Properties::Date.new('Date', '2000-01-01') }
5
+ let(:new_date) { Date.strptime('2004-05-01', '%Y-%m-%d') }
6
+
7
+ it { expect(subject.type).to eq('Edm.Date') }
8
+ it { expect(subject.value).to eq(Date.parse('2000-01-01')) }
9
+
10
+ it { expect(subject.url_value).to eq("2000-01-01")}
11
+
12
+ it { expect {subject.value = 'bad'}.to raise_error(ArgumentError) }
13
+
14
+ it { expect(lambda {
15
+ subject.value = '2004-05-01'
16
+ subject.value
17
+ }.call).to eq(new_date) }
18
+
19
+ it { expect(lambda {
20
+ subject.value = new_date
21
+ subject.value
22
+ }.call).to eq(new_date) }
23
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::DateTimeOffset do
4
+ let(:subject) { OData4::Properties::DateTimeOffset.new('DateTime', '2000-01-01T16:00:00-09:00') }
5
+ let(:new_datetime) { DateTime.strptime('2004-05-01T14:32:00+02:00', '%Y-%m-%dT%H:%M:%S%:z') }
6
+
7
+ it { expect(subject.type).to eq('Edm.DateTimeOffset') }
8
+ it { expect(subject.value).to eq(DateTime.strptime('2000-01-01T16:00:00-09:00', '%Y-%m-%dT%H:%M:%S%:z')) }
9
+
10
+ it { expect(subject.url_value).to eq("2000-01-01T16:00:00-09:00")}
11
+
12
+ it { expect {subject.value = 'bad'}.to raise_error(ArgumentError) }
13
+
14
+ it { expect(lambda {
15
+ subject.value = new_datetime
16
+ subject.value
17
+ }.call).to eq(new_datetime) }
18
+
19
+ it { expect(lambda {
20
+ subject.value = nil
21
+ }).not_to raise_error }
22
+
23
+ context 'with allows_nil option set to false' do
24
+ let(:subject) { OData4::Properties::DateTimeOffset.new('DateTime', '2000-01-01T16:00:00Z-09:00', allows_nil: false) }
25
+
26
+ it { expect(lambda {
27
+ subject.value = nil
28
+ }).to raise_error(ArgumentError) }
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::DateTime do
4
+ let(:subject) { OData4::Properties::DateTime.new('DateTime', '2000-01-01T16:00:00.000') }
5
+ let(:new_datetime) { DateTime.strptime('2004-05-01T14:32:00.000', '%Y-%m-%dT%H:%M:%S.%L') }
6
+
7
+ it { expect(subject.type).to eq('Edm.DateTime') }
8
+ it { expect(subject.value).to eq(DateTime.parse('2000-01-01T16:00:00.000')) }
9
+
10
+ it { expect(subject.url_value).to eq("2000-01-01T16:00:00.000")}
11
+
12
+ it { expect {subject.value = 'bad'}.to raise_error(ArgumentError) }
13
+
14
+ it { expect(lambda {
15
+ subject.value = '2004-05-01T14:32:00.000'
16
+ subject.value
17
+ }.call).to eq(new_datetime) }
18
+
19
+ it { expect(lambda {
20
+ subject.value = new_datetime
21
+ subject.value
22
+ }.call).to eq(new_datetime) }
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe OData4::Properties::Decimal do
4
+ let(:subject) { OData4::Properties::Decimal.new('Decimal', '678.90325') }
5
+
6
+ it { expect(subject.type).to eq('Edm.Decimal') }
7
+ it { expect(subject.value).to eq(BigDecimal('678.90325')) }
8
+
9
+ it { expect(subject.url_value).to eq('678.90325M') }
10
+
11
+ it { expect { subject.value = BigDecimal((7.9 * (10**28)), 2) + 1 }.to raise_error(ArgumentError) }
12
+ it { expect { subject.value = BigDecimal((-7.9 * (10**28)), 2) - 1 }.to raise_error(ArgumentError) }
13
+ it { expect { subject.value = BigDecimal((3.4 * (10**-28)), 2) * 3.14151 + 5 }.to raise_error(ArgumentError) }
14
+
15
+ it { expect(lambda {
16
+ subject.value = '19.89043256'
17
+ subject.value
18
+ }.call).to eq(BigDecimal('19.89043256')) }
19
+
20
+ it { expect(lambda {
21
+ subject.value = BigDecimal('19.89043256')
22
+ subject.value
23
+ }.call).to eq(BigDecimal('19.89043256')) }
24
+ end