Sha256: b96f34069242d230a9492d020cf0042bbca925fb03c72e1d0400d04e3b934fb2

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

describe "Toolbox Units" do
  context "basic request executing" do
    before do
      stub_request(:get, /#{TheBigDB.api_host}\/v#{TheBigDB.api_version}\/toolbox\/units\/convert/).to_return(:body => '{"server_says": "hello world"}')

      @request = TheBigDB::Toolbox::Unit(:convert, :value => "100 ly", :new_unit => "cm")
    end

    it "sets the correct data_sent instance variable" do
      @request.data_sent.should == {
          "headers" => Hash[@request.http_request.to_hash.map{|k,v| [k, v.join] }],
          "host" => TheBigDB.api_host,
          "port" => TheBigDB.api_port,
          "path" => "/v#{TheBigDB.api_version}/toolbox/units/convert",
          "method" => "GET",
          "params" => {"value" => "100 ly", "new_unit" => "cm"}
        }
    end

    it "sets the correct data_received instance variable" do
      @request.data_received.should include({
          "headers" => Hash[@request.http_response.to_hash.map{|k,v| [k, v.join] }],
          "content" => {"server_says" => "hello world"}
        })
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thebigdb-1.1.0 spec/resources/toolbox_spec.rb
thebigdb-1.0.0 spec/resources/toolbox_spec.rb