module SolargraphTestCoverage::Config
Constants
- DEFAULTS
Public Instance Methods
branch_coverage?()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 34 def branch_coverage? plugin_config['coverage'].include? 'branch' end
exclude_paths()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 26 def exclude_paths plugin_config['exclude_paths'] end
line_coverage?()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 30 def line_coverage? plugin_config['coverage'].include? 'line' end
preload_rails!()
click to toggle source
This gives us a nice speed-boost when running test in child process
We rescue the LoadError since Solargraph would catch it otherwise, and not load the plugin at all.
Adding the spec/ directory to the $LOAD_PATH lets 'require “spec_helper”' commonly found in rails_helper work.
If Coverage was started in Rails/Spec helper by SimpleCov, calling Coverage.result after requiring stops and resets it.
This is a bit experimental
# File lib/solargraph_test_coverage/config.rb, line 92 def preload_rails! return if defined?(Rails) || !File.file?('spec/rails_helper.rb') $LOAD_PATH.unshift(test_path) unless $LOAD_PATH.include?(test_path) require File.join(test_path, 'rails_helper') Coverage.result(stop: true, clear: true) if Coverage.running? true rescue LoadError => e Solargraph::Logging.logger.warn "LoadError when trying to require 'rails_helper'" Solargraph::Logging.logger.warn "[#{e.class}] #{e.message}" false end
preload_rails?()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 22 def preload_rails? plugin_config['preload_rails'] end
require_testing_framework!()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 68 def require_testing_framework! case test_framework when 'rspec' require 'rspec/core' when 'minitest' require 'minitest/autorun' else raise UnknownTestingGem end end
test_dir()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 50 def test_dir case test_framework when 'rspec' 'spec' when 'minitest' 'test' end end
test_failing_coverage?()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 38 def test_failing_coverage? plugin_config['coverage'].include? 'test_failing' end
test_file_suffix()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 59 def test_file_suffix case test_framework when 'rspec' '_spec.rb' when 'minitest' '_test.rb' end end
test_framework()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 46 def test_framework plugin_config['test_framework'] end
test_missing_coverage?()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 42 def test_missing_coverage? plugin_config['coverage'].include? 'test_missing' end
Private Instance Methods
plugin_config()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 110 def plugin_config @plugin_config ||= workspace_config.tap do |config| DEFAULTS.each_key { |key| config[key] = DEFAULTS[key] unless config.key?(key) } end end
test_path()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 120 def test_path ReporterHelpers.test_path end
workspace_config()
click to toggle source
# File lib/solargraph_test_coverage/config.rb, line 116 def workspace_config Solargraph::Workspace::Config.new(Dir.pwd).raw_data.fetch('test_coverage', {}) end