|
4 | 4 |
|
5 | 5 | RSpec.describe IB::Messages::Incoming::ContractData do |
6 | 6 |
|
| 7 | + before(:all) do |
| 8 | + establish_connection |
| 9 | + end |
| 10 | + |
| 11 | + after(:all) { close_connection } |
| 12 | + |
7 | 13 | context IB::Stock do |
8 | 14 | before(:all) do |
9 | | - establish_connection |
10 | 15 | ib = IB::Connection.current |
11 | | - ib.send_message :RequestContractDetails, contract: IB::Contract.new( sec_type: 'STK', symbol: 'GE', currency: 'USD', exchange:'SMART' ) |
| 16 | + ib.send_message :RequestContractDetails, contract: IB::Stock.new( symbol: 'GE', currency: 'USD', exchange:'SMART' ) |
12 | 17 | ib.wait_for :ContractDetailsEnd |
13 | 18 | end |
14 | 19 |
|
15 | | - after(:all) { close_connection } |
| 20 | + after(:all){ IB::Connection.current.clear_received :ContractData } |
| 21 | + |
16 | 22 |
|
17 | 23 | # it_behaves_like 'ContractData Message' do |
18 | 24 | # let( :the_message ){ IB::Connection.current.received[:ContractData].first } |
19 | 25 | # end |
| 26 | + context "Basics" do |
| 27 | + subject{ IB::Connection.current.received[:ContractData].contract.last } |
20 | 28 |
|
21 | | - it "inspects" do # debugging |
22 | | - ib = IB::Connection.current |
23 | | - contract = ib.received[:ContractData].contract.last |
24 | | - contract_details = ib.received[:ContractData].contract_details.last |
25 | | - |
26 | | - puts contract.inspect |
27 | | - puts contract_details.inspect |
| 29 | + it_behaves_like 'a complete Contract Object' |
| 30 | + its( :sec_type ){is_expected.to eq :stock} |
| 31 | + its( :symbol ){is_expected.to eq 'GE'} |
| 32 | + its( :con_id ){is_expected.to eq 7516} |
28 | 33 | end |
29 | 34 |
|
| 35 | + context "received a single contract" do |
| 36 | + subject{ IB::Connection.current.received[:ContractData] } |
| 37 | + it{ is_expected.to be_a Array } |
| 38 | + its(:size){is_expected.to eq 1 } |
| 39 | + end |
30 | 40 | end |
| 41 | + |
| 42 | + |
31 | 43 | end # describe IB::Messages:Incoming |
32 | 44 |
|
0 commit comments