frodo 0.12.7 → 0.12.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a40dc4c7d9c0ce23fe834d93e91365b8a0d23f60fc42317378a4f9eb021e688
4
- data.tar.gz: b2ed79b9746182ef6af02ec480925e87107d2412c4d44316fc36070f28d1511a
3
+ metadata.gz: 5a388c9e2e7916ae2e41438e5880a185e8669d24a3e69305e5feba9dcffe6969
4
+ data.tar.gz: 1e454f5b727aa91d5c8953771a55d46470fcc07f3ba915109ba482d8191749ee
5
5
  SHA512:
6
- metadata.gz: 929f1284a12b79d4ad569e043740f6893d1811cefd1f5bf6ca14fd3054c5e287544d6dfb1d7d157e0112c96ad2f755750ee84249a8f20fa03465a140a5323658
7
- data.tar.gz: 3521fb729651a1cd94333ab08d7680cd9cd0fbcf5e21c277d26db72dcb15e6821e80efe0bba9d7d68a9de9a586ffb6fdc29ac9f869595f0cda6c1d3a1370783f
6
+ metadata.gz: ba148923cea7fe4537475e6f0b2667079730b02a949b3a8fbc77bffe18399b351000542d49bebec118455d833b39c20210360dcc4445b9d01901a9914f1f96d7
7
+ data.tar.gz: da0d8abbf0c24dfaf42c2bddf8cb9ad06bc69e8000b29d975691df32a149cfb01ddab4d6189f4b3da897615958655610d9738c62960c9d14a326b69f2186465d
@@ -41,7 +41,7 @@ module Frodo
41
41
 
42
42
  def metadata_on_init
43
43
  # Creating Metadata using a different client than the one that is stored
44
- Frodo::Client.new(@options).api_get("$metadata").body unless @options[:with_metadata]
44
+ Frodo::Client.new(@options).api_get("$metadata").body if @options[:with_metadata]
45
45
  end
46
46
 
47
47
  # Public: Execute a query and returns the result.
@@ -1,4 +1,3 @@
1
-
2
1
  module Frodo
3
2
  # Encapsulates the basic details and functionality needed to interact with an
4
3
  # Frodo service.
@@ -21,7 +20,7 @@ module Frodo
21
20
  @service_url = service_url
22
21
 
23
22
  Frodo::ServiceRegistry.add(self)
24
- register_custom_types unless options[:with_metadata]
23
+ register_custom_types if @options[:with_metadata]
25
24
  end
26
25
 
27
26
  # Returns user supplied name for service, or its URL
@@ -173,14 +172,15 @@ module Frodo
173
172
  end
174
173
 
175
174
  def with_metadata?
176
- !options.key?(:with_metadata) || options[:with_metadata]
175
+ !@options.key?(:with_metadata) || @options[:with_metadata]
177
176
  end
178
177
 
179
178
  private
180
179
 
181
180
  def default_options
182
181
  {
183
- strict: true # strict property validation
182
+ strict: true, # strict property validation
183
+ with_metadata: true
184
184
  }
185
185
  end
186
186
 
@@ -1,3 +1,3 @@
1
1
  module Frodo
2
- VERSION = '0.12.7'
2
+ VERSION = '0.12.8'
3
3
  end
@@ -14,7 +14,8 @@ describe Frodo::Client do
14
14
  instance_url: instance_url,
15
15
  base_path: base_path,
16
16
  client_id: 'client_id',
17
- client_secret: 'secret'
17
+ client_secret: 'secret',
18
+ with_metadata: true
18
19
  )
19
20
 
20
21
  expect(client.options[:client_id]).to eql("client_id")
@@ -26,13 +27,36 @@ describe Frodo::Client do
26
27
  to_return(body: File.new('spec/fixtures/files/metadata.xml'), status: 200)
27
28
 
28
29
  service = client.service
29
- allow(service).to receive(:with_metadata?).and_return(true)
30
+ expect(service.with_metadata?).to be_truthy
30
31
 
31
32
  expect(service['Products']).to_not be_nil
32
33
  expect(service['Products'].name).to eql('Products')
33
34
  expect(service['Products'].type).to eql('ODataDemo.Product')
34
35
  end
35
36
 
37
+ it "creates a client without metadata" do
38
+ client = subject.new(
39
+ instance_url: instance_url,
40
+ base_path: base_path,
41
+ client_id: 'client_id',
42
+ client_secret: 'secret',
43
+ with_metadata: false
44
+ )
45
+
46
+ expect(client.options[:client_id]).to eql("client_id")
47
+ expect(client.options[:client_secret]).to eql("secret")
48
+ expect(client.options[:instance_url]).to eql(instance_url)
49
+ expect(client.options[:base_path]).to eql("/api")
50
+
51
+ expect_any_instance_of(Frodo::Client).to_not receive(:api_get)
52
+ service = client.service
53
+ expect(service.with_metadata?).to be_falsey
54
+
55
+ expect(service['Products']).to_not be_nil
56
+ expect(service['Products'].name).to eql('Products')
57
+ expect(service['Products'].type).to eql(nil) #because we init new EntitySet only with name
58
+ end
59
+
36
60
  it "creates a client and inject a service instead of pulling the configured one" do
37
61
  service = Frodo::Service.new(service_url, name: 'Demo', metadata_file: 'spec/fixtures/files/metadata.xml')
38
62
  client = subject.new(
@@ -3,7 +3,8 @@ require 'spec_helper'
3
3
  describe Frodo::Service do
4
4
  let(:service_url) { 'http://services.odata.org/V4/OData/OData.svc' }
5
5
  let(:metadata_file) { 'spec/fixtures/files/metadata.xml' }
6
- let(:subject) { Frodo::Service.new(service_url, name: 'ODataDemo', metadata_file: metadata_file) }
6
+ let(:options){{name: 'ODataDemo', metadata_file: metadata_file }}
7
+ let(:subject) { Frodo::Service.new(service_url, options) }
7
8
 
8
9
  describe '.new' do
9
10
  it 'adds itself to Frodo::ServiceRegistry on creation' do
@@ -34,6 +35,21 @@ describe Frodo::Service do
34
35
  expect(Frodo::PropertyRegistry['mscrm.BooleanManagedProperty']).to be_a(Class)
35
36
  end
36
37
  end
38
+
39
+ context "with 'with_metadata' option" do
40
+ it "call 'register_custom_types'" do
41
+ expect_any_instance_of(Frodo::Service).to receive(:register_custom_types)
42
+ subject
43
+ end
44
+ end
45
+
46
+ context "without 'with_metadata' option" do
47
+ let(:options){{name: 'ODataDemo', with_metadata:false, metadata_file: metadata_file }}
48
+ it "call 'register_custom_types'" do
49
+ expect_any_instance_of(Frodo::Service).to_not receive(:register_custom_types)
50
+ subject
51
+ end
52
+ end
37
53
  end
38
54
 
39
55
  describe '#logger' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frodo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.7
4
+ version: 0.12.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Pinault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri