Sha256: c189067196f47232285924b7bc8a1da2d4dd6ddde1cfad38d4fd431a6bff7bcd

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

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

      ButterCMS::ButterResource.stub(:resource_path).
        and_return('')
    end

    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
    before do
      ButterCMS.stub(:token).and_return('test123')
      ButterCMS.stub(:request).and_return({"data" => {"attribute" => 'test'}})

      ButterCMS::ButterResource.stub(:resource_path).
        and_return('')
    end

    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

16 entries across 16 versions & 1 rubygems

Version Path
buttercms-ruby-1.2.0 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.1.3 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.1.2 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.1.1 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.1.0 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.10 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.9 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.8 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.7 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.6 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.5 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.4 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.3 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.2 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.1 spec/lib/buttercms/butter_resource_spec.rb
buttercms-ruby-1.0.0 spec/lib/buttercms/butter_resource_spec.rb