Sha256: 6da1c55655ea1582df1c1267de42bb021ca709b924f235d83a33f1500fe8f77c

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

require "guard/rspec/options"
require "guard/rspec/deprecator"
require "guard/rspec/runner"

# NOTE: To avoid 'superclass mismatch for class RSpec' errors,
# every file has to have
#
#   class RSpec < Plugin
#
# and not just
#
#   class RSpec

module Guard
  class RSpec < Plugin
    attr_accessor :options, :runner

    def initialize(options = {})
      super
      @options = Options.with_defaults(options)
      Deprecator.warns_about_deprecated_options(@options)
      @runner = Runner.new(@options)
    end

    def start
      ::Guard::UI.info "Guard::RSpec is running"
      run_all if options[:all_on_start]
    end

    def run_all
      _throw_if_failed { runner.run_all }
    end

    def reload
      runner.reload
    end

    def run_on_modifications(paths)
      return false if paths.empty?
      _throw_if_failed { runner.run(paths) }
    end

    private

    def _throw_if_failed
      throw :task_has_failed unless yield
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-rspec-4.4.1 lib/guard/rspec.rb