Sha256: 4e3afe1a332da4ccbb147dd37b1e160f85410cfad72015badbe93bc208e4ca7e

Contents?: true

Size: 866 Bytes

Versions: 7

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices::Core
  describe Modules do
    it { is_expected.to be_a_kind_of Array }

    context 'Modules' do
      before do
        @mod = Mod.new('PostsHelper', [])
      end
      subject { described_class.new.tap { |modules| modules << @mod } }
      it 'adds descendant to the corresponding module' do
        expect(@mod).to receive(:add_descendant).with('PostsController')
        subject.add_module_descendant('PostsHelper', 'PostsController')
      end
    end

    context 'Mod' do
      subject do
        Mod.new('UsersHelper', ['Admin']).tap do |mod|
          mod.add_descendant('Admin::UsersController')
        end
      end
      it { expect(subject.to_s).to eq('Admin::UsersHelper') }
      it { expect(subject.descendants).to eq(['Admin::UsersController']) }
    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/modules_spec.rb
rails_best_practices-1.23.1 spec/rails_best_practices/core/modules_spec.rb
rails_best_practices-1.23.0 spec/rails_best_practices/core/modules_spec.rb
rails_best_practices-1.22.1 spec/rails_best_practices/core/modules_spec.rb
rails_best_practices-1.22.0 spec/rails_best_practices/core/modules_spec.rb
rails_best_practices-1.21.0 spec/rails_best_practices/core/modules_spec.rb
rails_best_practices-1.20.1 spec/rails_best_practices/core/modules_spec.rb