class PoiseBoiler::Helpers::SpecHelper
Helper for a spec_helper.rb to configure things for the Poise workflow. This configures rspec, rspec-its, simplecov (with codeclimate and codecov if possible), and the Halite spec helper.
@since 1.0.0
Public Instance Methods
install()
click to toggle source
# File lib/poise_boiler/helpers/spec_helper.rb, line 28 def install require 'rspec' require 'rspec/its' require 'simplecov' require 'pry' require 'pry-byebug' require 'chefspec' # Check for coverage stuffs formatters = [] if ENV['CODECLIMATE_REPO_TOKEN'] require 'codeclimate-test-reporter' formatters << CodeClimate::TestReporter::Formatter end if ENV['CODECOV_TOKEN'] || ENV['TRAVIS'] require 'codecov' formatters << SimpleCov::Formatter::Codecov end unless formatters.empty? SimpleCov.formatters = formatters end SimpleCov.start do # Don't get coverage on the test cases themselves. add_filter '/spec/' add_filter '/test/' # Codecov doesn't automatically ignore vendored files. add_filter '/vendor/' end RSpec.configure do |config| # Basic configuraiton config.run_all_when_everything_filtered = true config.filter_run(:focus) unless ENV['CI'] # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 config.order = 'random' unless options['no_halite'] require 'halite/spec_helper' config.include Halite::SpecHelper(gem_name ? gemspec : nil) # Hide the spec helper from RSpec traces by default. config.backtrace_exclusion_patterns << %r{/halite/spec_helper} # In verbose mode, set Chef to log level debug by default. if ENV['DEBUG'] config.before { chefspec_options[:log_level] ||= :debug } end end end end