Sha256: 00c1be0ce809deab8cf46223e64ed6e3312694353952e609fc69773cf505663c

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe RailsBestPractices::Prepares::HelperPrepare do
  let(:runner) { RailsBestPractices::Core::Runner.new(:prepares => 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

3 entries across 3 versions & 2 rubygems

Version Path
rails_best_practices-gorgeouscode-1.0.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.9.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb
rails_best_practices-1.8.0 spec/rails_best_practices/prepares/helper_prepare_spec.rb