Sha256: 9fe76bf80f652467083ad96918929db595fb4380925b3690238fbd127a711615

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Ey::Provisioner::Connection do
  subject    { Ey::Provisioner::Connection.new("tokenabc") }
  let(:http) { stub('http') }
  before     { Excon.expects(:new).with(Ey::Provisioner::Connection::EY_API_CLOUD_URL).returns(http) }

  let(:headers) do
    {
      'Accept' => 'application/json',
      'X-EY-Cloud-Token' => 'tokenabc',
      'Content-type' => 'application/json'
    }
  end

  describe "http_post" do
    let(:request) { stub('request') }
    before        { request.expects(:to_hash).returns(:test => 'data') }

    it "should post via HTTP to the API" do
      http.expects(:post).with(
        :body    => JSON(:request => { :test => 'data' }),
        :headers => headers,
        :path    => "/api/v2/testpath",
        :expects => [200, 201, 202]
      )
 
      subject.http_post("testpath", request)
    end
  end

  describe "environment" do
    it "should return an environment instance" do
      subject.environment(1234).should be_a(Ey::Provisioner::Environment)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ey-provisioner-1.0.3 spec/connection_spec.rb
ey-provisioner-1.0.2 spec/connection_spec.rb
ey-provisioner-1.0.1 spec/connection_spec.rb
ey-provisioner-1.0.0 spec/connection_spec.rb