Skip to content

Commit

Permalink
Rails integration specs for Order, Contract and ContractDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
arvicco committed Aug 11, 2012
1 parent c7e6139 commit cb61258
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/views/ib/contract_details/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@

<br />

<%= link_to 'New Contract detail', new_contract_detail_path %>
<%= link_to 'New Contract Detail', new_contract_detail_path %>
2 changes: 1 addition & 1 deletion app/views/ib/contract_details/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>New contract_detail</h1>
<h1>New Contract Detail</h1>

<%= render 'form' %>

Expand Down
4 changes: 0 additions & 4 deletions app/views/ib/contracts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@
<%= f.label :right %><br />
<%= f.text_field :right %>
</div>
<div class="field">
<%= f.label :type %><br />
<%= f.text_field :type %>
</div>
<div class="actions">
<%= f.submit %>
</div>
Expand Down
44 changes: 44 additions & 0 deletions rails_spec/integration/contract_detail_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require 'spec_helper'

describe "ContractDetails" do

it "creating a new one" do
visit contract_details_path
click_link "New Contract Detail"
fill_in "Market name", :with => 'AAPL'
fill_in "Trading class", :with => 'AAPL'
fill_in "Min tick", :with => 0.02
fill_in "Price magnifier", :with => 100
fill_in "Order types", :with => 'ACTIVETIM,ADJUST,ALERT,ALGO,ALLOC,AON,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,FOK,GAT,GTC,GTD,GTT,HID,ICE,IOC,LIT,LMT,MIT,MKT,MTL,NONALGO,OCA,PAON,POSTONLY,RELSTK,SCALE,SCALERST,SMARTSTG,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF'
fill_in "Valid exchanges", :with => 'SMART,AMEX,BATS,BOX,CBOE,CBOE2,IBSX,ISE,MIBSX,NASDAQOM,PHLX,PSE'
fill_in "Under con", :with => 265598
fill_in "Long name", :with => 'APPLE INC'
fill_in "Contract month", :with => '201301'
fill_in "Industry", :with => 'Technology'
fill_in "Category", :with => 'Computers'
fill_in "Subcategory", :with => 'Computers'
fill_in "Time zone", :with => 'EST'
fill_in "Trading hours", :with => '20120422:0930-1600;20120423:0930-1600'
fill_in "Liquid hours", :with => '20120422:0930-1600;20120423:0930-1600'
click_button "Create Contract detail"

within "#notice" do
page.should have_content("Contract detail was successfully created.")
end
# p (page.methods-Object.methods).sort
# p page.body
page.should have_content("AAPL")
page.should have_content("0.02")
page.should have_content("100")
page.should have_content("ACTIVETIM,ADJUST,ALERT,ALGO,ALLOC,AON,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,FOK,GAT,GTC,GTD,GTT,HID,ICE,IOC,LIT,LMT,MIT,MKT,MTL,NONALGO,OCA,PAON,POSTONLY,RELSTK,SCALE,SCALERST,SMARTSTG,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF")
page.should have_content("SMART,AMEX,BATS,BOX,CBOE,CBOE2,IBSX,ISE,MIBSX,NASDAQOM,PHLX,PSE")
page.should have_content("265598")
page.should have_content("APPLE INC")
page.should have_content("201301")
page.should have_content("Technology")
page.should have_content("Computers")
page.should have_content("EST")
page.should have_content("20120422:0930-1600;20120423:0930-1600")

end
end
35 changes: 35 additions & 0 deletions rails_spec/integration/contract_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'

describe "Contracts" do

it "creating a new one" do
visit contracts_path
click_link "New Contract"
fill_in "Multiplier", :with => 131313
fill_in "Strike", :with => 620.22
fill_in "Right", :with => 'P'
fill_in "Symbol", :with => 'AAPL'
fill_in "Currency", :with => 'USD'
fill_in "Exchange", :with => 'SMART'
fill_in "Sec type", :with => 'OPT'
fill_in "Sec", :with => 'US0378331005' # "Sec id" ?
fill_in "Sec id type", :with => 'ISIN'
click_button "Create Contract"

within "#notice" do
page.should have_content("Contract was successfully created.")
end
# p (page.methods-Object.methods).sort
# p page.body
page.should have_content("131313")
page.should have_content("620.22")
page.should have_content("put")
page.should have_content("AAPL")
page.should have_content("USD")
page.should have_content("SMART")
page.should have_content("option")
page.should have_content("US0378331005")
page.should have_content("ISIN")

end
end
27 changes: 27 additions & 0 deletions rails_spec/integration/order_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'spec_helper'

describe "Orders" do

it "creating a new one" do
visit orders_path
click_link "New Order"
fill_in "Contract", :with => 131313
fill_in "Limit price", :with => 11.22
fill_in "Order type", :with => 'STPLMT'
fill_in "Side", :with => 'B'
check "Transmit"
click_button "Create Order"

within "#notice" do
page.should have_content("Order was successfully created.")
end
# p (page.methods-Object.methods).sort
# p page.body
page.should have_content("131313")
page.should have_content("11.22")
page.should have_content("stop_limit")
page.should have_content("buy")
page.should have_content("true")

end
end

0 comments on commit cb61258

Please sign in to comment.