class Transpec::Config

Constants

BOOLEAN_MATCHER_TYPES
DEFAULT_CONVERSIONS
FORMS_OF_BE_FALSEY
NEGATIVE_FORMS_OF_TO
PREDICATES

Attributes

boolean_matcher_type[RW]
conversion[R]
form_of_be_falsey[RW]
negative_form_of_to[RW]
rspec_command[RW]

Public Class Methods

conversion_types() click to toggle source
# File lib/transpec/config.rb, line 43
def self.conversion_types
  DEFAULT_CONVERSIONS.keys
end
new() click to toggle source
# File lib/transpec/config.rb, line 47
def initialize
  PREDICATES.each do |predicate, default_value|
    instance_variable_set('@' + predicate.to_s, default_value)
  end

  @conversion = SymbolKeyHash.new
  @conversion.update(DEFAULT_CONVERSIONS)

  self.negative_form_of_to = 'not_to'
  self.boolean_matcher_type = :conditional
  self.form_of_be_falsey = 'be_falsey'
end
valid_conversion_type?(type) click to toggle source
# File lib/transpec/config.rb, line 39
def self.valid_conversion_type?(type)
  conversion_types.include?(type.to_sym)
end

Public Instance Methods

boolean_matcher_type=(type) click to toggle source
# File lib/transpec/config.rb, line 69
def boolean_matcher_type=(type)
  validate!(type.to_sym, BOOLEAN_MATCHER_TYPES, 'Boolean matcher type')
  @boolean_matcher_type = type.to_sym
end
convert?(type) click to toggle source
# File lib/transpec/config.rb, line 60
def convert?(type)
  @conversion[type]
end
form_of_be_falsey=(form) click to toggle source
# File lib/transpec/config.rb, line 74
def form_of_be_falsey=(form)
  validate!(form.to_s, FORMS_OF_BE_FALSEY, 'Form of "be_falsey"')
  @form_of_be_falsey = form.to_s.freeze
end
negative_form_of_to=(form) click to toggle source
# File lib/transpec/config.rb, line 64
def negative_form_of_to=(form)
  validate!(form.to_s, NEGATIVE_FORMS_OF_TO, 'Negative form of "to"')
  @negative_form_of_to = form.to_s.freeze
end

Private Instance Methods

validate!(arg, valid_values, subject) click to toggle source
# File lib/transpec/config.rb, line 81
def validate!(arg, valid_values, subject)
  return if valid_values.include?(arg)
  message = "#{subject} must be either "
  message << valid_values.map(&:inspect).join(' or ')
  fail ArgumentError, message
end