Sha256: 555a6b4bad732af1cbf786c5a9c8888e8aa12a070000a078311d5235994751e0

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Reviews
    describe RemoveEmptyHelpersReview do
      let(:runner) { Core::Runner.new(reviews: RemoveEmptyHelpersReview.new) }

      it 'should remove empty helpers' do
        content =<<-EOF
        module PostsHelper
        end
        EOF
        runner.review('app/helpers/posts_helper.rb', content)
        expect(runner.errors.size).to eq(1)
        expect(runner.errors[0].to_s).to eq('app/helpers/posts_helper.rb:1 - remove empty helpers')
      end

      it 'should not remove empty helpers' do
        content =<<-EOF
        module PostsHelper
          def post_link(post)
            post_path(post)
          end
        end
        EOF
        runner.review('app/helpers/posts_helper.rb', content)
        expect(runner.errors.size).to eq(0)
      end

      it 'should not remove empty application_helper' do
        content =<<-EOF
        module ApplicationHelper
        end
        EOF
        runner.review('app/helpers/application_helper.rb', content)
        expect(runner.errors.size).to eq(0)
      end

      it 'should not check ignored files' do
        runner = Core::Runner.new(reviews: RemoveEmptyHelpersReview.new(ignored_files: /posts_helper/))
        content =<<-EOF
        module PostsHelper
        end
        EOF
        runner.review('app/helpers/posts_helper.rb', content)
        expect(runner.errors.size).to eq(0)
      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/reviews/remove_empty_helpers_review_spec.rb