Sha256: f8a7e4766cb3530911fd969131cc468fae269deff4eebb16dc81d1f674245772

Contents?: true

Size: 997 Bytes

Versions: 13

Compression:

Stored size: 997 Bytes

Contents

require "guard/compat/plugin"

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::Compat::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

13 entries across 13 versions & 3 rubygems

Version Path
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb
geminfo-0.1.0 path/gems/guard-rspec-4.6.4/lib/guard/rspec.rb
guard-rspec-4.6.4 lib/guard/rspec.rb
guard-rspec-4.6.3 lib/guard/rspec.rb
guard-rspec-4.6.2 lib/guard/rspec.rb
guard-rspec-4.6.1 lib/guard/rspec.rb
guard-rspec-4.6.0 lib/guard/rspec.rb
guard-rspec-4.5.2 lib/guard/rspec.rb
guard-rspec-4.5.1 lib/guard/rspec.rb
guard-rspec-4.5.0 lib/guard/rspec.rb