Sha256: a43fa0ca78f1c6a135a6490f4f378ee9c40aba16ea4d287daf4de4b30e7cb923

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
require 'fin/models/shared_examples'

describe Fin::Position do
  let(:model_class_id) { 15 }

  shared_examples_for 'position_with_set_properties' do
    it_behaves_like 'model'

    describe '#to_s' do
      it 'is just right' do
        subject.to_s.should == "12[1234567] 12344, open: 12345, buys: 1212, sells: 1213"
      end
    end

    describe '#index' do
      it 'should be equal to isin_id' do
        subject.index.should == subject.isin_id
      end
    end
  end

  describe '#new with empty initializer' do
    let(:property_hash) { {} }
    subject { Fin::Position.new }

    it_behaves_like 'model'

    it 'has all nil properties' do
      subject.class.attribute_types.each { |prop, _| subject.send(prop).should == nil }
    end
  end

  describe '#new with opts' do
    let(:property_hash) do
      {:isin_id => 1234567,
       :repl_id => 12,
       :repl_rev => 123,
       :client_code => 'fz1234',
       :open_qty => 12345,
       :buys_qty => 1212,
       :sells_qty => 1213,
       :pos => 12344,
       :net_volume_rur => 123456,
       :last_deal_id => 654321,

      }
    end
    subject { Fin::Position.new property_hash }
    it_behaves_like 'position_with_set_properties'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fin-0.1.6 spec/fin/models/position_spec.rb
fin-0.1.5 spec/fin/models/position_spec.rb
fin-0.1.4 spec/fin/models/position_spec.rb
fin-0.1.3 spec/fin/models/position_spec.rb
fin-0.1.2 spec/fin/models/position_spec.rb