Sha256: 8d9112e302b3f2e3e5e61caa51953037c839c145b4cf6afa30b4bef9e7e4c161

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

require 'message_helper'

shared_examples_for 'Alert message' do
  it { should be_an IB::Messages::Incoming::Alert }
  it { should be_warning }
  it { should_not be_error }
  its(:message_type) { should == :Alert }
  its(:message_id) { should == 4 }
  its(:version) { should == 2 }
  its(:data) { should == {:version=>2, :error_id=>-1, :code=>2104, :message=>"Market data farm connection is OK:cashfarm"} }
  its(:error_id) { should == -1 }
  its(:code) { should == 2104 }
  its(:message) { should =~ /Market data farm connection is OK/ }
  its(:to_human) { should =~ /TWS Warning/ }

  it 'has class accessors as well' do
    subject.class.message_id.should == 4
    subject.class.message_type.should == :Alert
  end
end

describe IB::Messages::Incoming do

  context 'Newly instantiated Message' do

    subject do
      IB::Messages::Incoming::Alert.new(
          :version => 2,
          :error_id => -1,
          :code => 2104,
          :message => 'Market data farm connection is OK:cashfarm')
    end

    it_behaves_like 'Alert message'
  end

  context 'Message received from IB', :connected => true do

    before(:all) do
      @ib = IB::Connection.new OPTS[:connection].merge(:logger => mock_logger)
      @ib.wait_for :Alert
    end

    after(:all) { close_connection }

    subject { @ib.received[:Alert].first }

    it_behaves_like 'Alert message'
  end #
end # describe IB::Messages:Incoming

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ib-ruby-0.7.0 spec/ib-ruby/messages/incoming_spec.rb
ib-ruby-0.6.1 spec/ib-ruby/messages/incoming_spec.rb