# encoding: utf-8 # require 'spec_helper' describe Mode::Sdk do after :each do Mode::Sdk.reset end describe '.configure' do it 'sets configuration variables' do expect_any_instance_of( Mode::Sdk::Configuration).to receive(:setting=).once Mode::Sdk.configure do |config| config.setting = 'value' end end end describe '.config' do it 'instantiates and memoizes configuration instance' do expect(Mode::Sdk.instance_variable_get(:@config)).to be_nil expect(Mode::Sdk.config).to be_an_instance_of(Mode::Sdk::Configuration) config = Mode::Sdk.instance_variable_get(:@config) expect(config).to be_an_instance_of(Mode::Sdk::Configuration) end end describe '.account' do it 'returns account from client' do expect(Mode::Sdk::Client).to receive(:account).and_return( 'username' => 'someone') expect(Mode::Sdk.account).to eq('username' => 'someone') end end describe '.username' do it 'returns username from client' do expect(Mode::Sdk::Client).to receive(:account).and_return( 'username' => 'someone') expect(Mode::Sdk.username).to eq('someone') end end describe '.authenticated?' do it 'returns value from client' do expect(Mode::Sdk::Client).to receive(:authenticated?).and_return(true) expect(Mode::Sdk.authenticated?).to eq(true) end end end