Skip to content

Commit

Permalink
leishman#3 - Merge into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Inkybro committed Mar 13, 2014
2 parents 9991202 + ac09c74 commit 038a413
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spec/kraken_key.rb
.project
Gemfile.lock
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ source 'https://rubygems.org'
gemspec
gem 'httparty'
gem 'hashie'
gem 'addressable'
39 changes: 0 additions & 39 deletions Gemfile.lock

This file was deleted.

Binary file modified kraken_ruby-0.2.1.gem
Binary file not shown.
1 change: 1 addition & 0 deletions kraken_ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
spec.files = spec.files - spec.files.grep(%r{\.gem$})
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
Expand Down
2 changes: 1 addition & 1 deletion lib/kraken_ruby/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'httparty'
require 'hashie'
require 'Base64'
require 'base64' # <--- had to change this from "require 'Base64'"; getting "load error"
require 'addressable/uri'


Expand Down
61 changes: 61 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require 'kraken_ruby'
require 'kraken_key'

describe Kraken::Client do

before :each do
# FIXME: perhaps it would be wiser or make more sense to implement
# this sleep within the actual library -- just not sure if that is
# a desired default behavior or if it's something that maybe should
# be left up to the developer using the library

sleep 0.3 # to prevent rapidly pinging the Kraken server
end

let(:kraken){ Kraken::Client.new(API_KEY, API_SECRET) }

context "public data" do
it "gets the proper server time" do
kraken_time = DateTime.parse(kraken.server_time.rfc1123)
utc_time = Time.now.getutc
expect(kraken_time.day).to eq utc_time.day
expect(kraken_time.hour).to eq utc_time.hour
end

it "gets list of tradeable assets" do
expect(kraken.assets).to respond_to :XLTC
end

it "gets list of asset pairs" do
expect(kraken.asset_pairs).to respond_to :XLTCXXDG
end

it "gets public ticker data for given asset pairs" do
result = kraken.ticker('XLTCXXDG, ZEURXXDG')
expect(result).to respond_to :XLTCXXDG
expect(result).to respond_to :ZEURXXDG
end

it "gets order book data for a given asset pair" do
order_book = kraken.order_book('XLTCXXDG')
expect(order_book.XLTCXXDG).to respond_to :asks
end

it "gets an array of trades data for a given asset pair" do
trades = kraken.trades('XLTCXXDG')
expect(trades.XLTCXXDG).to be_instance_of(Array)
end

it "gets an array of spread data for a given asset pair" do
spread = kraken.spread('XLTCXXDG')
expect(spread.XLTCXXDG).to be_instance_of(Array)
end
end

context "private data" do # More tests to come
it "gets the user's balance" do
expect(kraken.balance).to be_instance_of(Hash)
end
end

end

0 comments on commit 038a413

Please sign in to comment.