Sha256: e2b3e01a8a865962402e0bdeefc5ef914c2be79f01738a9c5d07bd7faeefed0d
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 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 self.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 'violates 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 'returns a hash of available properties' do expect(subject).to include 'foo' => 'fixnum' expect(subject).to include 'bar' => 'string' end end describe '#attributes' do subject { super().attributes } it 'returns a hash of the resources attributes' do expect(subject).to include 'foo' => 1 expect(subject).to include 'bar' => 'baz' expect(subject).to include 'qux' => 'qux' end end describe '.default_attributes' do let(:my_mocked_resource) { Class.new(my_temp_resource) } subject { MyNamespace::MyMockedResource.default_attributes } it 'allows implementors to specify sane defaults' do expect(subject).to eq Hash.new end end describe '#default_attributes' do let(:my_mocked_resource) { Class.new(my_temp_resource) } subject { MyNamespace::MyMockedResource.new.default_attributes } it 'proxies to the class method' do expect(subject).to eq Hash.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
frenetic-1.0.0.alpha.1 | spec/resource_mockery_spec.rb |