Module: EacRubyGemSupport::Rspec::Setup::Rubocop
- Defined in:
- lib/eac_ruby_gem_support/rspec/setup/rubocop.rb
Constant Summary collapse
- RUN_LAST_METADATA_KEY =
:eac_ruby_gem_support_rubocop_check
Instance Method Summary collapse
-
#describe_rubocop ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
- #setup_rubocop ⇒ void
- #setup_rubocop_last ⇒ void
- #specific_files_requested? ⇒ Boolean
Instance Method Details
#describe_rubocop ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/eac_ruby_gem_support/rspec/setup/rubocop.rb', line 12 def describe_rubocop # rubocop:disable Metrics/AbcSize, Metrics/MethodLength this = self ::RSpec.describe ::RuboCop, RUN_LAST_METADATA_KEY => true do before do ::RuboCop::ConfigLoader.ignore_parent_exclusion = true end let(:root_path) { this.app_root_path } let(:config_store) do r = ::RuboCop::ConfigStore.new r.for(root_path) r end let(:runner) { ::RuboCop::Runner.new({}, config_store) } it 'rubocop return ok' do expect(::Dir.chdir(root_path) { runner.run([]) }).to eq(true) end end end |
#setup_rubocop ⇒ void
This method returns an undefined value.
34 35 36 37 |
# File 'lib/eac_ruby_gem_support/rspec/setup/rubocop.rb', line 34 def setup_rubocop setup_rubocop_last describe_rubocop unless specific_files_requested? end |
#setup_rubocop_last ⇒ void
This method returns an undefined value.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/eac_ruby_gem_support/rspec/setup/rubocop.rb', line 40 def setup_rubocop_last previous_strategy = ::RSpec.configuration.ordering_registry.fetch(:global) ::RSpec.configure do |config| config.register_ordering(:global) do |list| ordered = previous_strategy.order(list) last, others = ordered.partition { |item| item.[RUN_LAST_METADATA_KEY] } others + last end end end |
#specific_files_requested? ⇒ Boolean
52 53 54 55 56 57 |
# File 'lib/eac_ruby_gem_support/rspec/setup/rubocop.rb', line 52 def specific_files_requested? config = ::RSpec.configuration files_or_directories = config.instance_variable_get(:@files_or_directories_to_run) default_pattern = ::RSpec::Core::Configuration.new.pattern files_or_directories != [config.default_path] || config.pattern != default_pattern end |