lib/intermodal/rspec/models/has_parent_resource.rb
def concerned_with_parent_resource(_parent_resource_name, options = {}, &blk)
          extra_get_examples = options[:extra_get_examples]

          context "when concerned with parent resource #{_parent_resource_name}" do
            let(:parent_resource_name) { _parent_resource_name }
            let(:parent_id_name) { "#{parent_resource_name}_id" }
            let(:parent_model) { parent_resource_name.to_s.camelize.constantize }
            let(:different_parent) { parent_model.make! }
            let(:parent_with_different_account) { parent_model.make!(:account => different_account) }

            instance_eval(&blk) if blk

            it { should belong_to _parent_resource_name } unless options[:skip_association_examples]
            it { should validate_presence_of _parent_resource_name } unless options[:skip_validation_examples]

            [ :by_parent_id, :by_parent, "by_#{_parent_resource_name}_id", "by_#{_parent_resource_name}" ].each do |scope|
              should_respond_to_scope(scope)
            end

            implements_get_interface_for_nested_resource(&extra_get_examples)
          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 concerned_with_parent_resource(_parent_resource_name, options = {}, &blk)
          extra_get_examples = options[:extra_get_examples]
          context "when concerned with parent resource #{_parent_resource_name}" do
            let(:parent_resource_name) { _parent_resource_name }
            let(:parent_id_name) { "#{parent_resource_name}_id" }
            let(:parent_model) { parent_resource_name.to_s.camelize.constantize }
            let(:different_parent) { parent_model.make! }
            let(:parent_with_different_account) { parent_model.make!(:account => different_account) }
            instance_eval(&blk) if blk
            it { should belong_to _parent_resource_name } unless options[:skip_association_examples]
            it { should validate_presence_of _parent_resource_name } unless options[:skip_validation_examples]
            [ :by_parent_id, :by_parent, "by_#{_parent_resource_name}_id", "by_#{_parent_resource_name}" ].each do |scope|
              should_respond_to_scope(scope)
            end
            implements_get_interface_for_nested_resource(&extra_get_examples)
          end
        end
def concerned_with_parent_resource ( _parent_resource_name , options = { } , & blk ) extra_get_examples = options [ :extra_get_examples ] context "when concerned with parent resource #{_parent_resource_name}" do let ( :parent_resource_name ) { _parent_resource_name } let ( :parent_id_name ) { "#{parent_resource_name}_id" } let ( :parent_model ) { parent_resource_name . to_s . camelize . constantize } let ( :different_parent ) { parent_model . make! } let ( :parent_with_different_account ) { parent_model . make! ( :account => different_account ) } instance_eval ( & blk ) if blk it { should belong_to _parent_resource_name } unless options [ :skip_association_examples ] it { should validate_presence_of _parent_resource_name } unless options [ :skip_validation_examples ] [ :by_parent_id , :by_parent , "by_#{_parent_resource_name}_id" , "by_#{_parent_resource_name}" ] . each do | scope | should_respond_to_scope ( scope ) end implements_get_interface_for_nested_resource ( & extra_get_examples ) end end
NOTE: I am cheating.
NOTE : I am cheating .
_parent_resource_name
options
blk