Sha256: 2577ea6494e398baddc72f1c246a11f7ffb74dc86b064bddf77617c4c0e6f5f9

Contents?: true

Size: 968 Bytes

Versions: 4

Compression:

Stored size: 968 Bytes

Contents

require_relative '../../spec_helper'

describe Bitstampede::Net do
  let(:client){ double }
  subject(:net) { described_class.new(client) }

  before do
    client.stub(:secret).and_return(1)
    client.stub(:key).and_return(2)
  end

  it 'gets instantiated with a client' do
    expect(net.client).to eq(client)
  end

  it 'defers to its client for secret' do
    expect(net.secret).to eq(1)
  end

  it 'defers to its client for key' do
    expect(net.key).to eq(2)
  end

  describe '#post' do
    describe 'any_endpoint' do
      let(:example_balance) do
        <<-JSON
          {
            "foo": "bar"
          }
        JSON
      end

      before do
        FakeWeb.register_uri(:post, "https://www.bitstamp.net/api/balance/", body: example_balance)
      end

      it "queries the appropriate endpoint and returns its body as a string" do
        expect(json_parse(net.post('balance'))).to eq(json_parse(example_balance))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bitstampede-0.1.9 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.8 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.7 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.6 spec/unit/bitstampede/net_spec.rb