odata 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
 - data/.travis.yml +13 -0
 - data/lib/odata.rb +4 -0
 - data/lib/odata/entity.rb +68 -0
 - data/lib/odata/entity_set.rb +68 -0
 - data/lib/odata/model.rb +10 -0
 - data/lib/odata/properties.rb +4 -0
 - data/lib/odata/properties/date_time.rb +6 -2
 - data/lib/odata/properties/decimal.rb +4 -5
 - data/lib/odata/properties/float.rb +2 -6
 - data/lib/odata/properties/integer.rb +4 -8
 - data/lib/odata/properties/number.rb +13 -0
 - data/lib/odata/properties/string.rb +48 -0
 - data/lib/odata/property.rb +0 -32
 - data/lib/odata/railtie.rb +5 -2
 - data/lib/odata/service.rb +59 -2
 - data/lib/odata/version.rb +1 -1
 - data/odata.gemspec +1 -0
 - data/spec/fixtures/sample_service/products_skip0_top5.xml +171 -0
 - data/spec/fixtures/sample_service/products_skip10_top5.xml +51 -0
 - data/spec/fixtures/sample_service/products_skip5_top5.xml +179 -0
 - data/spec/odata/entity_set_spec.rb +40 -0
 - data/spec/odata/entity_spec.rb +43 -0
 - data/spec/odata/properties/decimal_spec.rb +3 -2
 - data/spec/odata/properties/string_spec.rb +33 -0
 - data/spec/odata/property_spec.rb +0 -32
 - data/spec/odata/service_registry_spec.rb +0 -6
 - data/spec/odata/service_spec.rb +17 -4
 - data/spec/spec_helper.rb +31 -7
 - metadata +29 -2
 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe OData::EntitySet do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:subject) { OData::EntitySet.new(options) }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:options) { {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  container: 'DemoService', namespace: 'ODataDemo', name: 'Products',
         
     | 
| 
      
 7 
     | 
    
         
            +
                  type: 'Product'
         
     | 
| 
      
 8 
     | 
    
         
            +
              } }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              before(:example) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                OData::Service.open('http://services.odata.org/OData/OData.svc')
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              # Basic Instance Methods
         
     | 
| 
      
 15 
     | 
    
         
            +
              it { expect(subject).to respond_to(:name, :type, :container, :namespace) }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              it { expect(subject.name).to eq('Products') }
         
     | 
| 
      
 18 
     | 
    
         
            +
              it { expect(subject.container).to eq('DemoService') }
         
     | 
| 
      
 19 
     | 
    
         
            +
              it { expect(subject.namespace).to eq('ODataDemo') }
         
     | 
| 
      
 20 
     | 
    
         
            +
              it { expect(subject.type).to eq('Product') }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              describe '#each' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                it { expect(subject).to respond_to(:each) }
         
     | 
| 
      
 24 
     | 
    
         
            +
                it { expect(lambda {
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @counter = 0
         
     | 
| 
      
 26 
     | 
    
         
            +
                  subject.each {|entity| @counter += 1}
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @counter
         
     | 
| 
      
 28 
     | 
    
         
            +
                }.call).to eq(11) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                it { expect(lambda {
         
     | 
| 
      
 30 
     | 
    
         
            +
                  @entities = []
         
     | 
| 
      
 31 
     | 
    
         
            +
                  subject.each {|entity| @entities << entity}
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @entities
         
     | 
| 
      
 33 
     | 
    
         
            +
                }.call.shuffle.first).to be_a(OData::Entity) }
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              describe '#count' do
         
     | 
| 
      
 37 
     | 
    
         
            +
                it { expect(subject).to respond_to(:count) }
         
     | 
| 
      
 38 
     | 
    
         
            +
                it { expect(subject.count).to eq(11) }
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe OData::Entity do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:subject) { OData::Entity.new(options) }
         
     | 
| 
      
 5 
     | 
    
         
            +
              let(:options) { {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  type:       'ODataDemo.Product',
         
     | 
| 
      
 7 
     | 
    
         
            +
                  namespace:  'ODataDemo'
         
     | 
| 
      
 8 
     | 
    
         
            +
              } }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              it { expect(subject).to respond_to(:name, :type, :namespace) }
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it { expect(subject.name).to eq('Product') }
         
     | 
| 
      
 13 
     | 
    
         
            +
              it { expect(subject.type).to eq('ODataDemo.Product') }
         
     | 
| 
      
 14 
     | 
    
         
            +
              it { expect(subject.namespace).to eq('ODataDemo') }
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              describe '.from_xml' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                let(:subject) { OData::Entity.from_xml(product_xml, options) }
         
     | 
| 
      
 18 
     | 
    
         
            +
                let(:product_xml) {
         
     | 
| 
      
 19 
     | 
    
         
            +
                  document = ::Nokogiri::XML(File.open('spec/fixtures/sample_service/product_0.xml'))
         
     | 
| 
      
 20 
     | 
    
         
            +
                  document.remove_namespaces!
         
     | 
| 
      
 21 
     | 
    
         
            +
                  document.xpath('//entry').first
         
     | 
| 
      
 22 
     | 
    
         
            +
                }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                before(:example) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  OData::Service.open('http://services.odata.org/OData/OData.svc')
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it { expect(OData::Entity).to respond_to(:from_xml) }
         
     | 
| 
      
 29 
     | 
    
         
            +
                it { expect(subject).to be_a(OData::Entity) }
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                it { expect(subject.name).to eq('Product') }
         
     | 
| 
      
 32 
     | 
    
         
            +
                it { expect(subject.type).to eq('ODataDemo.Product') }
         
     | 
| 
      
 33 
     | 
    
         
            +
                it { expect(subject.namespace).to eq('ODataDemo') }
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                it { expect(subject['ID']).to eq(0) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                it { expect(subject['Name']).to eq('Bread') }
         
     | 
| 
      
 37 
     | 
    
         
            +
                it { expect(subject['Description']).to eq('Whole grain bread') }
         
     | 
| 
      
 38 
     | 
    
         
            +
                it { expect(subject['ReleaseDate']).to eq(DateTime.new(1992,1,1,0,0,0,0)) }
         
     | 
| 
      
 39 
     | 
    
         
            +
                it { expect(subject['DiscontinuedDate']).to be_nil }
         
     | 
| 
      
 40 
     | 
    
         
            +
                it { expect(subject['Rating']).to eq(4) }
         
     | 
| 
      
 41 
     | 
    
         
            +
                it { expect(subject['Price']).to eq(2.5) }
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -6,8 +6,9 @@ describe OData::Properties::Decimal do 
     | 
|
| 
       6 
6 
     | 
    
         
             
              it { expect(subject.type).to eq('Edm.Decimal') }
         
     | 
| 
       7 
7 
     | 
    
         
             
              it { expect(subject.value).to eq(BigDecimal('678.90325')) }
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
              it { expect { subject.value = BigDecimal((7.9 * (10**28)) + 1 
     | 
| 
       10 
     | 
    
         
            -
              it { expect { subject.value = BigDecimal((-7.9 * (10**28)) - 1 
     | 
| 
      
 9 
     | 
    
         
            +
              it { expect { subject.value = BigDecimal((7.9 * (10**28)), 2) + 1 }.to raise_error(ArgumentError) }
         
     | 
| 
      
 10 
     | 
    
         
            +
              it { expect { subject.value = BigDecimal((-7.9 * (10**28)), 2) - 1 }.to raise_error(ArgumentError) }
         
     | 
| 
      
 11 
     | 
    
         
            +
              it { expect { subject.value = BigDecimal((3.4 * (10**-28)), 2) * 3.14151 + 5 }.to raise_error(ArgumentError) }
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
              it { expect(lambda {
         
     | 
| 
       13 
14 
     | 
    
         
             
                subject.value = '19.89043256'
         
     | 
| 
         @@ -3,6 +3,10 @@ require 'spec_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            describe OData::Properties::String do
         
     | 
| 
       4 
4 
     | 
    
         
             
              let(:subject) { OData::Properties::String.new('Stringy', 'This is an example') }
         
     | 
| 
       5 
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 
     | 
    
         
            +
             
     | 
| 
       6 
10 
     | 
    
         
             
              it { expect(subject.type).to eq('Edm.String') }
         
     | 
| 
       7 
11 
     | 
    
         
             
              it { expect(subject.value).to eq('This is an example')}
         
     | 
| 
       8 
12 
     | 
    
         | 
| 
         @@ -10,4 +14,33 @@ describe OData::Properties::String do 
     | 
|
| 
       10 
14 
     | 
    
         
             
                subject.value = 'Another example'
         
     | 
| 
       11 
15 
     | 
    
         
             
                subject.value
         
     | 
| 
       12 
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) { OData::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) { OData::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) { OData::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
         
     | 
| 
       13 
46 
     | 
    
         
             
            end
         
     | 
    
        data/spec/odata/property_spec.rb
    CHANGED
    
    | 
         @@ -17,38 +17,6 @@ describe OData::Property do 
     | 
|
| 
       17 
17 
     | 
    
         
             
              it { expect(subject).to respond_to(:allows_nil?) }
         
     | 
| 
       18 
18 
     | 
    
         
             
              it { expect(subject.allows_nil?).to eq(true) }
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
              it { expect(subject).to respond_to(:max_length) }
         
     | 
| 
       21 
     | 
    
         
            -
              it { expect(lambda {subject.max_length}).to raise_error(NotImplementedError) }
         
     | 
| 
       22 
     | 
    
         
            -
              #it { expect(subject.max_length).to eq(nil) }
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              it { expect(subject).to respond_to(:fixed_length) }
         
     | 
| 
       25 
     | 
    
         
            -
              it { expect(lambda {subject.fixed_length}).to raise_error(NotImplementedError) }
         
     | 
| 
       26 
     | 
    
         
            -
              #it { expect(subject.fixed_length).to eq(nil) }
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              it { expect(subject).to respond_to(:precision) }
         
     | 
| 
       29 
     | 
    
         
            -
              it { expect(lambda {subject.precision}).to raise_error(NotImplementedError) }
         
     | 
| 
       30 
     | 
    
         
            -
              #it { expect(subject.precision).to eq(nil) }
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              it { expect(subject).to respond_to(:scale) }
         
     | 
| 
       33 
     | 
    
         
            -
              it { expect(lambda {subject.scale}).to raise_error(NotImplementedError) }
         
     | 
| 
       34 
     | 
    
         
            -
              #it { expect(subject.scale).to eq(nil) }
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
              it { expect(subject).to respond_to(:is_unicode?) }
         
     | 
| 
       37 
     | 
    
         
            -
              it { expect(lambda {subject.is_unicode?}).to raise_error(NotImplementedError) }
         
     | 
| 
       38 
     | 
    
         
            -
              #it { expect(subject.is_unicode?).to eq(true) }
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              it { expect(subject).to respond_to(:collation) }
         
     | 
| 
       41 
     | 
    
         
            -
              it { expect(lambda {subject.collation}).to raise_error(NotImplementedError) }
         
     | 
| 
       42 
     | 
    
         
            -
              #it { expect(subject.collation).to eq(nil) }
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              it { expect(subject).to respond_to(:srid) }
         
     | 
| 
       45 
     | 
    
         
            -
              it { expect(lambda {subject.srid}).to raise_error(NotImplementedError) }
         
     | 
| 
       46 
     | 
    
         
            -
              #it { expect(subject.srid).to eq(0) }
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
              it { expect(subject).to respond_to(:default_value) }
         
     | 
| 
       49 
     | 
    
         
            -
              it { expect(lambda {subject.default_value}).to raise_error(NotImplementedError) }
         
     | 
| 
       50 
     | 
    
         
            -
              #it { expect(subject.default_value).to eq(nil) }
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
20 
     | 
    
         
             
              it { expect(subject).to respond_to(:concurrency_mode) }
         
     | 
| 
       53 
21 
     | 
    
         
             
              it { expect(subject.concurrency_mode).to eq(:none) }
         
     | 
| 
       54 
22 
     | 
    
         | 
| 
         @@ -4,12 +4,6 @@ describe OData::ServiceRegistry do 
     | 
|
| 
       4 
4 
     | 
    
         
             
              let(:subject) { OData::ServiceRegistry }
         
     | 
| 
       5 
5 
     | 
    
         
             
              let(:sample_service) { OData::Service.open('http://services.odata.org/OData/OData.svc') }
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
              # We're calling this as a private method because there should not be any
         
     | 
| 
       8 
     | 
    
         
            -
              # reasons to have to flush the service registry except in testing.
         
     | 
| 
       9 
     | 
    
         
            -
              after :each do
         
     | 
| 
       10 
     | 
    
         
            -
                OData::ServiceRegistry.instance.send(:flush)
         
     | 
| 
       11 
     | 
    
         
            -
              end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
7 
     | 
    
         
             
              it { expect(subject).to respond_to(:add) }
         
     | 
| 
       14 
8 
     | 
    
         
             
              it { expect(subject).to respond_to(:[]) }
         
     | 
| 
       15 
9 
     | 
    
         | 
    
        data/spec/odata/service_spec.rb
    CHANGED
    
    | 
         @@ -3,6 +3,8 @@ require 'spec_helper' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            describe OData::Service do
         
     | 
| 
       4 
4 
     | 
    
         
             
              let(:subject) { OData::Service.open('http://services.odata.org/OData/OData.svc') }
         
     | 
| 
       5 
5 
     | 
    
         
             
              let(:entity_types) { %w{Product FeaturedProduct ProductDetail Category Supplier Person Customer Employee PersonDetail Advertisement} }
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:entity_sets) { %w{Products ProductDetails Categories Suppliers Persons PersonDetails Advertisements} }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:entity_set_types) { %w{Product ProductDetail Category Supplier Person PersonDetail Advertisement} }
         
     | 
| 
       6 
8 
     | 
    
         
             
              let(:complex_types) { %w{Address} }
         
     | 
| 
       7 
9 
     | 
    
         | 
| 
       8 
10 
     | 
    
         
             
              # We're calling this as a private method because there should not be any
         
     | 
| 
         @@ -27,7 +29,8 @@ describe OData::Service do 
     | 
|
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
              describe 'instance methods' do
         
     | 
| 
       29 
31 
     | 
    
         
             
                it { expect(subject).to respond_to(:service_url) }
         
     | 
| 
       30 
     | 
    
         
            -
                it { expect(subject).to respond_to(: 
     | 
| 
      
 32 
     | 
    
         
            +
                it { expect(subject).to respond_to(:entity_types) }
         
     | 
| 
      
 33 
     | 
    
         
            +
                it { expect(subject).to respond_to(:entity_sets) }
         
     | 
| 
       31 
34 
     | 
    
         
             
                it { expect(subject).to respond_to(:complex_types) }
         
     | 
| 
       32 
35 
     | 
    
         
             
                it { expect(subject).to respond_to(:namespace) }
         
     | 
| 
       33 
36 
     | 
    
         
             
              end
         
     | 
| 
         @@ -36,9 +39,15 @@ describe OData::Service do 
     | 
|
| 
       36 
39 
     | 
    
         
             
                it { expect(subject.service_url).to eq('http://services.odata.org/OData/OData.svc') }
         
     | 
| 
       37 
40 
     | 
    
         
             
              end
         
     | 
| 
       38 
41 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
              describe '# 
     | 
| 
       40 
     | 
    
         
            -
                it { expect(subject. 
     | 
| 
       41 
     | 
    
         
            -
                it { expect(subject. 
     | 
| 
      
 42 
     | 
    
         
            +
              describe '#entity_types' do
         
     | 
| 
      
 43 
     | 
    
         
            +
                it { expect(subject.entity_types.size).to eq(10) }
         
     | 
| 
      
 44 
     | 
    
         
            +
                it { expect(subject.entity_types).to eq(entity_types) }
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              describe '#entity_sets' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                it { expect(subject.entity_sets.size).to eq(7) }
         
     | 
| 
      
 49 
     | 
    
         
            +
                it { expect(subject.entity_sets.keys).to eq(entity_set_types) }
         
     | 
| 
      
 50 
     | 
    
         
            +
                it { expect(subject.entity_sets.values).to eq(entity_sets) }
         
     | 
| 
       42 
51 
     | 
    
         
             
              end
         
     | 
| 
       43 
52 
     | 
    
         | 
| 
       44 
53 
     | 
    
         
             
              describe '#complex_types' do
         
     | 
| 
         @@ -70,4 +79,8 @@ describe OData::Service do 
     | 
|
| 
       70 
79 
     | 
    
         
             
                  it { expect(subject.get(::Examples::Product, {key: 0}).first.price).to eq(2.5) }
         
     | 
| 
       71 
80 
     | 
    
         
             
                end
         
     | 
| 
       72 
81 
     | 
    
         
             
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              describe '#[]' do
         
     | 
| 
      
 84 
     | 
    
         
            +
                it { expect(subject['Product']).to be_a(OData::EntitySet) }
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
       73 
86 
     | 
    
         
             
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -11,7 +11,11 @@ end 
     | 
|
| 
       11 
11 
     | 
    
         
             
            require 'odata'
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
            require 'webmock/rspec'
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
            if ENV['REAL_HTTP'] == 'true'
         
     | 
| 
      
 15 
     | 
    
         
            +
              WebMock.allow_net_connect!
         
     | 
| 
      
 16 
     | 
    
         
            +
            else
         
     | 
| 
      
 17 
     | 
    
         
            +
              WebMock.disable_net_connect!(allow_localhost: true, allow: 'codeclimate.com')
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
       15 
19 
     | 
    
         | 
| 
       16 
20 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
       17 
21 
     | 
    
         
             
              if config.files_to_run.one?
         
     | 
| 
         @@ -32,13 +36,33 @@ RSpec.configure do |config| 
     | 
|
| 
       32 
36 
     | 
    
         
             
              end
         
     | 
| 
       33 
37 
     | 
    
         | 
| 
       34 
38 
     | 
    
         
             
              config.before(:example) do
         
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
                unless ENV['REAL_HTTP'] == 'true'
         
     | 
| 
      
 40 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/$metadata').
         
     | 
| 
      
 41 
     | 
    
         
            +
                      to_return(status: 200, body: File.open('spec/fixtures/sample_service/metadata.xml'))
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products').
         
     | 
| 
      
 44 
     | 
    
         
            +
                      to_return(status: 200, body: File.open('spec/fixtures/sample_service/products.xml'))
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products?$inlinecount=allpages&$skip=0&$top=5').
         
     | 
| 
      
 47 
     | 
    
         
            +
                      to_return(status: 200, body: File.open('spec/fixtures/sample_service/products_skip0_top5.xml'))
         
     | 
| 
       37 
48 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products?$inlinecount=allpages&$skip=5&$top=5').
         
     | 
| 
      
 50 
     | 
    
         
            +
                      to_return(status: 200, body: File.open('spec/fixtures/sample_service/products_skip5_top5.xml'))
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products?$inlinecount=allpages&$skip=10&$top=5').
         
     | 
| 
      
 53 
     | 
    
         
            +
                      to_return(status: 200, body: File.open('spec/fixtures/sample_service/products_skip10_top5.xml'))
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products/$count').
         
     | 
| 
      
 56 
     | 
    
         
            +
                      to_return(status: 200, :body => '11')
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  WebMock.stub_request(:get, 'http://services.odata.org/OData/OData.svc/Products(0)').
         
     | 
| 
      
 59 
     | 
    
         
            +
                      to_return(status: 200, body: File.open('spec/fixtures/sample_service/product_0.xml'))
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
       40 
62 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 63 
     | 
    
         
            +
              config.after(:example) do
         
     | 
| 
      
 64 
     | 
    
         
            +
                # We're calling this as a private method because there should not be any
         
     | 
| 
      
 65 
     | 
    
         
            +
                # reasons to have to flush the service registry except in testing.
         
     | 
| 
      
 66 
     | 
    
         
            +
                OData::ServiceRegistry.instance.send(:flush)
         
     | 
| 
       43 
67 
     | 
    
         
             
              end
         
     | 
| 
       44 
68 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: odata
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - James Thompson
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-06- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-06-30 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -94,6 +94,20 @@ dependencies: 
     | 
|
| 
       94 
94 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       95 
95 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
96 
     | 
    
         
             
                    version: 1.18.0
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: backports
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: 3.6.0
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: 3.6.0
         
     | 
| 
       97 
111 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       98 
112 
     | 
    
         
             
              name: nokogiri
         
     | 
| 
       99 
113 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -152,6 +166,8 @@ files: 
     | 
|
| 
       152 
166 
     | 
    
         
             
            - README.md
         
     | 
| 
       153 
167 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       154 
168 
     | 
    
         
             
            - lib/odata.rb
         
     | 
| 
      
 169 
     | 
    
         
            +
            - lib/odata/entity.rb
         
     | 
| 
      
 170 
     | 
    
         
            +
            - lib/odata/entity_set.rb
         
     | 
| 
       155 
171 
     | 
    
         
             
            - lib/odata/model.rb
         
     | 
| 
       156 
172 
     | 
    
         
             
            - lib/odata/properties.rb
         
     | 
| 
       157 
173 
     | 
    
         
             
            - lib/odata/properties/binary.rb
         
     | 
| 
         @@ -162,6 +178,7 @@ files: 
     | 
|
| 
       162 
178 
     | 
    
         
             
            - lib/odata/properties/float.rb
         
     | 
| 
       163 
179 
     | 
    
         
             
            - lib/odata/properties/guid.rb
         
     | 
| 
       164 
180 
     | 
    
         
             
            - lib/odata/properties/integer.rb
         
     | 
| 
      
 181 
     | 
    
         
            +
            - lib/odata/properties/number.rb
         
     | 
| 
       165 
182 
     | 
    
         
             
            - lib/odata/properties/string.rb
         
     | 
| 
       166 
183 
     | 
    
         
             
            - lib/odata/properties/time.rb
         
     | 
| 
       167 
184 
     | 
    
         
             
            - lib/odata/property.rb
         
     | 
| 
         @@ -174,6 +191,11 @@ files: 
     | 
|
| 
       174 
191 
     | 
    
         
             
            - spec/fixtures/sample_service/metadata.xml
         
     | 
| 
       175 
192 
     | 
    
         
             
            - spec/fixtures/sample_service/product_0.xml
         
     | 
| 
       176 
193 
     | 
    
         
             
            - spec/fixtures/sample_service/products.xml
         
     | 
| 
      
 194 
     | 
    
         
            +
            - spec/fixtures/sample_service/products_skip0_top5.xml
         
     | 
| 
      
 195 
     | 
    
         
            +
            - spec/fixtures/sample_service/products_skip10_top5.xml
         
     | 
| 
      
 196 
     | 
    
         
            +
            - spec/fixtures/sample_service/products_skip5_top5.xml
         
     | 
| 
      
 197 
     | 
    
         
            +
            - spec/odata/entity_set_spec.rb
         
     | 
| 
      
 198 
     | 
    
         
            +
            - spec/odata/entity_spec.rb
         
     | 
| 
       177 
199 
     | 
    
         
             
            - spec/odata/model_spec.rb
         
     | 
| 
       178 
200 
     | 
    
         
             
            - spec/odata/properties/binary_spec.rb
         
     | 
| 
       179 
201 
     | 
    
         
             
            - spec/odata/properties/boolean_spec.rb
         
     | 
| 
         @@ -218,6 +240,11 @@ test_files: 
     | 
|
| 
       218 
240 
     | 
    
         
             
            - spec/fixtures/sample_service/metadata.xml
         
     | 
| 
       219 
241 
     | 
    
         
             
            - spec/fixtures/sample_service/product_0.xml
         
     | 
| 
       220 
242 
     | 
    
         
             
            - spec/fixtures/sample_service/products.xml
         
     | 
| 
      
 243 
     | 
    
         
            +
            - spec/fixtures/sample_service/products_skip0_top5.xml
         
     | 
| 
      
 244 
     | 
    
         
            +
            - spec/fixtures/sample_service/products_skip10_top5.xml
         
     | 
| 
      
 245 
     | 
    
         
            +
            - spec/fixtures/sample_service/products_skip5_top5.xml
         
     | 
| 
      
 246 
     | 
    
         
            +
            - spec/odata/entity_set_spec.rb
         
     | 
| 
      
 247 
     | 
    
         
            +
            - spec/odata/entity_spec.rb
         
     | 
| 
       221 
248 
     | 
    
         
             
            - spec/odata/model_spec.rb
         
     | 
| 
       222 
249 
     | 
    
         
             
            - spec/odata/properties/binary_spec.rb
         
     | 
| 
       223 
250 
     | 
    
         
             
            - spec/odata/properties/boolean_spec.rb
         
     |