Sha256: 8cd00637e4f6680652a4378988d1cc1c18111716760b613cbf2ffb454975d5df

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

require 'frenetic/resource_mockery'

describe Frenetic::ResourceMockery do
  let(:my_temp_resource) do
    Class.new(Frenetic::Resource)
  end

  let(:my_mocked_resource) do
    Class.new(my_temp_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 }

  it 'should violate some basic CS principles by telling the parent-class of its existence' do
    expect(my_temp_resource.instance_variables).to include :@mock_class
  end

  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.6 spec/concerns/resource_mockery_spec.rb
frenetic-0.0.20.alpha.5 spec/concerns/resource_mockery_spec.rb