Sha256: 395be906e018aaffc6388ee8239eb7a9cedd846af6424fb4223e030cb9dbca63

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

require 'spec_helper'
require 'nested_validator'

shared_context 'nested validator' do
  let(:parent_class) do
    opts = options
    Class.new {
      include ActiveModel::Validations

      attr_accessor :child, :other

      instance_eval "validates :child, nested: #{opts}"

      def initialize(child=nil)
        self.child = child
        self.other = ''
      end

      def to_s
        'parent'
      end
    }
  end

  let(:options) { 'true' }

  let(:child_class) do
    Class.new {
      include ActiveModel::Validations

      attr_accessor :attribute, :attribute2, :attribute3

      validates :attribute, presence: true
      validates :attribute2, presence: true
      validates :attribute3, presence: true

      def self.model_name
        ActiveModel::Name.new(self, nil, 'temp')
      end
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nested_validator-1.0.6 spec/lib/nested_validator/nested_validator_context.rb
nested_validator-1.0.5 spec/lib/nested_validator/nested_validator_context.rb