Sha256: 08a00dab9e96e71b21768fe0ff6c2ea1ae90a86c8b789f8cf9f70a67ef77c1f6

Contents?: true

Size: 717 Bytes

Versions: 1

Compression:

Stored size: 717 Bytes

Contents

class Soundcheck
  attr_accessor :path

  def initialize(path = "spec", options = {})
    @options = options

    if options[:fast]
      @path = `grep -r -L 'spec_helper' #{path || "spec"} | grep '_spec.rb'`.strip.gsub("\n", " ")
    else
      @path = path || "spec"
    end
  end

  def command_to_run
    if has_gemfile?
      if requires_spec_helper?
        return "rspec --drb #{@path}"
      else
        return "bundle exec rspec --drb #{@path}"
      end
    end

    # Assume rspec
    "rspec --drb #{@path}"
  end

  def requires_spec_helper?
    `grep -r 'spec_helper' #{@path}`
    $?.exitstatus == 1 # no match; we have a stand-alone spec
  end

  def has_gemfile?
    File.exist?("Gemfile")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
soundcheck-0.1.0 lib/soundcheck.rb