fin 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY +4 -0
- data/README.rdoc +5 -5
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/fin.rb +2 -5
- data/lib/fin/book.rb +2 -2
- data/lib/fin/book_manager.rb +1 -1
- data/lib/fin/changed_list.rb +1 -1
- data/lib/fin/container_list.rb +10 -1
- data/lib/fin/deal_list.rb +2 -2
- data/lib/fin/models/deal.rb +44 -50
- data/lib/fin/models/instrument.rb +39 -57
- data/lib/fin/models/model.rb +112 -16
- data/lib/fin/models/money_limit.rb +29 -58
- data/lib/fin/models/order.rb +51 -26
- data/lib/fin/models/position.rb +13 -36
- data/lib/fin/models/quote.rb +40 -0
- data/lib/fin/quote_list.rb +17 -0
- data/lib/version.rb +1 -1
- data/spec/fin/book_spec.rb +17 -17
- data/spec/fin/deal_list_spec.rb +3 -3
- data/spec/fin/models/deal_spec.rb +49 -117
- data/spec/fin/models/instrument_spec.rb +32 -34
- data/spec/fin/models/model_spec.rb +215 -75
- data/spec/fin/models/money_limit_spec.rb +48 -119
- data/spec/fin/models/order_spec.rb +29 -48
- data/spec/fin/models/position_spec.rb +34 -55
- data/spec/fin/models/quote_spec.rb +73 -0
- data/spec/fin/models/shared_examples.rb +84 -3
- data/spec/fin/order_list_spec.rb +12 -12
- data/spec/fin/shared_examples.rb +1 -1
- data/tasks/common.rake +2 -2
- data/tasks/spec.rake +1 -1
- data/tasks/version.rake +7 -7
- metadata +6 -3
- data/lib/fin/order_list.rb +0 -17
@@ -2,45 +2,16 @@ require 'spec_helper'
|
|
2
2
|
require 'fin/models/shared_examples'
|
3
3
|
|
4
4
|
describe Fin::Instrument do
|
5
|
+
let(:model_class_id) { 12 }
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
describe '#new with empty initializer' do
|
9
|
-
subject { Fin::Instrument.new }
|
10
|
-
|
11
|
-
its (:id) {should == nil} # replId
|
12
|
-
its (:rev) {should == nil} # replRev
|
13
|
-
its (:isin_id) {should == nil}
|
14
|
-
its (:isin) {should == nil}
|
15
|
-
its (:short_isin) {should == nil}
|
16
|
-
its (:sess_id) {should == nil}
|
17
|
-
its (:session) {should == nil}
|
18
|
-
end
|
7
|
+
shared_examples_for 'instrument_with_set_properties' do
|
19
8
|
|
9
|
+
its (:session_id) {should == 1213}
|
10
|
+
it_behaves_like 'model'
|
20
11
|
|
21
|
-
|
22
|
-
subject { Fin::Instrument.new :id => 12,
|
23
|
-
:rev => 123,
|
24
|
-
:isin_id => 1234567,
|
25
|
-
:isin => 'symbolic isin',
|
26
|
-
:short_isin => 'short isin',
|
27
|
-
:name => 'name',
|
28
|
-
:sess_id => 1213,
|
29
|
-
}
|
30
|
-
|
31
|
-
its (:isin_id) {should == 1234567}
|
32
|
-
its (:isin) {should == 'symbolic isin'}
|
33
|
-
its (:short_isin) {should == 'short isin'}
|
34
|
-
its (:name) {should == 'name'}
|
35
|
-
its (:id) {should == 12}
|
36
|
-
its (:rev) {should == 123}
|
37
|
-
its (:sess_id) {should == 1213}
|
38
|
-
its (:sess) {should == 1213}
|
39
|
-
|
40
|
-
describe '#to_s, #inspect' do
|
12
|
+
describe '#to_s' do
|
41
13
|
it 'is just right' do
|
42
14
|
subject.to_s.should == "name:short isin[symbolic isin]"
|
43
|
-
subject.inspect.should == "name:short isin[symbolic isin]"
|
44
15
|
end
|
45
16
|
end
|
46
17
|
|
@@ -50,5 +21,32 @@ describe Fin::Instrument do
|
|
50
21
|
end
|
51
22
|
end
|
52
23
|
end
|
24
|
+
|
25
|
+
describe '#new with empty initializer' do
|
26
|
+
let(:property_hash) { {} }
|
27
|
+
subject { Fin::Instrument.new }
|
28
|
+
|
29
|
+
it_behaves_like 'model'
|
30
|
+
|
31
|
+
it 'has all nil properties' do
|
32
|
+
subject.class.attribute_types.each { |prop, _| subject.send(prop).should == nil }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#new with opts' do
|
37
|
+
let(:property_hash) do
|
38
|
+
{:repl_id => 12,
|
39
|
+
:rev => 123,
|
40
|
+
:isin_id => 1234567,
|
41
|
+
:isin => 'symbolic isin',
|
42
|
+
:short_isin => 'short isin',
|
43
|
+
:name => 'name',
|
44
|
+
:sess_id => 1213,
|
45
|
+
}
|
46
|
+
end
|
47
|
+
subject { Fin::Instrument.new property_hash }
|
48
|
+
it_behaves_like 'instrument_with_set_properties'
|
49
|
+
|
50
|
+
end
|
53
51
|
end
|
54
52
|
|
@@ -2,108 +2,248 @@ require 'spec_helper'
|
|
2
2
|
require 'fin/models/shared_examples'
|
3
3
|
|
4
4
|
describe Fin::Model do
|
5
|
+
let(:model_class_id) { 0 }
|
6
|
+
let(:property_hash) { {} }
|
7
|
+
|
5
8
|
it_behaves_like 'model'
|
6
9
|
end
|
7
10
|
|
8
11
|
describe Fin::Model, "as a base class for BD models" do
|
9
12
|
let(:model_class) { Class.new(Fin::Model) }
|
10
|
-
let(:model_item) {model_class.new}
|
11
|
-
|
13
|
+
let(:model_item) { model_class.new }
|
14
|
+
|
15
|
+
describe 'Class inheriting from Model' do
|
16
|
+
it 'has pre-defined replID, replRev, replAct properties' do
|
17
|
+
expect do
|
18
|
+
model_item.replID
|
19
|
+
model_item.repl_id
|
20
|
+
model_item.replRev
|
21
|
+
model_item.repl_rev
|
22
|
+
model_item.rev
|
23
|
+
model_item.replAct
|
24
|
+
model_item.repl_act
|
25
|
+
end.to_not raise_error
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.property' do
|
30
|
+
it 'creates attr_accessor in a model class, given a String or Symbol' do
|
31
|
+
model_class.instance_eval do
|
32
|
+
property :foo => :i4, 'bar' => :i4
|
33
|
+
end
|
34
|
+
model_item.should respond_to :foo
|
35
|
+
model_item.should respond_to :foo=
|
36
|
+
model_item.should respond_to :bar
|
37
|
+
model_item.should respond_to :bar=
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'creates attr_accessor with aliases in a model class, given an Array' do
|
41
|
+
model_class.instance_eval do
|
42
|
+
property [:foo, 'bar', :baz] => :i4
|
43
|
+
end
|
44
|
+
model_item.should respond_to :foo=
|
45
|
+
model_item.should respond_to :bar=
|
46
|
+
model_item.should respond_to :baz=
|
47
|
+
model_item.should respond_to :foo
|
48
|
+
model_item.should respond_to :bar
|
49
|
+
model_item.should respond_to :baz
|
50
|
+
model_item.foo = 1313
|
51
|
+
model_item.foo.should == 1313
|
52
|
+
model_item.bar.should == 1313
|
53
|
+
model_item.baz.should == 1313
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'accepts a mix of Symbols and Arrays' do
|
57
|
+
model_class.instance_eval do
|
58
|
+
property :foo => :i4, ['bar', :baz] => :i4
|
59
|
+
end
|
60
|
+
model_item.should respond_to :foo=
|
61
|
+
model_item.should respond_to :bar=
|
62
|
+
model_item.should respond_to :baz=
|
63
|
+
model_item.should respond_to :foo
|
64
|
+
model_item.should respond_to :bar
|
65
|
+
model_item.should respond_to :baz
|
66
|
+
model_item.foo = 1313
|
67
|
+
model_item.foo.should == 1313
|
68
|
+
model_item.bar.should_not == 1313
|
69
|
+
model_item.baz.should_not == 1313
|
70
|
+
model_item.bar = 42
|
71
|
+
model_item.foo.should == 1313
|
72
|
+
model_item.bar.should == 42
|
73
|
+
model_item.baz.should == 42
|
74
|
+
end
|
75
|
+
end # describe '.property'
|
12
76
|
|
13
|
-
|
14
|
-
|
77
|
+
describe ' model subclasses tracking' do
|
78
|
+
describe '.model_class_id' do
|
79
|
+
it 'sets/accesses uniform class identifier for this class' do
|
80
|
+
model_class.model_class_id.should be_nil
|
15
81
|
model_class.instance_eval do
|
16
|
-
|
82
|
+
model_class_id 1313
|
17
83
|
end
|
18
|
-
|
19
|
-
|
20
|
-
model_item.should respond_to :bar
|
21
|
-
model_item.should_not respond_to :bar=
|
84
|
+
model_class.model_class_id.should == 1313
|
85
|
+
model_class.model_class_id.should == 1313
|
22
86
|
end
|
23
87
|
|
24
|
-
it '
|
88
|
+
it 'adds class identifier to list of model classes' do
|
25
89
|
model_class.instance_eval do
|
26
|
-
|
90
|
+
model_class_id 1313
|
91
|
+
end
|
92
|
+
Fin::Model.model_classes[1313].should == model_class
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'is 0 for Fin::Model itself' do
|
96
|
+
Fin::Model.model_class_id.should == 0
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '.model_classes' do
|
101
|
+
it 'contains at least a reference to Fin::Model itself' do
|
102
|
+
Fin::Model.model_classes.should have_value Fin::Model
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with mock record' do
|
110
|
+
let(:rec) do # Mocks raw OLE record received through P2ClientGate callback
|
111
|
+
mock('record').tap do |mock|
|
112
|
+
mock.stub(:GetValAsString) do |field|
|
113
|
+
case field
|
114
|
+
when 'replID'
|
115
|
+
'11'
|
116
|
+
when 'replRev'
|
117
|
+
'12'
|
118
|
+
when 'replAct'
|
119
|
+
'13'
|
120
|
+
when 'longint'
|
121
|
+
'1322222222455664'
|
122
|
+
when 'name'
|
123
|
+
'rec_name'
|
124
|
+
when 'time'
|
125
|
+
'rec_time'
|
126
|
+
when 'price'
|
127
|
+
'16.7'
|
128
|
+
when 'net'
|
129
|
+
'89.89'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
mock.stub(:GetValAsLong) do |field|
|
133
|
+
case field
|
134
|
+
when 'foo'
|
135
|
+
14
|
136
|
+
when 'bar'
|
137
|
+
15
|
138
|
+
end
|
27
139
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '.from_record' do
|
144
|
+
it 'creates new model object' do
|
145
|
+
object = model_class.from_record(rec)
|
146
|
+
object.should be_a_kind_of model_class
|
147
|
+
end
|
148
|
+
|
149
|
+
it ' extracts attributes from raw (OLE) record' do
|
150
|
+
object = model_class.from_record(rec)
|
151
|
+
object.replID.should == 11
|
152
|
+
object.repl_id.should == 11
|
153
|
+
object.replRev.should == 12
|
154
|
+
object.repl_rev.should == 12
|
155
|
+
object.replAct.should == 13
|
156
|
+
object.repl_act.should == 13
|
38
157
|
end
|
39
158
|
|
40
|
-
it '
|
159
|
+
it 'is created by property macro based on defined properties' do
|
41
160
|
model_class.instance_eval do
|
42
|
-
|
161
|
+
property :foo => :i4, ['bar', :baz] => :i1
|
43
162
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
model_item.instance_variable_set(:@foo, 1313)
|
51
|
-
model_item.foo.should == 1313
|
52
|
-
model_item.bar.should_not == 1313
|
53
|
-
model_item.baz.should_not == 1313
|
54
|
-
model_item.instance_variable_set(:@bar, 42)
|
55
|
-
model_item.foo.should == 1313
|
56
|
-
model_item.bar.should == 42
|
57
|
-
model_item.baz.should == 42
|
163
|
+
rec.should_receive(:GetValAsLong).with('foo').and_return(14)
|
164
|
+
rec.should_receive(:GetValAsLong).with('bar').and_return(15)
|
165
|
+
object = model_class.from_record(rec)
|
166
|
+
object.foo.should == 14
|
167
|
+
object.bar.should == 15
|
168
|
+
object.baz.should == 15
|
58
169
|
end
|
59
|
-
end # describe '.prop_reader'
|
60
170
|
|
61
|
-
|
62
|
-
it 'creates attr_accessor in a model class, given a String or Symbol' do
|
171
|
+
it 'calling property macro twice still generates a valid extractor' do
|
63
172
|
model_class.instance_eval do
|
64
|
-
|
173
|
+
property :foo => :i4
|
174
|
+
property ['bar', :baz] => :i1
|
65
175
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
176
|
+
object = model_class.from_record(rec)
|
177
|
+
object.repl_id.should == 11
|
178
|
+
object.repl_rev.should == 12
|
179
|
+
object.repl_act.should == 13
|
180
|
+
object.foo.should == 14
|
181
|
+
object.bar.should == 15
|
182
|
+
object.baz.should == 15
|
70
183
|
end
|
71
184
|
|
72
|
-
it '
|
185
|
+
it 'extracts properties of all types correctly' do
|
73
186
|
model_class.instance_eval do
|
74
|
-
|
187
|
+
property :foo => :i4, :bar => :i1, :longint => :i8,
|
188
|
+
:name => :c4, :time => :t,
|
189
|
+
:price => :'d3.1', :net => :f
|
75
190
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
191
|
+
object = model_class.from_record(rec)
|
192
|
+
object.repl_id.should == 11
|
193
|
+
object.repl_rev.should == 12
|
194
|
+
object.repl_act.should == 13
|
195
|
+
object.foo.should == 14
|
196
|
+
object.bar.should == 15
|
197
|
+
object.longint.should == 1322222222455664
|
198
|
+
object.name.should == 'rec_name'
|
199
|
+
object.time.should == 'rec_time'
|
200
|
+
object.price.should be_within(0.0001).of(16.7)
|
201
|
+
object.net.should be_within(0.0001).of(89.89)
|
86
202
|
end
|
203
|
+
end # from_record
|
87
204
|
|
88
|
-
|
205
|
+
context 'serialization' do
|
206
|
+
before do
|
89
207
|
model_class.instance_eval do
|
90
|
-
|
208
|
+
model_class_id 1313
|
209
|
+
property :foo => :i4, :bar => :i1, :longint => :i8,
|
210
|
+
:name => :c4, :time => :t,
|
211
|
+
:price => :'d3.1', :net => :f
|
91
212
|
end
|
92
|
-
model_item.should respond_to :foo=
|
93
|
-
model_item.should respond_to :bar=
|
94
|
-
model_item.should respond_to :baz=
|
95
|
-
model_item.should respond_to :foo
|
96
|
-
model_item.should respond_to :bar
|
97
|
-
model_item.should respond_to :baz
|
98
|
-
model_item.foo = 1313
|
99
|
-
model_item.foo.should == 1313
|
100
|
-
model_item.bar.should_not == 1313
|
101
|
-
model_item.baz.should_not == 1313
|
102
|
-
model_item.bar = 42
|
103
|
-
model_item.foo.should == 1313
|
104
|
-
model_item.bar.should == 42
|
105
|
-
model_item.baz.should == 42
|
106
213
|
end
|
107
|
-
|
108
|
-
|
214
|
+
|
215
|
+
describe '.from_msg' do
|
216
|
+
it 'allows restoration of original object from serializable data' do
|
217
|
+
msg = model_class.to_msg(rec)
|
218
|
+
object = model_class.from_msg(msg)
|
219
|
+
object.repl_id.should == 11
|
220
|
+
object.repl_rev.should == 12
|
221
|
+
object.repl_act.should == 13
|
222
|
+
object.foo.should == 14
|
223
|
+
object.bar.should == 15
|
224
|
+
object.longint.should == 1322222222455664
|
225
|
+
object.name.should == 'rec_name'
|
226
|
+
object.time.should == 'rec_time'
|
227
|
+
object.price.should be_within(0.0001).of(16.7)
|
228
|
+
object.net.should be_within(0.0001).of(89.89)
|
229
|
+
end
|
230
|
+
end # from_msg
|
231
|
+
|
232
|
+
describe '.to_msg', 'Class method!' do
|
233
|
+
it 'converts RECORD into serializable representation' do
|
234
|
+
model_class.to_msg(rec).should ==
|
235
|
+
[1313, 11, 12, 13, 14, 15, 1322222222455664, "rec_name", "rec_time", 16.7, 89.89]
|
236
|
+
end
|
237
|
+
end # to_msg
|
238
|
+
|
239
|
+
describe '#to_msg', 'Instance method!' do
|
240
|
+
it 'converts OBJECT into serializable representation' do
|
241
|
+
object = model_class.from_record(rec)
|
242
|
+
object.to_msg.should ==
|
243
|
+
[1313, 11, 12, 13, 14, 15, 1322222222455664, "rec_name", "rec_time", 16.7, 89.89]
|
244
|
+
end
|
245
|
+
end # to_msg
|
246
|
+
|
247
|
+
end #serialization
|
248
|
+
end # with mock record
|
109
249
|
end
|
@@ -2,134 +2,19 @@ require 'spec_helper'
|
|
2
2
|
require 'fin/models/shared_examples'
|
3
3
|
|
4
4
|
describe Fin::MoneyLimit do
|
5
|
+
let(:model_class_id) { 13 }
|
5
6
|
|
6
|
-
|
7
|
+
shared_examples_for 'limit_with_set_properties' do
|
7
8
|
|
8
|
-
|
9
|
-
subject { Fin::MoneyLimit.new }
|
10
|
-
|
11
|
-
its (:repl_id) {should == nil} # replId
|
12
|
-
its (:repl_rev) {should == nil} # replRev
|
13
|
-
its (:client_code) {should == nil}
|
14
|
-
its (:money_old) {should == nil}
|
15
|
-
its (:money_amount) {should == nil}
|
16
|
-
its (:money_free) {should == nil}
|
17
|
-
its (:money_blocked) {should == nil}
|
18
|
-
its (:pledge_old) {should == nil}
|
19
|
-
its (:pledge_amount) {should == nil}
|
20
|
-
its (:pledge_free) {should == nil}
|
21
|
-
its (:pledge_blocked) {should == nil}
|
22
|
-
its (:vm_reserve) {should == nil}
|
23
|
-
its (:vm_intercl) {should == nil}
|
24
|
-
its (:fee) {should == nil}
|
25
|
-
its (:fee_reserve) {should == nil}
|
26
|
-
its (:limit_spot_buy) {should == nil}
|
27
|
-
its (:limit_spot_buy_used) {should == nil}
|
28
|
-
its (:coeff_go) {should == nil}
|
29
|
-
its (:coeff_liquidity) {should == nil}
|
30
|
-
its (:is_auto_update_limit) {should == nil}
|
31
|
-
its (:is_auto_update_spot_limit) {should == nil}
|
32
|
-
its (:no_fut_discount) {should == nil}
|
33
|
-
its (:limits_set) {should == nil}
|
34
|
-
its (:premium) {should == nil}
|
35
|
-
its (:premium_order_reserve) {should == nil}
|
36
|
-
|
37
|
-
# client_code c7 ��� �������
|
38
|
-
# money_old d26.2 ����� �� ������ ������
|
39
|
-
# money_amount d26.2 ����� �����
|
40
|
-
# money_free d26.2 �������� �����
|
41
|
-
# money_blocked d26.2 ������������� �����
|
42
|
-
#
|
43
|
-
# pledge_old d26.2 ������� �� ������ ������
|
44
|
-
# pledge_amount d26.2 ����� �������
|
45
|
-
# pledge_free d26.2 �������� �������
|
46
|
-
# pledge_blocked d26.2 ������������� �������
|
47
|
-
#
|
48
|
-
# vm_reserve d26.2 �����, ����������������� ��� ������������� ������������ �����
|
49
|
-
# vm_intercl d26.2 ������������ �����, ��������� ��� ���������� � ����. �������
|
50
|
-
#
|
51
|
-
# fee d26.2 ��������� ����
|
52
|
-
# fee_reserve d26.2 ��������������� ������ ����� ��� ������
|
53
|
-
#
|
54
|
-
# limit_spot_buy d26.2 ����� �� ������� ������.
|
55
|
-
# limit_spot_buy_used d26.2 �������������� ����� �� ������� ������
|
56
|
-
#
|
57
|
-
# coeff_go d16.5 ����������� ����������� ��
|
58
|
-
# coeff_liquidity d16.5 ����������� �����������
|
59
|
-
#
|
60
|
-
# is_auto_update_limit i1 ������� �������������� ��������� ������ �� ��������
|
61
|
-
# ������ ��� ������� ����� ��������: 0-���, 1-������.
|
62
|
-
# is_auto_update_spot_limit i1 ������� �������������� ��������� ������� �� ������
|
63
|
-
# (�� �������, � �� �������) ��� ������� ����� ��������:
|
64
|
-
# 0-���, 1-������.
|
65
|
-
# no_fut_discount i1 ���������� ������������� ������ �� ���������: 1-������, 0-���.
|
66
|
-
# limits_set i1 ������� ��������� �������. 0 � ������ �����������
|
67
|
-
# premium d26.2 ������
|
68
|
-
# premium_order_reserve f ������ ������ ��� ������
|
69
|
-
end
|
9
|
+
it_behaves_like 'model'
|
70
10
|
|
71
|
-
|
72
|
-
subject { Fin::MoneyLimit.new :repl_id => 12,
|
73
|
-
:repl_rev => 123,
|
74
|
-
:client_code => '1234',
|
75
|
-
:money_old => 1234,
|
76
|
-
:money_amount => 12345,
|
77
|
-
:money_free => 123456,
|
78
|
-
:money_blocked => 1,
|
79
|
-
:pledge_old => 12,
|
80
|
-
:pledge_amount => 123,
|
81
|
-
:pledge_free => 1234,
|
82
|
-
:pledge_blocked => 12345,
|
83
|
-
:vm_reserve => 123456,
|
84
|
-
:vm_intercl => 1,
|
85
|
-
:fee => 12,
|
86
|
-
:fee_reserve => 123,
|
87
|
-
:limit_spot_buy => 1234,
|
88
|
-
:limit_spot_buy_used => 12345,
|
89
|
-
:coeff_go => 123456,
|
90
|
-
:coeff_liquidity => 1,
|
91
|
-
:is_auto_update_limit => 1,
|
92
|
-
:is_auto_update_spot_limit => 0,
|
93
|
-
:no_fut_discount => 1,
|
94
|
-
:limits_set => 1,
|
95
|
-
:premium => 123,
|
96
|
-
:premium_order_reserve => 1234,
|
97
|
-
}
|
98
|
-
|
99
|
-
its (:repl_id) {should == 12} # replId
|
100
|
-
its (:repl_rev) {should == 123} # replRev
|
101
|
-
its (:client_code) {should == '1234'}
|
102
|
-
its (:money_old) {should == 1234}
|
103
|
-
its (:money_amount) {should == 12345}
|
104
|
-
its (:money_free) {should == 123456}
|
105
|
-
its (:money_blocked) {should == 1}
|
106
|
-
its (:pledge_old) {should == 12}
|
107
|
-
its (:pledge_amount) {should == 123}
|
108
|
-
its (:pledge_free) {should == 1234}
|
109
|
-
its (:pledge_blocked) {should == 12345}
|
110
|
-
its (:vm_reserve) {should == 123456}
|
111
|
-
its (:vm_intercl) {should == 1}
|
112
|
-
its (:fee) {should == 12}
|
113
|
-
its (:fee_reserve) {should == 123}
|
114
|
-
its (:limit_spot_buy) {should == 1234}
|
115
|
-
its (:limit_spot_buy_used) {should == 12345}
|
116
|
-
its (:coeff_go) {should == 123456}
|
117
|
-
its (:coeff_liquidity) {should == 1}
|
118
|
-
its (:is_auto_update_limit) {should == 1}
|
119
|
-
its (:is_auto_update_spot_limit) {should == 0}
|
120
|
-
its (:no_fut_discount) {should == 1}
|
121
|
-
its (:limits_set) {should == 1}
|
122
|
-
its (:premium) {should == 123}
|
123
|
-
its (:premium_order_reserve) {should == 1234}
|
124
|
-
|
125
|
-
describe '#to_s, #inspect' do
|
11
|
+
describe '#to_s' do
|
126
12
|
it 'is just right' do
|
127
13
|
right = "Money: Old 1234 Amt 12345 Free 123456 Blck 1 " +
|
128
14
|
"Pledge: Old 12 Amt 123 Free 1234 Blck 12345 " +
|
129
15
|
"VM: Reserve 123456 Intercl 1 Fee: 12 Reserve 123 " +
|
130
16
|
"Limit Spot: Buy 1234 Used 12345"
|
131
17
|
subject.to_s.should == right
|
132
|
-
subject.inspect.should == right
|
133
18
|
end
|
134
19
|
end
|
135
20
|
|
@@ -139,5 +24,49 @@ describe Fin::MoneyLimit do
|
|
139
24
|
end
|
140
25
|
end
|
141
26
|
end
|
27
|
+
|
28
|
+
describe '#new with empty initializer' do
|
29
|
+
let(:property_hash) { {} }
|
30
|
+
subject { Fin::MoneyLimit.new }
|
31
|
+
|
32
|
+
it_behaves_like 'model'
|
33
|
+
|
34
|
+
it 'has all nil properties' do
|
35
|
+
subject.class.attribute_types.each { |prop, _| subject.send(prop).should == nil }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#new with opts' do
|
40
|
+
let(:property_hash) do
|
41
|
+
{:repl_id => 12,
|
42
|
+
:repl_rev => 123,
|
43
|
+
:client_code => '1234',
|
44
|
+
:money_old => 1234,
|
45
|
+
:money_amount => 12345,
|
46
|
+
:money_free => 123456,
|
47
|
+
:money_blocked => 1,
|
48
|
+
:pledge_old => 12,
|
49
|
+
:pledge_amount => 123,
|
50
|
+
:pledge_free => 1234,
|
51
|
+
:pledge_blocked => 12345,
|
52
|
+
:vm_reserve => 123456,
|
53
|
+
:vm_intercl => 1,
|
54
|
+
:fee => 12,
|
55
|
+
:fee_reserve => 123,
|
56
|
+
:limit_spot_buy => 1234,
|
57
|
+
:limit_spot_buy_used => 12345,
|
58
|
+
:coeff_go => 123456,
|
59
|
+
:coeff_liquidity => 1,
|
60
|
+
:is_auto_update_limit => 1,
|
61
|
+
:is_auto_update_spot_limit => 0,
|
62
|
+
:no_fut_discount => 1,
|
63
|
+
:limits_set => 1,
|
64
|
+
:premium => 123,
|
65
|
+
:premium_order_reserve => 1234,
|
66
|
+
}
|
67
|
+
end
|
68
|
+
subject { Fin::MoneyLimit.new property_hash }
|
69
|
+
it_behaves_like 'limit_with_set_properties'
|
70
|
+
end
|
142
71
|
end
|
143
72
|
|