Sha256: f5447feb04b2551882f7a53250fd77eda8518395d7900abb8041055fb682ae04

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

      context 'methods' do
        it 'should parse 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 'should parse 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

5 entries across 5 versions & 1 rubygems

Version Path
rails_best_practices-1.20.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.19.5 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.19.4 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.19.3 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.19.2 spec/rails_best_practices/prepares/helper_prepare_spec.rb