Class: Shoulda::Matchers::ActiveModel::DisallowValueMatcher

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/shoulda/matchers/active_model/disallow_value_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ DisallowValueMatcher

Returns a new instance of DisallowValueMatcher.



27
28
29
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 27

def initialize(value)
  @allow_matcher = AllowValueMatcher.new(value)
end

Instance Method Details

#does_not_match?(subject) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 35

def does_not_match?(subject)
  allow_matcher.matches?(subject)
end

#failure_messageObject



64
65
66
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 64

def failure_message
  allow_matcher.failure_message_when_negated
end

#failure_message_when_negatedObject



68
69
70
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 68

def failure_message_when_negated
  allow_matcher.failure_message
end

#for(attribute) ⇒ Object



39
40
41
42
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 39

def for(attribute)
  allow_matcher.for(attribute)
  self
end

#ignoring_interference_by_writer(value = :always) ⇒ Object



59
60
61
62
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 59

def ignoring_interference_by_writer(value = :always)
  allow_matcher.ignoring_interference_by_writer(value)
  self
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 31

def matches?(subject)
  allow_matcher.does_not_match?(subject)
end

#on(context) ⇒ Object



44
45
46
47
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 44

def on(context)
  allow_matcher.on(context)
  self
end

#strict(strict = true) ⇒ Object



54
55
56
57
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 54

def strict(strict = true)
  allow_matcher.strict(strict)
  self
end

#with_message(message, options = {}) ⇒ Object



49
50
51
52
# File 'lib/shoulda/matchers/active_model/disallow_value_matcher.rb', line 49

def with_message(message, options = {})
  allow_matcher.with_message(message, options)
  self
end