spec/orders_spec.rb in bitstamp-0.2.8 vs spec/orders_spec.rb in bitstamp-0.3.0
- old
+ new
@@ -1,19 +1,40 @@
require 'spec_helper'
describe Bitstamp::Orders do
- before :each do
- read_bitstamp_yaml
- end
+ before { setup_bitstamp }
- it "should return an array when querying for all orders" do
- Bitstamp.orders.all.should be_kind_of Array
+ describe :all, vcr: {cassette_name: 'bitstamp/orders/all'} do
+ subject { Bitstamp.orders.all }
+ it { should be_kind_of Array }
+ describe "first order" do
+ subject { Bitstamp.orders.all.first }
+ its(:price) { should == "1.01" }
+ its(:amount) { should == "1.00000000" }
+ its(:type) { should == 0 }
+ its(:datetime) { should == "2013-09-26 23:15:04" }
+ end
end
- it "should sell bitcoins" do
- Bitstamp.orders.sell(:amount => 1, :price => 1000)
+ describe :sell do
+ context "no permission found", vcr: {cassette_name: 'bitstamp/orders/sell/failure'} do
+ subject { Bitstamp.orders.sell(:amount => 1, :price => 1000) }
+ it { should be_kind_of Bitstamp::Order }
+ its(:error) { should == "No permission found" }
+ end
+ # context "bitcoins available", vcr: {cassette_name: 'bitstamp/orders/sell/success'} do
+ # subject { Bitstamp.orders.sell(:amount => 1, :price => 1000) }
+ # xit { should be_kind_of Bitstamp::Order }
+ # its(:error) { should be_nil }
+ # end
end
- it "should buy bitcoins" do
- Bitstamp.orders.buy(:amount => 1, :price => 1.01)
+ describe :buy, vcr: {cassette_name: 'bitstamp/orders/buy'} do
+ subject { Bitstamp.orders.buy(:amount => 1, :price => 1.01) }
+ it { should be_kind_of Bitstamp::Order }
+ its(:price) { should == "1.01" }
+ its(:amount) { should == "1" }
+ its(:type) { should == 0 }
+ its(:datetime) { should == "2013-09-26 23:26:56.849475" }
+ its(:error) { should be_nil }
end
end