require 'spec_helper' describe RubyEcommClient::Client do before do use_test = [:qa, :production].include?(RubyEcommClient::Client.environment) @shopper_id = use_test ? '261639' : '923518' @low_tree_id = '2402' @downgrade_tree_id = '2402' @current_tree_id = '2410' @upgrade_tree_id = '2418' @resource_type = 'outright' @resource_id = use_test ? 'd5e2ead3-c1c4-11e3-9ea5-005056953ce3' : 'b6be6fd0-c1a5-11e3-8e42-0050569575d8' @client = RubyEcommClient::Client.new(@shopper_id, @resource_type, @resource_id) end context '#initialize' do it 'require shopper_id non-nil' do expect { RubyEcommClient::Client.new(nil, @resource_type, @resource_id) }.to raise_error(ArgumentError) end it 'require shopper_id non-blank' do expect { RubyEcommClient::Client.new('', @resource_type, @resource_id) }.to raise_error(ArgumentError) end it 'require resource_type non-nil' do expect { RubyEcommClient::Client.new(@shopper_id, nil, @resource_id) }.to raise_error(ArgumentError) end it 'require resource_type non-blank' do expect { RubyEcommClient::Client.new(@shopper_id, '', @resource_id) }.to raise_error(ArgumentError) end it 'require resource_id non-nil' do expect { RubyEcommClient::Client.new(@shopper_id, @resource_type, nil) }.to raise_error(ArgumentError) end it 'require resource_id non-blank' do expect { RubyEcommClient::Client.new(@shopper_id, @resource_type, '') }.to raise_error(ArgumentError) end it 'set shopper_id' do @client.shopper_id.should eq(@shopper_id) end it 'set resource_type' do @client.resource_type.should eq(@resource_type) end it 'set resource_id' do @client.resource_id.should eq(@resource_id) end end context '#express_checkout?' do it 'must relay' do RubyEcommClient::ServiceProfile.any_instance.should_receive(:express_checkout?).once @client.express_checkout? end end context '#account_info' do it 'must relay' do RubyEcommClient::ServiceManager.any_instance.should_receive(:account_info).with(1).once @client.account_info(1) end end context '#transitions' do it 'must relay' do RubyEcommClient::ServiceManager.any_instance.should_receive(:transitions).with(1).once @client.transitions(1) end end context '#find_transition' do it 'must relay' do RubyEcommClient::ServiceManager.any_instance.should_receive(:find_transition).with([], 1).once @client.find_transition([], 1) end end context '#request_change_via_manager' do it 'must relay' do RubyEcommClient::ServiceManager.any_instance.should_receive(:request_change_via_manager).with(1).once @client.request_change_via_manager(1) end end context '#request_change_via_express' do it 'must relay' do RubyEcommClient::ServicePurchase.any_instance.should_receive(:request_change_via_express).with(1, '10.0.1.1').once @client.request_change_via_express(1, '10.0.1.1') end end context '#request_change' do it 'must relay' do RubyEcommClient::ServicePurchase.any_instance.should_receive(:request_change).with(1, '10.0.1.1').once @client.request_change(1, '10.0.1.1') end end end