Class: EacRubyUtils::Rspec::Conditional

Inherits:
Object
  • Object
show all
Includes:
Console::Speaker
Defined in:
lib/eac_ruby_utils/rspec/conditional.rb

Constant Summary

Constants included from Console::Speaker

Console::Speaker::STDERR, Console::Speaker::STDIN, Console::Speaker::STDOUT

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Console::Speaker

current_node, #fatal_error, #info, #infom, #infov, on_node, #on_speaker_node, #out, pop, push, #puts, #request_input, #success, #title, #warn

Constructor Details

#initializeConditional

Returns a new instance of Conditional.


15
16
17
# File 'lib/eac_ruby_utils/rspec/conditional.rb', line 15

def initialize
  @tags = {}
end

Class Method Details

.defaultObject


11
12
13
# File 'lib/eac_ruby_utils/rspec/conditional.rb', line 11

def self.default
  @default ||= new
end

Instance Method Details

#add(tag, &condition) ⇒ Object


19
20
21
# File 'lib/eac_ruby_utils/rspec/conditional.rb', line 19

def add(tag, &condition)
  tags[tag] = condition
end

#configure(rspec_config) ⇒ Object


23
24
25
26
27
28
29
30
31
# File 'lib/eac_ruby_utils/rspec/conditional.rb', line 23

def configure(rspec_config)
  tags.each do |tag, condition|
    message = condition.call
    if message.present?
      warn("Excluded tag: #{tag}: #{message}")
      rspec_config.filter_run_excluding tag
    end
  end
end