Sha256: 93ddbadf40e3a6eab168aedd0ebd2e307632205c9d751f1d6836a2927ac51478

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

require 'mspec/runner/mspec'

# Holds some of the state of the example (i.e. +it+ block) that is
# being evaluated. See also +ContextState+.
class ExampleState
  def initialize(describe, it)
    @describe = describe
    @it = it
    @unfiltered = nil
  end

  def describe
    @describe
  end

  def it
    @it
  end

  def description
    @description ||= "#{@describe} #{@it}"
  end

  def unfiltered?
    unless @unfiltered
      incl = MSpec.retrieve(:include) || []
      excl = MSpec.retrieve(:exclude) || []
      @unfiltered   = incl.empty? || incl.any? { |f| f === description }
      @unfiltered &&= excl.empty? || !excl.any? { |f| f === description }
    end
    @unfiltered
  end

  def filtered?
    not unfiltered?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mspec-1.2.0 lib/mspec/runner/example.rb
mspec-1.3.0 lib/mspec/runner/example.rb
mspec-1.3.1 lib/mspec/runner/example.rb