Sha256: 63256c23d027b75565790745dd018534655fdd3af1ddc9a90a7933594e35abd4

Contents?: true

Size: 890 Bytes

Versions: 7

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices::Core
  describe ModelAttributes do
    let(:model_attributes) { described_class.new }

    before do
      model_attributes.add_attribute('Post', 'title', :string)
      model_attributes.add_attribute('Post', 'user_id', :integer)
    end

    it 'gets model attributes' do
      expect(model_attributes.get_attribute_type('Post', 'title')).to eq(:string)
      expect(model_attributes.get_attribute_type('Post', 'user_id')).to eq(:integer)
      expect(model_attributes.get_attribute_type('Post', 'unknonw')).to be_nil
    end

    it 'checks is model attributes' do
      expect(model_attributes.is_attribute?('Post', 'title')).to be true
      expect(model_attributes.is_attribute?('Post', 'user_id')).to be true
      expect(model_attributes.is_attribute?('Post', 'unknonw')).to be false
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_best_practices-1.23.2 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.23.1 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.23.0 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.22.1 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.22.0 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.21.0 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.20.1 spec/rails_best_practices/core/model_attributes_spec.rb