Sha256: 0bbccc4ca5b6bc4a046ea9adb0f58b70a1beceb778f556af007cf6fbb2ba3746

Contents?: true

Size: 978 Bytes

Versions: 7

Compression:

Stored size: 978 Bytes

Contents

require_relative '../../spec_helper'

describe Bitstampede::Net do
  let(:client){ double }
  subject { 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(subject.client).to eq(client)
  end

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

  it 'defers to its client for key' do
    expect(subject.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(subject.post('balance'))).to eq(json_parse(example_balance))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bitstampede-0.1.5 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.4 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.3 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.2 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.1 spec/unit/bitstampede/net_spec.rb
bitstampede-0.1.0 spec/unit/bitstampede/net_spec.rb
bitstampede-0.0.1 spec/unit/bitstampede/net_spec.rb