Sha256: 5186729b04582b3ed8797914f9d76cd35e5deee1e2ebebdcb3af8543251be3e0

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

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(["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

11 entries across 11 versions & 1 rubygems

Version Path
rails_best_practices-1.19.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.18.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.18.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.17.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.16.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.15.7 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.15.6 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.15.4 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.15.3 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.15.2 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.15.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb