Sha256: c3f0c225eddafec4044b2763a4a0bcc97f24d08746aa8e09083a0c2c680e4f17

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

require 'frenetic/resource_mockery'

describe Frenetic::ResourceMockery do
  let(:my_mocked_resource) do
    Class.new(Frenetic::Resource) do
      def default_attributes
        { qux:'qux' }
      end
    end
  end

  before do
    stub_const 'MyNamespace::MyMockedResource', my_mocked_resource

    MyNamespace::MyMockedResource.send :include, described_class
  end

  let(:params) { { foo:1, bar:'baz' } }

  subject { MyNamespace::MyMockedResource.new params }

  describe '#properties' do
    subject { super().properties }

    it 'should return a hash of available properties' do
      subject.should include 'foo' => 'fixnum'
      subject.should include 'bar' => 'string'
    end
  end

  describe '#attributes' do
    subject { super().attributes }

    it 'should return a hash of the resources attributes' do
      subject.should include 'foo' => 1
      subject.should include 'bar' => 'baz'
      subject.should include 'qux' => 'qux'
    end
  end

  describe '#default_attributes' do
    it 'should allow implementors to specify sane defaults' do
      subject.qux.should == 'qux'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frenetic-0.0.20.alpha.4 spec/concerns/resource_mockery_spec.rb
frenetic-0.0.20.alpha.3 spec/concerns/resource_mockery_spec.rb