Sha256: d2f9e52849d6a9027b26420fad8089f1ba9282c329b19e6c643416a71c5a63a1

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe IB::Models::ComboLeg do

  let(:properties) do
    {:con_id => 123,
     :ratio=> 1234,
     :action => 'BUY',
     :exchange => 'BLAH',
     :open_close => IB::ComboLeg::OPEN,
     :short_sale_slot => 1,
     :designated_location => 'BLEH',
     :exempt_code => 12}
  end

  context "instantiation" do
    context 'empty without properties' do
      subject { IB::ComboLeg.new }

      it { should_not be_nil }
      its(:con_id) {should == 0}
      its(:open_close) {should == 0}
      its(:short_sale_slot) {should == 0}
      its(:designated_location) {should == ''}
      its(:exempt_code) {should == -1}

      its(:created_at) {should be_a Time}
    end

    context 'with properties' do
      subject { IB::ComboLeg.new properties }

      it 'sets properties right' do
        properties.each do |name, value|
          subject.send(name).should == value
        end
      end

      context 'essential properties are still set, even if not given explicitely' do
        its(:created_at) {should be_a Time}
      end
    end

    it 'allows setting attributes' do
      expect {
        x = IB::ComboLeg.new
        properties.each do |name, value|
          subject.send("#{name}=", value)
          subject.send(name).should == value
        end
      }.to_not raise_error
    end
  end #instantiation

end # describe IB::Models::Contract::ComboLeg

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ib-ruby-0.7.4 spec/ib-ruby/models/combo_leg_spec.rb