Sha256: ae47b08518794cd34eee2fee9fa1bf69311b5fe037d320b18211899a5f2e3458

Contents?: true

Size: 908 Bytes

Versions: 5

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

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

    it 'should get 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 'should check 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

5 entries across 5 versions & 1 rubygems

Version Path
rails_best_practices-1.20.0 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.19.5 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.19.4 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.19.3 spec/rails_best_practices/core/model_attributes_spec.rb
rails_best_practices-1.19.2 spec/rails_best_practices/core/model_attributes_spec.rb