Sha256: dec459a47ef30b972a044bccaafc36803c143313a7f9a4edbee39dcfe77f7931

Contents?: true

Size: 1.82 KB

Versions: 12

Compression:

Stored size: 1.82 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])

describe IB::Models::Order do

  let(:properties) do
    {:outside_rth => true,
     :open_close => 'C',
     :origin => IB::Models::Order::Origin_Firm,
     :transmit => false,
     :designated_location => "WHATEVER",
     :exempt_code => 123,
     :delta_neutral_order_type => "HACK",
     :what_if => true,
     :not_held => true}
  end

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

      it { should_not be_nil }
      its (:outside_rth) {should == false}
      its (:open_close) {should == "O"}
      its (:origin) {should == IB::Models::Order::Origin_Customer}
      its (:transmit) {should == true}
      its (:designated_location) {should == ''}
      its (:exempt_code) {should == -1}
      its (:delta_neutral_order_type) {should == ''}
      its (:what_if) {should == false}
      its (:not_held) {should == false}
      its (:created_at) {should be_a Time}
    end

    context 'with properties' do
      subject { IB::Models::Order.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::Models::Order.new
        x.outside_rth = true
        x.open_close = 'C'
        x.origin = IB::Models::Order::Origin_Firm
        x.transmit = false
        x.designated_location = "WHATEVER"
        x.exempt_code = 123
        x.delta_neutral_order_type = "HACK"
        x.what_if = true
        x.not_held = true
      }.to_not raise_error
    end
  end #instantiation

end # describe IB::Models::Order

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ib-ruby-0.5.15 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.14 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.13 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.12 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.11 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.10 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.9 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.7 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.2 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.5.0 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.4.22 spec/ib-ruby/models/order_spec.rb
ib-ruby-0.4.20 spec/ib-ruby/models/order_spec.rb