Sha256: 749083173e9d0df7daa57ac7dd89c44ad782ad6a8ca21dd6c4274234694b99c1

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

require 'guard'
require 'guard/plugin'

module Guard
  class RSpec < Plugin
    require 'guard/rspec/deprecator'
    require 'guard/rspec/runner'

    attr_accessor :options, :runner

    def initialize(options = {})
      super
      @options = {
        all_on_start: false
      }.merge(options)

      Deprecator.warns_about_deprecated_options(@options)
      @runner = Runner.new(@options)
    end

    def start
      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

3 entries across 3 versions & 1 rubygems

Version Path
guard-rspec-4.0.2 lib/guard/rspec.rb
guard-rspec-4.0.1 lib/guard/rspec.rb
guard-rspec-4.0.0 lib/guard/rspec.rb