spec/resource_mockery_spec.rb in frenetic-1.0.0.alpha.1 vs spec/resource_mockery_spec.rb in frenetic-1.0.0

- old
+ new

@@ -8,22 +8,42 @@ end let(:my_mocked_resource) do Class.new(my_temp_resource) do def self.default_attributes - { qux:'qux' } + { + qux: 'qux', + _embedded: { + embedded_resource: { + plugh: 'xyzzy' + } + } + } end end end + let(:params) do + { + foo: 1, + bar: 'baz', + _embedded: { + embedded_resource: { + grault: 'garply' + }, + another_resource: { + waldo: 'fred' + } + } + } + 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 @@ -42,28 +62,31 @@ 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' + expect(subject['_embedded']['embedded_resource']).to include 'plugh' => 'xyzzy' + expect(subject['_embedded']['embedded_resource']).to include 'grault' => 'garply' + expect(subject['_embedded']['another_resource']).to include 'waldo' => 'fred' 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 + expect(subject).to eq({}) 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 + expect(subject).to eq({}) end end -end \ No newline at end of file +end