spec/netsuite/configuration_spec.rb in netsuite-0.8.6 vs spec/netsuite/configuration_spec.rb in netsuite-0.8.7

- old
+ new

@@ -27,14 +27,16 @@ expect(config.filters).to eq([:special]) end end describe '#connection' do + EXAMPLE_ENDPOINT = 'https://1023.suitetalk.api.netsuite.com/services/NetSuitePort_2020_2' before(:each) do # reset clears out the password info config.email 'me@example.com' config.password 'me@example.com' + config.endpoint EXAMPLE_ENDPOINT config.account 1023 config.wsdl "my_wsdl" config.api_version "2012_2" end @@ -55,10 +57,23 @@ allow(config).to receive(:cached_wsdl) config.connection expect(config).to have_received(:cached_wsdl) end + + it 'sets the endpoint on the Savon client' do + # this is ugly/brittle, but it's hard to see how else to test this + savon_configs = config.connection.globals.instance_eval {@options} + expect(savon_configs.fetch(:endpoint)).to eq(EXAMPLE_ENDPOINT) + end + + it 'handles a nil endpoint' do + config.endpoint = nil + # this is ugly/brittle, but it's hard to see how else to test this + savon_configs = config.connection.globals.instance_eval {@options} + expect(savon_configs.fetch(:endpoint)).to eq(nil) + end end describe '#wsdl' do context 'when the wsdl has been set' do before do @@ -161,9 +176,26 @@ it 'handles an empty cache' do expect(config.wsdl_cache).to be_empty expect( config.cached_wsdl ).to eq nil end + end + end + + describe '#endpoint' do + it 'can be set with endpoint=' do + config.endpoint = 42 + expect(config.endpoint).to eq(42) + end + + it 'can be set with just endpoint(value)' do + config.endpoint(42) + expect(config.endpoint).to eq(42) + end + + it 'supports nil endpoints' do + config.endpoint = nil + expect(config.endpoint).to eq(nil) end end describe '#auth_header' do context 'when doing user authentication' do