Sha256: 81c3705138338e81bf0f45d931b1dbba78e1ec752e5e548b822b1756c3b24508

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper.rb'

describe Reviewed::Utils do

  class MockUtils < Reviewed::Base; end

  describe 'object_from_response' do
    use_vcr_cassette "utils/object"

    let(:article_id) { '509d166d60de7db97c05ce71' }

    it 'returns an object of the correct class' do
      response = MockUtils.object_from_response(:get, "articles/#{article_id}")
      response.should be_an_instance_of(MockUtils)
    end
  end

  describe 'collection_from_response' do
    use_vcr_cassette "utils/collection"

    it 'returns a collection object' do
      collection = MockUtils.collection_from_response(:get, "articles")
      collection.should be_an_instance_of(Reviewed::Collection)
    end

    it 'returns objects of the correct class' do
      collection = MockUtils.collection_from_response(:get, "articles")
      collection.items.each do |obj|
        obj.should be_an_instance_of(MockUtils)
      end
    end
  end

  describe 'from_response' do

    it 'returns a new object from a response' do
      MockUtils.from_response({}).should be_an_instance_of(MockUtils) 
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reviewed-0.0.8 spec/utils_spec.rb
reviewed-0.0.7 spec/utils_spec.rb