Sha256: 16730ae28084067c1378f39d3e826a7d9ed677443119094b33c719dd89449356

Contents?: true

Size: 535 Bytes

Versions: 17

Compression:

Stored size: 535 Bytes

Contents

require 'mspec/guards/guard'

class RunnerGuard < SpecGuard
  def match?
    @args.any? do |runner|
      case runner
      when :mspec
        ENV['MSPEC_RUNNER'] == '1'
      when :rspec
        ENV['RSPEC_RUNNER'] == '1' or Object.const_defined?(:Spec)
      else
        false
      end
    end
  end
end

class Object
  def runner_is(*args)
    g = RunnerGuard.new(*args)
    yield if g.yield?
    g.unregister
  end

  def runner_is_not(*args)
    g = RunnerGuard.new(*args)
    yield if g.yield? true
    g.unregister
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mspec-1.0.0 lib/mspec/guards/runner.rb
mspec-1.5.0 lib/mspec/guards/runner.rb
mspec-1.5.3 lib/mspec/guards/runner.rb
mspec-1.1.1 lib/mspec/guards/runner.rb
mspec-1.3.0 lib/mspec/guards/runner.rb
mspec-1.5.1 lib/mspec/guards/runner.rb
mspec-1.5.2 lib/mspec/guards/runner.rb
mspec-1.5.4 lib/mspec/guards/runner.rb
mspec-1.3.1 lib/mspec/guards/runner.rb
mspec-1.2.0 lib/mspec/guards/runner.rb
mspec-1.1.0 lib/mspec/guards/runner.rb
mspec-1.4.0 lib/mspec/guards/runner.rb
mspec-1.5.8 lib/mspec/guards/runner.rb
mspec-1.5.5 lib/mspec/guards/runner.rb
mspec-1.5.6 lib/mspec/guards/runner.rb
mspec-1.5.7 lib/mspec/guards/runner.rb
mspec-1.5.9 lib/mspec/guards/runner.rb