Sha256: 706d0cb0ed61baefc1f2b366cd47584568da96eaa8aac62cd51c3f8bf67a9658
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require_relative 'fsr/version' require 'listen' # Run RSpec fast by avoiding full app boot # # ```rb # listener = Runner.listen( # [ # 'spec/search/service/fql/builder_spec.rb:42' # ], # load: # [ # 'lib/search/service/fql/builder.rb', # 'lib/search/service/fql.rb', # 'lib/rts/util.rb' # ] # ) # # listener.start # listener.stop # ``` module Fsr def self.listen( run, load: [], listen: [ "#{`pwd`.strip}/app", "#{`pwd`.strip}/lib", "#{`pwd`.strip}/spec" ] ) Listen.to(*listen) { new(run, load: load).run } end # core runner class Core def initialize(specs, load: []) @specs = specs @dependent_files = load end def run @dependent_files.each { |file| load(file) } RSpec::Core::Runner.run(@specs) cleanup end def cleanup warn_level = $VERBOSE $VERBOSE = nil remove_rspec require('rspec') configure $VERBOSE = warn_level end def remove_rspec Object.send(:remove_const, 'RSpec') $LOADED_FEATURES.reject! { |a| a.include?('rspec') } end def configure load('spec/spec_helper.rb') load('spec/rails_helper.rb') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fsr-0.1.1 | lib/fsr.rb |