lib/intermodal/rspec/models/has_parent_resource.rb
def implements_get_interface_for_nested_resource(&blk)
          implements_get_interface do

            context 'by parent' do
              it 'should find resource scoped to parent' do
                model.get(subject.id, :parent => subject.send(parent_resource_name)).should eql(subject)
              end

              it 'should find resource scoped to parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id).should eql(subject)
              end

              it 'should find writeable resource scoped to parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id).should_not be_readonly
              end
            end

            context 'by parent and account' do
              it 'should find resource scoped to account id and parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id, :account_id => account.id).should eql(subject)
              end

              it 'should find writeable resource scoped to account id and parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id, :account_id => account.id).should_not be_readonly
              end

              it 'should not find resource scoped to a different parent' do
                model.get(subject.id, :parent => different_parent).should be_nil
              end

              it 'should not find resource scoped to a different parent id' do
                model.get(subject.id, :parent_id => different_parent.id).should be_nil
              end

              it 'should not find resource scoped to a parent in a different account' do
                model.get(subject.id, :parent_id => parent_with_different_account.id, :account_id => account).should be_nil
              end

              it 'should not find resource scoped to a correct parent but incorrect account' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id, :account_id => different_account).should be_nil
              end
            end

            instance_eval(&blk) if blk
          end
        end
# NOTE: I am cheating. It assumes if the class method is defined then
# it is a scope
I am cheating. It assumes if the class method is defined then
it is a scope
I am cheating . It assumes if the class method is defined then it is a scope
def implements_get_interface_for_nested_resource(&blk)
          implements_get_interface do
            context 'by parent' do
              it 'should find resource scoped to parent' do
                model.get(subject.id, :parent => subject.send(parent_resource_name)).should eql(subject)
              end
              it 'should find resource scoped to parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id).should eql(subject)
              end
              it 'should find writeable resource scoped to parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id).should_not be_readonly
              end
            end
            context 'by parent and account' do
              it 'should find resource scoped to account id and parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id, :account_id => account.id).should eql(subject)
              end
              it 'should find writeable resource scoped to account id and parent id' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id, :account_id => account.id).should_not be_readonly
              end
              it 'should not find resource scoped to a different parent' do
                model.get(subject.id, :parent => different_parent).should be_nil
              end
              it 'should not find resource scoped to a different parent id' do
                model.get(subject.id, :parent_id => different_parent.id).should be_nil
              end
              it 'should not find resource scoped to a parent in a different account' do
                model.get(subject.id, :parent_id => parent_with_different_account.id, :account_id => account).should be_nil
              end
              it 'should not find resource scoped to a correct parent but incorrect account' do
                model.get(subject.id, :parent_id => subject.send(parent_resource_name).id, :account_id => different_account).should be_nil
              end
            end
            instance_eval(&blk) if blk
          end
        end
def implements_get_interface_for_nested_resource ( & blk ) implements_get_interface do context 'by parent' do it 'should find resource scoped to parent' do model . get ( subject . id , :parent => subject . send ( parent_resource_name ) ) . should eql ( subject ) end it 'should find resource scoped to parent id' do model . get ( subject . id , :parent_id => subject . send ( parent_resource_name ) . id ) . should eql ( subject ) end it 'should find writeable resource scoped to parent id' do model . get ( subject . id , :parent_id => subject . send ( parent_resource_name ) . id ) . should_not be_readonly end end context 'by parent and account' do it 'should find resource scoped to account id and parent id' do model . get ( subject . id , :parent_id => subject . send ( parent_resource_name ) . id , :account_id => account . id ) . should eql ( subject ) end it 'should find writeable resource scoped to account id and parent id' do model . get ( subject . id , :parent_id => subject . send ( parent_resource_name ) . id , :account_id => account . id ) . should_not be_readonly end it 'should not find resource scoped to a different parent' do model . get ( subject . id , :parent => different_parent ) . should be_nil end it 'should not find resource scoped to a different parent id' do model . get ( subject . id , :parent_id => different_parent . id ) . should be_nil end it 'should not find resource scoped to a parent in a different account' do model . get ( subject . id , :parent_id => parent_with_different_account . id , :account_id => account ) . should be_nil end it 'should not find resource scoped to a correct parent but incorrect account' do model . get ( subject . id , :parent_id => subject . send ( parent_resource_name ) . id , :account_id => different_account ) . should be_nil end end instance_eval ( & blk ) if blk end end
NOTE: I am cheating.
NOTE : I am cheating .
blk