Class: Gurke::FeatureList::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/gurke/feature_list.rb

Defined Under Namespace

Classes: TagFilter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, files) ⇒ Filter

Returns a new instance of Filter.



65
66
67
68
# File 'lib/gurke/feature_list.rb', line 65

def initialize(options, files)
  @options = options
  @files   = files
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



63
64
65
# File 'lib/gurke/feature_list.rb', line 63

def files
  @files
end

#optionsObject (readonly)

Returns the value of attribute options.



63
64
65
# File 'lib/gurke/feature_list.rb', line 63

def options
  @options
end

Instance Method Details

#filtered?(scenario) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/gurke/feature_list.rb', line 76

def filtered?(scenario)
  filtered_by_tags?(scenario) || (scenario)
end

#filtered_by_line?(scenario) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
89
90
91
92
# File 'lib/gurke/feature_list.rb', line 86

def (scenario)
  _, lines = files.find {|f, _| f == scenario.file }

  return false if lines.empty?

  lines.none? {|l| scenario.line <= l && scenario.steps.last.line >= l }
end

#filtered_by_tags?(scenario) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
83
84
# File 'lib/gurke/feature_list.rb', line 80

def filtered_by_tags?(scenario)
  !tag_filters.reduce(false) do |memo, set|
    memo || set.all? {|rule| rule.match? scenario }
  end
end

#tag_filtersObject



70
71
72
73
74
# File 'lib/gurke/feature_list.rb', line 70

def tag_filters
  @tag_filters ||= options[:tags].map do |list|
    list.strip.split(/[,+\s]\s*/).map {|t| TagFilter.new(t) }
  end
end