diff --git a/spec/netsuite/configuration_spec.rb b/spec/netsuite/configuration_spec.rb index 7b48a0c6..a6d0920f 100644 --- a/spec/netsuite/configuration_spec.rb +++ b/spec/netsuite/configuration_spec.rb @@ -29,10 +29,12 @@ 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" @@ -57,6 +59,19 @@ 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 @@ -166,6 +181,23 @@ 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 before do