Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlaprade authored and iloveitaly committed Mar 4, 2021
1 parent 75bac9d commit 41afd80
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/netsuite/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 41afd80

Please sign in to comment.