Sha256: 50fd67e2fc76868ec03fd614c5c1e7d5a09c0a77bdc8edfe9b3f89a111a5a9cc

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

module RailsBestPractices::Core
  describe Klasses do
    it { should be_a_kind_of Array }

    context 'Klass' do
      context '#class_name' do
        it 'gets class name without module' do
          klass = Klass.new('BlogPost', 'Post', [])
          expect(klass.class_name).to eq('BlogPost')
        end

        it 'gets class name with moduel' do
          klass = Klass.new('BlogPost', 'Post', ['Admin'])
          expect(klass.class_name).to eq('Admin::BlogPost')
        end
      end

      context '#extend_class_name' do
        it 'gets extend class name without module' do
          klass = Klass.new('BlogPost', 'Post', [])
          expect(klass.extend_class_name).to eq('Post')
        end

        it 'gets extend class name with module' do
          klass = Klass.new('BlogPost', 'Post', ['Admin'])
          expect(klass.extend_class_name).to eq('Admin::Post')
        end
      end

      it 'gets to_s equal to class_name' do
        klass = Klass.new('BlogPost', 'Post', ['Admin'])
        expect(klass.to_s).to eq(klass.class_name)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_best_practices-1.19.1 spec/rails_best_practices/core/klasses_spec.rb