From 283e451501a0b1a9a4f36c628a324b0290d02974 Mon Sep 17 00:00:00 2001 From: Ernie Brodeur Date: Thu, 15 Nov 2018 23:33:15 -0800 Subject: [PATCH] wip --- spec/cts/mpx/driver/connections_spec.rb | 2 +- spec/cts/mpx/driver/exceptions_spec.rb | 5 +- spec/cts/mpx/driver/request_spec.rb | 2 + spec/cts/mpx/driver/response_spec.rb | 2 +- spec/cts/mpx/entries_spec.rb | 4 +- spec/cts/mpx/entry_spec.rb | 60 ++++++++------- spec/cts/mpx/field_spec.rb | 14 +--- spec/cts/mpx/fields_spec.rb | 6 +- spec/cts/mpx/query_spec.rb | 17 ++--- spec/cts/mpx/registry_spec.rb | 40 +++++----- spec/cts/mpx/service_spec.rb | 7 +- spec/cts/mpx/services/data_spec.rb | 6 +- spec/cts/mpx/services/ingest_spec.rb | 2 +- spec/cts/mpx/services/web_spec.rb | 4 +- spec/cts/mpx/services_spec.rb | 8 +- spec/cts/mpx/validators_spec.rb | 5 +- spec/spec_helper_shared_contexts.rb | 97 +++++++++++++++++-------- 17 files changed, 149 insertions(+), 132 deletions(-) diff --git a/spec/cts/mpx/driver/connections_spec.rb b/spec/cts/mpx/driver/connections_spec.rb index 24c5455..d1512e6 100644 --- a/spec/cts/mpx/driver/connections_spec.rb +++ b/spec/cts/mpx/driver/connections_spec.rb @@ -4,7 +4,7 @@ module Cts module Mpx module Driver describe Connections do - include_context "with basic parameters" + include_context "with parameters" let(:uri) { account_id } let(:connection) { Excon.new uri } diff --git a/spec/cts/mpx/driver/exceptions_spec.rb b/spec/cts/mpx/driver/exceptions_spec.rb index 85794f4..03276e9 100644 --- a/spec/cts/mpx/driver/exceptions_spec.rb +++ b/spec/cts/mpx/driver/exceptions_spec.rb @@ -4,12 +4,14 @@ module Cts module Mpx module Driver describe Exceptions do + include_context "with parameters" + let(:false_block) { proc { false } } let(:true_block) { proc { true } } + let(:reference) { 1234 } describe "::raise_unless_account_id" do context "when the argument is not an account_id" do - let(:reference) { 1234 } it "is expected to raise a ArgumentError with is not a valid account_id " do expect { described_class.raise_unless_account_id(reference) }.to raise_error ArgumentError, /#{reference} is not a valid account_id/ @@ -44,7 +46,6 @@ module Driver describe "::raise_unless_reference?" do it { expect(described_class).to respond_to(:raise_unless_reference?).with(1).argument } context "when the argument is not a reference" do - let(:reference) { 1234 } it "is expected to raise a ArgumentError with is not a valid reference " do expect { described_class.raise_unless_reference?(reference) }.to raise_error ArgumentError, /#{reference} is not a valid reference/ diff --git a/spec/cts/mpx/driver/request_spec.rb b/spec/cts/mpx/driver/request_spec.rb index ce071d3..0708a9f 100644 --- a/spec/cts/mpx/driver/request_spec.rb +++ b/spec/cts/mpx/driver/request_spec.rb @@ -4,6 +4,8 @@ module Cts module Mpx module Driver describe Request do + include_context "with parameters" + it { is_expected.to be_a_kind_of Creatable } describe "Instance method signatures" do diff --git a/spec/cts/mpx/driver/response_spec.rb b/spec/cts/mpx/driver/response_spec.rb index a120a71..cc2bd35 100644 --- a/spec/cts/mpx/driver/response_spec.rb +++ b/spec/cts/mpx/driver/response_spec.rb @@ -4,7 +4,7 @@ module Cts module Mpx module Driver describe Response do - include_context "with request and response" + include_context "with request and response objects" it { is_expected.to be_a_kind_of Creatable } diff --git a/spec/cts/mpx/entries_spec.rb b/spec/cts/mpx/entries_spec.rb index 26ec76d..78c6623 100644 --- a/spec/cts/mpx/entries_spec.rb +++ b/spec/cts/mpx/entries_spec.rb @@ -3,8 +3,8 @@ module Cts module Mpx describe Entries do - include_context "with media entries" - include_context "with field" + include_context "with entries objects" + include_context "with field objects" let(:other_entries) { Entries.create(collection: [other_entry]) } let(:other_entry) { Entry.new } diff --git a/spec/cts/mpx/entry_spec.rb b/spec/cts/mpx/entry_spec.rb index 05a7e04..b677559 100644 --- a/spec/cts/mpx/entry_spec.rb +++ b/spec/cts/mpx/entry_spec.rb @@ -3,13 +3,13 @@ module Cts module Mpx describe Entry do - include_context "with basic parameters" - include_context "with field" - include_context "with media entry" - include_context "with page" + include_context "with parameters" + include_context "with field objects" + include_context "with media objects" + include_context "with page objects" + include_context "with empty objects" let(:data) { { id: media_id } } - let(:empty_entry) { described_class.new } it { is_expected.to be_a_kind_of Creatable } @@ -28,8 +28,8 @@ module Mpx end describe '::self.load_by_id' do - include_context "with user" - include_context "with request and response" + include_context "with user objects" + include_context "with request and response objects" let(:entries) { [{ "id" => media_id, "guid" => "123" }] } @@ -54,7 +54,7 @@ module Mpx end it "is expected to call entry.load" do - allow(empty_entry).to receive(:load).and_return media_entry + allow(entry).to receive(:load).and_return media_entry described_class.load_by_id user: user, id: 'http://data.media.theplatform.com/media/data/Media/1' expect(media_entry).to have_received(:load) end @@ -64,27 +64,27 @@ module Mpx describe '#id' do context "when the argument is not a reference" do - it { expect { empty_entry.id = 'no' }.to raise_error ArgumentError, /is not a valid reference/ } + it { expect { entry.id = 'no' }.to raise_error ArgumentError, /is not a valid reference/ } end it "is expected to set service" do - empty_entry.id = media_id - expect(empty_entry.service).to eq media_service + entry.id = media_id + expect(entry.service).to eq media_service end it "is expected to set endpoint" do - empty_entry.id = media_id - expect(empty_entry.endpoint).to eq 'Media' + entry.id = media_id + expect(entry.endpoint).to eq 'Media' end it "is expected to build an id field" do - empty_entry.id = media_id - expect(empty_entry.fields['id']).to eq media_id + entry.id = media_id + expect(entry.fields['id']).to eq media_id end end describe '#load' do - include_context "with user" - include_context "with request and response" + include_context "with user objects" + include_context "with request and response objects" let(:fields) { 'id,guid' } let(:params) { { user: user, fields: fields } } @@ -131,10 +131,8 @@ module Mpx end describe '#save (when ID is not set)' do - include_context "with user" - include_context "with request and response" - - let(:empty_entry) { Cts::Mpx::Entry.new } + include_context "with user objects" + include_context "with request and response objects" before do media_entry.fields['ownerId'] = account_id @@ -163,33 +161,33 @@ module Mpx context "when fields['ownerId'] is not set" do - before { empty_entry.fields['ownerId'] = nil } + before { entry.fields['ownerId'] = nil } - it { expect { empty_entry.save user: user }.to raise_error ArgumentError, "fields['ownerId'] must be set" } + it { expect { entry.save user: user }.to raise_error ArgumentError, "fields['ownerId'] must be set" } end context "when service is not set" do before do - empty_entry.fields['ownerId'] = account_id - empty_entry.instance_variable_set :@service, nil + entry.fields['ownerId'] = account_id + entry.instance_variable_set :@service, nil end - it { expect { empty_entry.save user: user }.to raise_error ArgumentError, /is a required keyword/ } + it { expect { entry.save user: user }.to raise_error ArgumentError, /is a required keyword/ } end context "when endpoint is not set" do before do - empty_entry.fields['ownerId'] = account_id - empty_entry.instance_variable_set :@endpoint, nil + entry.fields['ownerId'] = account_id + entry.instance_variable_set :@endpoint, nil end - it { expect { empty_entry.save user: user }.to raise_error ArgumentError, /is a required keyword/ } + it { expect { entry.save user: user }.to raise_error ArgumentError, /is a required keyword/ } end end describe '#save (when ID is set)' do - include_context "with user" - include_context "with request and response" + include_context "with user objects" + include_context "with request and response objects" before do media_entry.fields['ownerId'] = account_id diff --git a/spec/cts/mpx/field_spec.rb b/spec/cts/mpx/field_spec.rb index 254f583..d00dd8d 100644 --- a/spec/cts/mpx/field_spec.rb +++ b/spec/cts/mpx/field_spec.rb @@ -3,11 +3,7 @@ module Cts module Mpx describe Field do - let(:field_name) { 'guid' } - let(:field_value) { '12345' } - let(:custom_field_name) { 'custom$guid' } - let(:guid_field) { described_class.create name: field_name, value: field_value } - let(:custom_field) { described_class.create(name: custom_field_name, value: 'abcdef', xmlns: { "custom" => "http://1234a.com" }) } + include_context "with field objects" it { is_expected.to be_a_kind_of Creatable } @@ -23,14 +19,12 @@ module Mpx it { is_expected.to respond_to(:type).with(0).argument } describe '::to_h' do - let(:result) { guid_field } - it "is expected to have a key set to name" do - expect(result.to_h.keys.first).to eq field_name + expect(field.name).to eq field_name end it "is expected to have a value set to value" do - expect(result.to_h.values.first).to eq field_value + expect(field.value).to eq field_value end end @@ -39,7 +33,7 @@ module Mpx it { expect(custom_field.type).to eq :custom } end - it { expect(guid_field.type).to eq :internal } + it { expect(field.type).to eq :internal } end end end diff --git a/spec/cts/mpx/fields_spec.rb b/spec/cts/mpx/fields_spec.rb index f275850..dd6e35f 100644 --- a/spec/cts/mpx/fields_spec.rb +++ b/spec/cts/mpx/fields_spec.rb @@ -26,8 +26,8 @@ module Mpx # entry: data # } # end - include_context "with field" - include_context "with basic objects" + include_context "with field objects" + include_context "with empty objects" it { is_expected.to be_a_kind_of Enumerable } it { is_expected.to be_a_kind_of Creatable } @@ -137,7 +137,7 @@ module Mpx end describe '::parse' do - include_context "with media entry" + include_context "with media objects" let(:data) { { id: media_id, service: media_service, endpoint: media_endpoint } } diff --git a/spec/cts/mpx/query_spec.rb b/spec/cts/mpx/query_spec.rb index 8da7deb..4da11dd 100644 --- a/spec/cts/mpx/query_spec.rb +++ b/spec/cts/mpx/query_spec.rb @@ -4,15 +4,13 @@ module Cts module Mpx describe Query do include_context "with fields" - include_context "with media entry" - include_context "with request and response" - include_context "with user" - - let(:new_entry) { described_class.new } - let(:query) { described_class.new } + include_context "with media objects" + include_context "with user objects" + include_context "with empty objects" + include_context "with request and response objects" before do - allow(described_class).to receive(:new).and_return new_entry + allow(described_class).to receive(:new).and_return query allow(Cts::Mpx::Services::Data).to receive(:get).and_return(populated_response) end @@ -33,11 +31,8 @@ module Mpx it { is_expected.to have_attributes(sort: nil) } end - describe "Class methods" do + describe "Responds to" do it { expect(described_class).to respond_to(:create) } - end - - describe "Instance methods" do it { is_expected.to respond_to(:entries).with(0).arguments } it { is_expected.to respond_to(:to_h).with(0).arguments.and_keywords(:include_entries) } it { is_expected.to respond_to(:run).with(0).arguments.and_keywords(:user) } diff --git a/spec/cts/mpx/registry_spec.rb b/spec/cts/mpx/registry_spec.rb index 80fb34d..3c48270 100644 --- a/spec/cts/mpx/registry_spec.rb +++ b/spec/cts/mpx/registry_spec.rb @@ -3,16 +3,12 @@ module Cts module Mpx describe Registry do - let(:user) { user } - let(:account_id) { account_id } - let(:root_account) { 'urn:theplatform:auth:root' } - let(:root_domain) { Driver.load_json_file('config/root_registry_sea1.json')['resolveDomainResponse'] } + include_context "with user objects" + include_context "with parameters" - let(:result_hash) do - { 'resolveDomainResponse' => root_domain } - end + let(:root_domain) { Driver.load_json_file('config/root_registry_sea1.json')['resolveDomainResponse'] } + let(:result_hash) { { 'resolveDomainResponse' => root_domain } } - # before { described_class.initialize } describe "Attributes" do it { is_expected.to have_attributes(domains: an_instance_of(Hash)) } end @@ -26,7 +22,7 @@ module Mpx describe "::fetch_and_store_domain" do before do allow(described_class).to receive(:fetch_domain).and_return(root_domain) - Registry.instance_variable_set(:@domains, root_account => root_domain) + Registry.instance_variable_set(:@domains, root_account_id => root_domain) end it "is expected to call fetch_domain" do @@ -41,8 +37,8 @@ module Mpx end it "is expected to store the domain in domains" do - described_class.fetch_and_store_domain user, root_account - expect(described_class.domains).to eq root_account => result_hash["resolveDomainResponse"] + described_class.fetch_and_store_domain user, root_account_id + expect(described_class.domains).to eq root_account_id => result_hash["resolveDomainResponse"] end it "is expected to return the domain" do @@ -51,6 +47,9 @@ module Mpx end describe "::fetch_domain" do + include_context "with response objects" + include_context "with user objects" + let(:post_params) do { user: user, @@ -70,15 +69,10 @@ module Mpx }' end - let(:response) do - r = Driver::Response.new - r.instance_variable_set :@data, Oj.load(post_response_string) - r.instance_variable_set :@status, 200 - r + before do + response.instance_variable_set :@data, Oj.load(post_response_string) + allow(Services::Web).to receive(:post).and_return response end - let(:user) { user } - - before { allow(Services::Web).to receive(:post).and_return response } it { expect { described_class.fetch_domain user, account_id }.to raise_error_without_user_token(user) } @@ -101,7 +95,7 @@ module Mpx context "when no account_id is supplied" do it "is expected to return the root account_id (urn:theplatform:auth:root)" do - expect(described_class.fetch_domain(user, root_account)).to eq described_class.domains[root_account] + expect(described_class.fetch_domain(user, root_account_id)).to eq described_class.domains[root_account_id] end end end @@ -110,7 +104,7 @@ module Mpx let(:file) { 'config/root_registry.sea1.json' } # this effectively re-initializes things without calling initialize or store_domain. - after { Registry.instance_variable_set(:@domains, root_account => root_domain) } + after { Registry.instance_variable_set(:@domains, root_account_id => root_domain) } before do allow(Driver).to receive(:load_json_file).with(/#{file}/).and_return(result_hash) @@ -121,10 +115,10 @@ module Mpx expect(Driver).to have_received(:load_json_file) end - it "is expected to call store_domain with root_account and the hash" do + it "is expected to call store_domain with root_account_id and the hash" do allow(described_class).to receive(:store_domain).and_return(result_hash) described_class.initialize - expect(described_class).to have_received(:store_domain).with(root_domain, root_account) + expect(described_class).to have_received(:store_domain).with(root_domain, root_account_id) end end diff --git a/spec/cts/mpx/service_spec.rb b/spec/cts/mpx/service_spec.rb index f166c14..cff5a47 100644 --- a/spec/cts/mpx/service_spec.rb +++ b/spec/cts/mpx/service_spec.rb @@ -4,10 +4,9 @@ module Cts module Mpx module Driver describe Service do - let(:account_id) { account_id } - let(:root_account_id) { 'urn:theplatform:auth:root' } - let(:service) { Services['User Data Service'] } - let(:url) { "https://identity.auth.theplatform.com/idm" } + include_context "with parameters" + let(:service) { Services[ident_service] } + let(:url) { ident_endpoint } describe "Attributes" do it { is_expected.to have_attributes(endpoints: []) } diff --git a/spec/cts/mpx/services/data_spec.rb b/spec/cts/mpx/services/data_spec.rb index 52eee53..8961c3b 100644 --- a/spec/cts/mpx/services/data_spec.rb +++ b/spec/cts/mpx/services/data_spec.rb @@ -4,9 +4,9 @@ module Cts module Mpx module Services describe Data do - include_context "with request and response" - include_context "with media entry" - include_context "with user" + include_context "with request and response objects" + include_context "with media objects" + include_context "with user objects" let(:root_domain) { Driver.load_json_file('config/root_registry_sea1.json')['resolveDomainResponse'] } let(:call_params) { { user: user, service: media_service, endpoint: media_endpoint, query: {} } } diff --git a/spec/cts/mpx/services/ingest_spec.rb b/spec/cts/mpx/services/ingest_spec.rb index f1227ff..0285c0e 100644 --- a/spec/cts/mpx/services/ingest_spec.rb +++ b/spec/cts/mpx/services/ingest_spec.rb @@ -4,7 +4,7 @@ module Cts module Mpx module Services describe Ingest do - let(:user) { user } + include_context "with user objects" it { expect(described_class.class).to be Module } diff --git a/spec/cts/mpx/services/web_spec.rb b/spec/cts/mpx/services/web_spec.rb index 205d874..d227f41 100644 --- a/spec/cts/mpx/services/web_spec.rb +++ b/spec/cts/mpx/services/web_spec.rb @@ -4,9 +4,9 @@ module Cts module Mpx module Services describe Web do - include_context "with user" + include_context "with user objects" include_context "with web parameters" - include_context "with request and response" + include_context "with request and response objects" it { expect(described_class.class).to be Module } diff --git a/spec/cts/mpx/services_spec.rb b/spec/cts/mpx/services_spec.rb index b109b13..92ca667 100644 --- a/spec/cts/mpx/services_spec.rb +++ b/spec/cts/mpx/services_spec.rb @@ -3,7 +3,7 @@ module Cts module Mpx describe Services do - let(:user) { user } + include_context "with user objects" let(:service_name) { 'Access Data Service' } describe "Attributes" do @@ -40,9 +40,7 @@ module Mpx end describe '::from_url' do - let(:media_id) { 'http://data.media.theplatform.com/media/data/Media/1' } - let(:field_id) { 'http://data.media.theplatform.com/media/data/Media/Field/1' } - + include_context "with media parameters" context "when the argument is not valid" do it "is expected to return nil" do expect(described_class.from_url('askjfdaldfkj')).to eq nil @@ -54,7 +52,7 @@ module Mpx end it "is expected to return a hash with a service field: ServiceObject and endpoint: String" do - expect(described_class.from_url(field_id)).to eq(service: 'Media Data Service', endpoint: 'Media/Field') + expect(described_class.from_url(media_field_id)).to eq(service: 'Media Data Service', endpoint: 'Media/Field') end end diff --git a/spec/cts/mpx/validators_spec.rb b/spec/cts/mpx/validators_spec.rb index 59084b6..a983154 100644 --- a/spec/cts/mpx/validators_spec.rb +++ b/spec/cts/mpx/validators_spec.rb @@ -3,6 +3,9 @@ module Cts module Mpx describe Validators do + include_context "with parameters" + include_context "with media parameters" + let(:reference) { account_id } describe "::account_id?" do @@ -15,7 +18,7 @@ module Mpx end context "when it is not an account_id" do - let(:reference) { "http://media.data.theplatform.com/media/data/Media/1" } + let(:reference) { media_id } it { expect(described_class.account_id?(reference)).to eq false } end diff --git a/spec/spec_helper_shared_contexts.rb b/spec/spec_helper_shared_contexts.rb index 89128c0..0a873b9 100644 --- a/spec/spec_helper_shared_contexts.rb +++ b/spec/spec_helper_shared_contexts.rb @@ -1,26 +1,26 @@ require 'rspec' -RSpec.shared_context "with basic parameters" do +RSpec.shared_context "with parameters" do let(:account_id) { "http://access.auth.theplatform.com/data/Account/1" } + let(:ident_service) { 'User Data Service'} + let(:ident_endpoint) { "https://identity.auth.theplatform.com/idm" } let(:root_account_id) { 'urn:theplatform:auth:root' } end -RSpec.shared_context "with basic objects" do - let(:entry) { Cts::Mpx::Entry.new } - let(:query) { Cts::Mpx::Query.new } - let(:fields) { Cts::Mpx::Fields.new } -end - -RSpec.shared_context "with media entry" do - include_context "with basic objects" +RSpec.shared_context "with media parameters" do let(:media_endpoint) { 'Media' } - let(:media_entry) { Cts::Mpx::Entry.create(id: media_id) { |object| object.id = object.id } } let(:media_id) { 'http://data.media.theplatform.com/media/data/Media/1' } + let(:media_field_id) { 'http://data.media.theplatform.com/media/data/Media/Field/1' } let(:media_service) { 'Media Data Service' } end -RSpec.shared_context "with media entries" do - include_context "with media entry" +RSpec.shared_context "with media objects" do + include_context "with media parameters" + let(:media_entry) { Cts::Mpx::Entry.create(id: media_id) { |object| object.id = object.id } } +end + +RSpec.shared_context "with entries objects" do + include_context "with media objects" let(:media_entries) { Cts::Mpx::Entries.create collection: [media_entry] } end @@ -30,46 +30,52 @@ end RSpec.shared_context "with web parameters" do - include_context "with user" + include_context "with user objects" let(:web_arguments) { { 'username' => user_name, 'password' => user_password } } + let(:web_assembler_parameters) { { service: web_service, endpoint: web_endpoint, method: web_method, arguments: web_arguments } } let(:web_endpoint) { 'Authentication' } let(:web_method) { 'signIn' } - let(:web_assembler_parameters) { { service: web_service, endpoint: web_endpoint, method: web_method, arguments: web_arguments } } - let(:web_post_parameters) { web_assembler_parameters.merge(user: user, query: {}) } let(:web_payload) { {} } + let(:web_post_parameters) { web_assembler_parameters.merge(user: user, query: {}) } let(:web_service) { 'User Data Service' } end -RSpec.shared_context "with user" do - let(:user) { Cts::Mpx::User.create username: user_name, password: user_password, token: user_token } +RSpec.shared_context "with user parameters" do let(:user_name) { "no-reply@comcast.net" } let(:user_password) { "a_password" } let(:user_token) { "carpe diem" } end -RSpec.shared_context "with field" do - let(:field) { Cts::Mpx::Field.create name: field_name, value: field_value } +RSpec.shared_context "with user objects" do + include_context "with user parameters" + let(:user) { Cts::Mpx::User.create username: user_name, password: user_password, token: user_token } +end + +RSpec.shared_context "with field parameters" do let(:field_name) { 'guid' } let(:field_value) { 'carpe diem' } - let(:custom_field) { Cts::Mpx::Field.create name: custom_field_name, value: custom_field_value , xmlns: custom_field_xmlns } let(:custom_field_value) { 'a_custom_field_value' } let(:custom_field_name) { 'custom$guid' } let(:custom_field_xmlns) { { 'custom' => 'uuid' } } end +RSpec.shared_context "with field objects" do + include_context "with field parameters" + let(:field) { Cts::Mpx::Field.create name: field_name, value: field_value } + let(:custom_field) { Cts::Mpx::Field.create name: custom_field_name, value: custom_field_value , xmlns: custom_field_xmlns } +end + RSpec.shared_context "with fields" do - include_context "with field" + include_context "with field objects" end -RSpec.shared_context "with excon driver" do +RSpec.shared_context "with excon parameters" do let(:excon_body) { Oj.dump(excon_response_hash) } let(:excon_headers) { {} } - let(:excon_response) { Excon::Response.new body: excon_body, headers: excon_headers, status: excon_status } let(:excon_status) { 200 } let(:excon_response_hash) { { "xmlns" => {}, "entries" => []}} let(:populated_excon_body) { Oj.dump(populated_excon_response_hash) } - let(:populated_excon_response) { Excon::Response.new body: populated_excon_body, headers: excon_headers, status: excon_status } let(:populated_excon_response_hash) { { "xmlns" => {}, "entries" => [ "id" => media_id]}} let(:headers) do { "Access-Control-Allow-Origin" => "*", @@ -92,18 +98,45 @@ end end -RSpec.shared_context "with page" do - include_context "with excon driver" - include_context "with media entries" - let(:page) { Cts::Mpx::Driver::Page.create page_parameters } +RSpec.shared_context "with excon objects" do + include_context "with excon parameters" + let(:excon_response) { Excon::Response.new body: excon_body, headers: excon_headers, status: excon_status } + let(:populated_excon_response) { Excon::Response.new body: populated_excon_body, headers: excon_headers, status: excon_status } +end + +RSpec.shared_context "with page parameters" do let(:page_parameters) { { xmlns: {}, entries: {} } } - let(:populated_page) { Cts::Mpx::Driver::Page.create populated_page_parameters } let(:populated_page_parameters) { media_entries.to_h } end -RSpec.shared_context "with request and response" do - include_context "with excon driver" - let(:request) { Cts::Mpx::Driver::Request.create method: :get, url: "http://access.auth.theplatform.com/data/Account/1" } +RSpec.shared_context "with page objects" do + include_context "with page parameters" + include_context "with excon objects" + include_context "with entries objects" + let(:page) { Cts::Mpx::Driver::Page.create page_parameters } + let(:populated_page) { Cts::Mpx::Driver::Page.create populated_page_parameters } +end + +RSpec.shared_context "with request and response objects" do + include_context "with request objects" + include_context "with response objects" +end + +RSpec.shared_context "with response objects" do + include_context "with excon objects" let(:response) { Cts::Mpx::Driver::Response.create original: excon_response } let(:populated_response) { Cts::Mpx::Driver::Response.create original: populated_excon_response } end + +RSpec.shared_context "with request objects" do + include_context "with excon objects" + let(:request) { Cts::Mpx::Driver::Request.create method: :get, url: "http://access.auth.theplatform.com/data/Account/1" } +end + +RSpec.shared_context "with empty objects" do + let(:entry) { Cts::Mpx::Entry.new } + let(:fields) { Cts::Mpx::Fields.new } + let(:query) { Cts::Mpx::Query.new } + let(:request) { Cts::Mpx::Driver::Request.new } + let(:response) { Cts::Mpx::Driver::Response.new } +end