Sha256: a7db2e6ee37128fe447220812092edf2863520440289b8d0af90acb41c7c9e0b

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe Sentimeta::Client do

  subject { Sentimeta::Client }

  let(:valid_url) { subject.generate_uri(:spheres) }


  describe :fetch do
    it { should respond_to :fetch }
  end


  describe :generate_uri do
    it "should return an instance of URI" do
      expect(valid_url).to be_kind_of URI
    end
  end


  describe :send_request do
    it "should be fine for a valid uri" do
      expect { subject.send_request valid_url }.not_to raise_error
    end

    it "should raise an error for invalid uri" do
      expect { subject.send_request "invalid" }.to raise_error Sentimeta::Error::Unreachable
    end
  end


  describe :endpoints do
    %i(criteria spheres objects catalog).each do |endpoint|
      it { should respond_to endpoint }

      it "##{endpoint} should call fetch once" do
        expect(subject).to receive(:fetch).and_call_original.once
        subject.public_send endpoint
      end

      it "##{endpoint} should return an array" do
        expect(subject.public_send endpoint).to be_kind_of Array
      end
    end

    it { should respond_to :prices }
    it("#prices should call fetch once") { pending }
    it("#prices should return an array") { pending }
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sentimeta-0.1.2 spec/client_spec.rb
sentimeta-0.1.0 spec/client_spec.rb
sentimeta-0.0.8 spec/client_spec.rb
sentimeta-0.0.7 spec/client_spec.rb
sentimeta-0.0.6 spec/client_spec.rb