require 'order_helper' shared_examples_for 'OrderStatus message' do it { should be_an IB::Messages::Incoming::OrderStatus } its(:message_type) { should == :OrderStatus } its(:message_id) { should == 3 } its(:version) { should == 6 } its(:data) { should_not be_empty } its(:local_id) { should be_an Integer } its(:status) { should =~ /Submit/ } its(:to_human) { should =~ / 6, :order_state => { :local_id => 1313, :perm_id => 172323928, :client_id => 1111, :parent_id => 0, :status => 'PreSubmitted', :filled => 0, :remaining => 100, :average_fill_price => 0.0, :last_fill_price => 0.0, :why_held => 'child' } end it_behaves_like 'OrderStatus message' end context 'received from IB' do before(:all) do verify_account @ib = IB::Connection.new OPTS[:connection].merge(:logger => mock_logger) @ib.wait_for :NextValidId, 3 @local_id = @ib.next_local_id place_order IB::Symbols::Stocks[:wfc] @ib.wait_for 2 # OrderStatus for cancelled orders from previous specs arrives first :( end after(:all) { close_connection } # implicitly cancels order subject { @ib.received[:OrderStatus].find { |msg| msg.local_id == @local_id } } it_behaves_like 'OrderStatus message' end end # describe IB::Messages:Incoming