Sha256: f7e8d206f28eccf538c009a3dff814dbb4578983e387b85a6f7a45bfb609bf74

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 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
          methods.get_methods("PostsHelper").map(&:method_name).should == ["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
          helpers.map(&:to_s).should == ["PostsHelper", "Admin::UsersHelper", "Admin", "Admin::BaseHelper"]
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rails_best_practices-1.14.4 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.14.3 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.14.2 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.14.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.14.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.8 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.5 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.4 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.3 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.2 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.13.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.12.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.11.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.11.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.10.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.10.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb