Sha256: 8ecd6f152eda2f85be1c569737cb14c954b00f2102b43420e9d795cfb4474240

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'helper'

describe MtGox::Client do
  before do
    @client = MtGox::Client.new
  end

  describe '#ticker' do
    before do
      stub_get('/code/data/ticker.php').
        to_return(:status => 200, :body => fixture('ticker.json'))
    end

    it "should fetch the ticker" do
      ticker = @client.ticker
      a_get('/code/data/ticker.php').should have_been_made
      ticker.last.should == 26.5
    end
  end

  describe '#asks' do
    before do
      stub_get('/code/data/getDepth.php').
        to_return(:status => 200, :body => fixture('depth.json'))
    end

    it "should fetch open asks" do
      asks = @client.asks
      a_get('/code/data/getDepth.php').should have_been_made
      asks.last.should == [45, 593.28]
    end
  end

  describe '#bids' do
    before do
      stub_get('/code/data/getDepth.php').
        to_return(:status => 200, :body => fixture('depth.json'))
    end

    it "should fetch open bids" do
      bids = @client.bids
      a_get('/code/data/getDepth.php').should have_been_made
      bids.last.should == [19.1, 1]
    end
  end

  describe '#trades' do
    before do
      stub_get('/code/data/getTrades.php').
        to_return(:status => 200, :body => fixture('trades.json'))
    end

    it "should fetch trades" do
      trades = @client.trades
      a_get('/code/data/getTrades.php').should have_been_made
      trades.last.date.should == Time.local(2011, 6, 8, 2, 51, 57)
      trades.last.price.should == 26.6099
      trades.last.amount.should == 1.37
      trades.last.tid.should == "129606"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mtgox-0.0.1 spec/mtgox/client_spec.rb