bitstamp-2 0.4.1

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.
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bitstamp do
4
+
5
+ describe :sanity_check! do
6
+ context 'not properly configured' do
7
+ it { -> { Bitstamp.sanity_check! }.should raise_error }
8
+ end
9
+ context 'properly configured' do
10
+ before {
11
+ Bitstamp.setup do |config|
12
+ config.key = 'test'
13
+ config.secret = 'test'
14
+ config.client_id = 'test'
15
+ end
16
+ }
17
+ it { -> { Bitstamp.sanity_check! }.should_not raise_error }
18
+ end
19
+ end
20
+
21
+ describe :orders do
22
+ it { should respond_to :orders }
23
+ end
24
+
25
+ describe :ticket, vcr: {cassette_name: 'bitstamp/ticker'} do
26
+ subject { Bitstamp.ticker }
27
+ it { should be_kind_of Bitstamp::Ticker }
28
+ its(:high) { should == "124.90" }
29
+ its(:last) { should == "124.55" }
30
+ its(:timestamp) { should == "1380237724" }
31
+ its(:bid) { should == "124.55" }
32
+ its(:volume) { should == "7766.46908740" }
33
+ its(:low) { should == "123.00" }
34
+ its(:ask) { should == "124.56" }
35
+ end
36
+
37
+ describe :balance, vcr: {cassette_name: 'bitstamp/balance'} do
38
+ context "configured" do
39
+ subject { Bitstamp.balance }
40
+ before { setup_bitstamp }
41
+ it { should == {"btc_reserved"=>"0", "fee"=>"0.4000", "btc_available"=>"0", "usd_reserved"=>"1.02", "btc_balance"=>"0", "usd_balance"=>"6953.07", "usd_available"=>"6952.05"} }
42
+ end
43
+ context "not configured" do
44
+ it { expect { Bitstamp.balance }.to raise_exception(Bitstamp::MissingConfigExeception, "Bitstamp Gem not properly configured") }
45
+ end
46
+ end
47
+
48
+ describe :order_book, vcr: {cassette_name: 'bitstamp/order_book'} do
49
+ let(:order_book) { Bitstamp.order_book }
50
+ subject { order_book }
51
+ it { should be_kind_of Hash }
52
+ it { should have_key("asks") }
53
+ it { should have_key("bids") }
54
+ it { order_book["asks"].should be_kind_of Array }
55
+ it { order_book["bids"].should be_kind_of Array }
56
+ end
57
+
58
+ describe :withdraw_bitcoins do
59
+ before {setup_bitstamp}
60
+ context "Failed to supply correct arguments", vcr: {cassette_name: 'bitstamp/withdraw_bitcoins/wrong_arguments'} do
61
+ subject { Bitstamp.withdraw_bitcoins(amount:100) }
62
+ #its(:error) { should == "Required parameters not supplied, :amount, :address" }
63
+ end
64
+ context "Failed to withdraw bitcoins", vcr: {cassette_name: 'bitstamp/withdraw_bitcoins/failure'} do
65
+ subject { Bitstamp.withdraw_bitcoins(:amount=>100, :address=>"17Vr8d1yWrA226QNYZLDwaG4vDMUEaT9t5") }
66
+ it {should == {"error"=>{"amount"=>["You have only 0 BTC available. Check your account balance for details."]}}}
67
+ #its(:error) { should == "Required parameters not supplied, :amount, :address" }
68
+ end
69
+ # context "succesfully withdrew bitcoins", vcr: {cassette_name: 'bitstamp/withdraw_bitcoins/success'} do
70
+ # subject { Bitstamp.withdraw_bitcoins(:amount=>0.04976353, :address=>"17Vr8d1yWrA226QNYZLDwaG4vDMUEaT9t5") }
71
+ # it {should =='true'}
72
+ # #its(:error) { should == "Required parameters not supplied, :amount, :address" }
73
+ # end
74
+ end
75
+ describe :unconfirmed_user_deposits, vcr: {cassette_name: 'bitstamp/unconfirmed_user_deposits'} do
76
+ before {setup_bitstamp}
77
+ subject { Bitstamp.unconfirmed_user_deposits }
78
+ it {should be_kind_of Array}
79
+
80
+ end
81
+ #
82
+ # Works but for privacy reasons I dont want to include the cassette
83
+ #
84
+ # describe :bitcoin_deposit_address, vcr: {cassette_name: 'bitstamp/bitcoin_deposit_address'} do
85
+ # before {setup_bitstamp}
86
+ # subject {Bitstamp.bitcoin_deposit_address}
87
+ # #it {should match /^[13][a-zA-Z0-9]{26,33}$/} TODO:fix this spec
88
+ # end
89
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ class Bitstamp::Coin < Bitstamp::Model;end
4
+ class Bitstamp::Coins < Bitstamp::Collection;end
5
+
6
+ describe Bitstamp::Coins do
7
+ subject { Bitstamp::Coins.new }
8
+ its(:name) { should eq 'coin' }
9
+ its(:module) { should eq "bitstamp/coin" }
10
+ its(:model) { should be Bitstamp::Coin }
11
+ its(:path) { should eq "/api/coins" }
12
+ end
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.bitstamp.net/api/balance/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: key=BITSTAMP_KEY&nonce=1380237671&signature=67768DD1BBDF45203840CC8688847A2DF5D224CA15B3ABDDC804EA251AC12211
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: !binary |-
14
+ T0s=
15
+ headers:
16
+ !binary "U2VydmVy":
17
+ - !binary |-
18
+ Y2xvdWRmbGFyZS1uZ2lueA==
19
+ !binary "RGF0ZQ==":
20
+ - !binary |-
21
+ VGh1LCAyNiBTZXAgMjAxMyAyMzoyMToxOCBHTVQ=
22
+ !binary "Q29udGVudC1UeXBl":
23
+ - !binary |-
24
+ YXBwbGljYXRpb24vanNvbg==
25
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
26
+ - !binary |-
27
+ Y2h1bmtlZA==
28
+ !binary "Q29ubmVjdGlvbg==":
29
+ - !binary |-
30
+ a2VlcC1hbGl2ZQ==
31
+ !binary "U2V0LUNvb2tpZQ==":
32
+ - !binary |-
33
+ X19jZmR1aWQ9ZDg2ZTkzYTIxNzY5Y2UxZDQzODc2YzQ1N2ZjNTU3ZmNjMTM4
34
+ MDIzNzY3Nzk1ODsgZXhwaXJlcz1Nb24sIDIzLURlYy0yMDE5IDIzOjUwOjAw
35
+ IEdNVDsgcGF0aD0vOyBkb21haW49LmJpdHN0YW1wLm5ldA==
36
+ !binary "Q29udGVudC1MYW5ndWFnZQ==":
37
+ - !binary |-
38
+ ZW4=
39
+ !binary "RXhwaXJlcw==":
40
+ - !binary |-
41
+ VGh1LCAyNiBTZXAgMjAxMyAyMzoyMToxOCBHTVQ=
42
+ !binary "VmFyeQ==":
43
+ - !binary |-
44
+ QWNjZXB0LUxhbmd1YWdl
45
+ !binary "Q2FjaGUtQ29udHJvbA==":
46
+ - !binary |-
47
+ bWF4LWFnZT0w
48
+ !binary "TGFzdC1Nb2RpZmllZA==":
49
+ - !binary |-
50
+ VGh1LCAyNiBTZXAgMjAxMyAyMzoyMToxOCBHTVQ=
51
+ !binary "Q2YtUmF5":
52
+ - !binary |-
53
+ YjQzYjA4ZjM5ZDgwMDk3
54
+ body:
55
+ encoding: ASCII-8BIT
56
+ string: !binary |-
57
+ eyJidGNfcmVzZXJ2ZWQiOiAiMCIsICJmZWUiOiAiMC40MDAwIiwgImJ0Y19h
58
+ dmFpbGFibGUiOiAiMCIsICJ1c2RfcmVzZXJ2ZWQiOiAiMS4wMiIsICJidGNf
59
+ YmFsYW5jZSI6ICIwIiwgInVzZF9iYWxhbmNlIjogIjY5NTMuMDciLCAidXNk
60
+ X2F2YWlsYWJsZSI6ICI2OTUyLjA1In0=
61
+ http_version:
62
+ recorded_at: Thu, 26 Sep 2013 23:21:18 GMT
63
+ recorded_with: VCR 2.6.0