Sha256: 81907fb06d17e30a6a03b0393188e1cf90a72aa788720f98bc493507b8a4fe73

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module RailsBestPractices
  module Prepares
    describe HelperPrepare do
      let(:runner) { Core::Runner.new(prepares: described_class.new) }

      context 'methods' do
        it 'parses helper methods' do
          content = <<-EOF
          module PostsHelper
            def used; end
            def unused; end
          end
          EOF
          runner.prepare('app/helpers/posts_helper.rb', content)
          methods = Prepares.helper_methods
          expect(methods.get_methods('PostsHelper').map(&:method_name)).to eq(%w[used unused])
        end

        it 'parses helpers' do
          content = <<-EOF
          module PostsHelper
          end
          EOF
          runner.prepare('app/helpers/posts_helper.rb', content)
          content = <<-EOF
          module Admin::UsersHelper
          end
          EOF
          runner.prepare('app/helpers/users_helper.rb', content)
          content = <<-EOF
          module Admin
            module BaseHelper
            end
          end
          EOF
          runner.prepare('app/helpers/base_helper.rb', content)
          helpers = Prepares.helpers
          expect(helpers.map(&:to_s)).to eq(['PostsHelper', 'Admin::UsersHelper', 'Admin', 'Admin::BaseHelper'])
        end
      end
    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/prepares/helper_prepare_spec.rb
rails_best_practices-1.23.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.23.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.22.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.22.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.21.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.20.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb