Sha256: 2209c515f81324af4fbc27c2c6b4760e76d59c3f1142c2bed6e4e25e0f69248a

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'guard/plugin'
require 'guard/ui'

require_relative 'busted/options'
require_relative 'busted/runner'
require_relative 'busted/utils'

module Guard
  # Plugin for 'guard' which starts 'busted' (lua unit testing framework) if a change is detected.
  class Busted < Plugin
    include BustedUtils
    attr_reader :options, :runner

    # Initializes a Guard plugin.
    def initialize(options = {})
      super

      @options = Guard::BustedOptions::DEFAULTS.merge(options)
      @runner = Guard::BustedRunner.new(@options)
    end

    # Called once when Guard starts.
    def start
      check_if_busted_exist
      run_all if @options[:run_all_on_start]
    end

    # Called when just `enter` is pressed
    def run_all
      @runner.run_all
    end

    # Called on file(s) modifications that the Guard plugin watches.
    def run_on_modifications(paths)
      @runner.run(paths)
    end

    private

    def check_if_busted_exist
      # :nocov:
      return unless which('busted').nil?

      # :nocov:

      UI.error 'Busted not found. Use :cmd option or ' \
               'install `busted` via `luarocks install busted --local`'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
guard-busted-1.0.1 lib/guard/busted.rb
guard-busted-1.0.0 lib/guard/busted.rb