Sha256: 7d8e07fbaae45e11bb284b34a262695ac51c16a30978e35a7be0242278c56869

Contents?: true

Size: 1.05 KB

Versions: 58

Compression:

Stored size: 1.05 KB

Contents

require 'mspec/guards/guard'

class FeatureGuard < SpecGuard
  def self.enabled?(*features)
    new(*features).match?
  end

  def match?
    @parameters.all? { |f| MSpec.feature_enabled? f }
  end
end

class Object
  # Provides better documentation in the specs by
  # naming sets of features that work together as
  # a whole. Examples include :encoding, :fiber,
  # :continuation, :fork.
  #
  # Usage example:
  #
  #   with_feature :encoding do
  #     # specs for a method that provides aspects
  #     # of the encoding feature
  #   end
  #
  # Multiple features must all be enabled for the
  # guard to run:
  #
  #   with_feature :one, :two do
  #     # these specs will run if features :one AND
  #     # :two are enabled.
  #   end
  #
  # The implementation must explicitly enable a feature
  # by adding code like the following to the .mspec
  # configuration file:
  #
  #   MSpec.enable_feature :encoding
  #
  def with_feature(*features)
    g = FeatureGuard.new(*features)
    g.name = :with_feature
    yield if g.yield?
  ensure
    g.unregister
  end
end

Version data entries

58 entries across 58 versions & 3 rubygems

Version Path
rhodes-5.5.18 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.17 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.15 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.0.22 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.2 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.0.7 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.0.3 lib/extensions/mspec/mspec/guards/feature.rb
rhodes-5.5.0 lib/extensions/mspec/mspec/guards/feature.rb
tauplatform-1.0.3 lib/extensions/mspec/mspec/guards/feature.rb
mspec-1.9.1 lib/mspec/guards/feature.rb
mspec-1.9.0 lib/mspec/guards/feature.rb
tauplatform-1.0.2 lib/extensions/mspec/mspec/guards/feature.rb
tauplatform-1.0.1 lib/extensions/mspec/mspec/guards/feature.rb
mspec-1.8.0 lib/mspec/guards/feature.rb
mspec-1.7.0 lib/mspec/guards/feature.rb
mspec-1.6.0 lib/mspec/guards/feature.rb
mspec-1.5.21 lib/mspec/guards/feature.rb
mspec-1.5.20 lib/mspec/guards/feature.rb
mspec-1.5.19 lib/mspec/guards/feature.rb
mspec-1.5.18 lib/mspec/guards/feature.rb