Sha256: 4cfcc1cca95e1c6696dc3cf5af198cb277cfd323419d2d63ae55db4bda0ea3e9

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Prepares::HelperPrepare do
  let(:runner) { RailsBestPractices::Core::Runner.new(:parepare => RailsBestPractices::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 = RailsBestPractices::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 = RailsBestPractices::Prepares.helpers
      helpers.map(&:to_s).should == ["PostsHelper", "Admin::UsersHelper", "Admin", "Admin::BaseHelper"]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_best_practices-1.7.2 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.7.1 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.7.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.6.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb