Sha256: f7a7d4ba13d616f7d240eb38bd789f0c8f47b09224b4599a175a5426d5bd1b8d

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

# coding: utf-8
require 'spec_helper'

describe Evostream::Client do
  subject {
    Evostream::Client.new(:host => 'somehost', :path_prefix => '/some_path')
  }

  it "should respond to an empty liststreams" do
    stub_request(:get, "http://somehost:80/some_path/liststreams").
      to_return(:body => '{"data":null,"description":"","status":"SUCCESS"}')
    subject.liststreams.should be_nil
  end

  it "should respond to a non empty liststreams" do
    liststreams = '{"data":[{"appName": "evostreamms"}],"description":"Available streams","status":"SUCCESS"}'
    stub_request(:get, "http://somehost:80/some_path/liststreams").
      to_return(:body => liststreams)
    subject.liststreams.should == JSON.parse(liststreams)['data']
  end

  it "should respond to a non implemented method" do
    stub_request(:get, "http://somehost:80/some_path/liststreams").
      to_return(:body => '{"data":null,"description":"command non_existant_service not known. Type help for list of commands","status":"FAIL"}')
    expect { subject.non_existant_service }.to raise_error
  end

  it "should encode params with base64" do
    stub_request(:get, "http://somehost:80/some_path/some_service?params=Zmlyc3RfcGFyYW09eHh4IHNlY29uZF9wYXJhbT14eHg=").
      to_return(:body => '{"data":null,"description":"","status":"SUCCESS"}')
    subject.some_service(:first_param => 'xxx', :second_param => 'xxx').should be_nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
evostream-0.0.2 spec/client_spec.rb
evostream-0.0.1 spec/client_spec.rb