Sha256: 42432ffb1b91cab03c715f9652915e3d594ef458fa9288a98ff382533026386e

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe Uatu::Connection do

  let(:resource) { 'characters' }
  let(:options) do
    {
      :format_type     => 'comic',
      :date_descriptor => 'lastWeek',
      :limit           => 20,
      :character_id    => '1009262'
    }
  end

  subject { described_class.new resource, options}

  describe '#params' do
    it 'prepares the options' do
      unrubified = subject.send(:params)

      expect(unrubified[:formatType]).to eq 'comic'
      expect(unrubified[:dateDescriptor]).to eq 'lastWeek'
      expect(unrubified[:limit]).to eq 20
      expect(unrubified[:characterId]).to eq nil
    end
  end

  describe '#path' do
    context 'single resource' do
      let(:options) { {} }
      let(:resource) { 'character' }
      it "should build normal routes just fine" do
        expect(subject.send(:path)).to eq "/v1/public/characters"
      end
    end

    context 'collection' do
      let(:options) { {} }
      let(:resource) { 'characters' }
      it "should build normal routes just fine" do
        expect(subject.send(:path)).to eq "/v1/public/characters"
      end
    end

    context 'with id' do
      let(:resource) { 'characters' }
      let(:options) { {character_id: '1009262'} }
      it "should build normal routes just fine" do
        expect(subject.send(:path)).to eq "/v1/public/characters/1009262"
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uatu-marvel-0.1.0 spec/uatu/connection_spec.rb