Sha256: e71fe2f72b18cdfd5ffff8d1f20fe3ab1e5cc9e92f752eb84df471e1d1ff06af

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe ButterCMS::ButterResource do
  before do
    allow(ButterCMS).to receive(:token).and_return('test123')
    allow(ButterCMS).to receive(:request).and_return({"data" => [{"attribute" => 'test'}]})

    allow(ButterCMS::ButterResource).to receive(:resource_path).and_return('')
  end

  describe '.all' do

    it 'should make a request with the correct endpoint' do
      expect(ButterCMS).to receive(:request).with('/', {})
      ButterCMS::ButterResource.all()
    end

    it 'should return a collection' do
      objects = ButterCMS::ButterResource.all
      expect(objects).to be_a(ButterCMS::ButterCollection)
      expect(objects.first).to be_a(ButterCMS::ButterResource)
    end
  end

  describe '.find' do
    it 'should make a request with the correct endpoint' do
      expect(ButterCMS).to receive(:request).with('/1', {})
      ButterCMS::ButterResource.find(1)
    end

    it 'should return one object' do
      expect(ButterCMS::ButterResource.find(1)).to be_a(ButterCMS::ButterResource)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
buttercms-ruby-1.4 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.3.2 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.3.1 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.3.0 spec/lib/buttercms/butter_resource_spec.rb