Sha256: 905eb4f66e8bc13bc80bac68ee5fc198eb543ad721774c04e1d8ff7f537becc6

Contents?: true

Size: 1.05 KB

Versions: 57

Compression:

Stored size: 1.05 KB

Contents

require 'rails_helper'

describe 'ActiveRecord::Base models' do
  ActiveRecord::Base.descendants.map(&:to_s).reject { |m| %w(Delayed::Backend::ActiveRecord::Job).include?(m) }.each do |model_name|
    model = model_name.constantize
    describe model do
      it 'should be an ActiveRecord::Base' do
        expect(ActiveRecord::Base.descendants).to include(model)
      end

      it 'should be instanciable' do
        instance = model.new
        expect(instance).to be_a(model)
      end

      it 'should be valid with correct attribute values' do
        instance = create(model.to_s.tableize.singularize.underscore.tr('/', '_'))
        expect(instance.valid?).to be_truthy
      end

      it 'should not be valid with empty attributes' do
        instance = model.new
        expect(instance.valid?).to be_falsey
      end

      it 'should save with valid attributes' do
        instance = create(model.to_s.tableize.singularize.underscore.tr('/', '_'))
        expect(instance.save).to be_truthy
        expect(instance).to be_persisted
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

Version Path
cmor_user_area-0.0.51.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.50.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.49.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.48.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.45.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.44.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.43.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.42.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.41.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.40.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.39.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.38.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.37.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.36.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.35.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.34.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.33.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.32.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.31.pre spec/models~/generic_spec.rb
cmor_user_area-0.0.30.pre spec/models~/generic_spec.rb