Class: RSpectacular::ActiveRecord::Matchers::TruthfulnessMatcher

Inherits:
Shoulda::ActiveRecord::Matchers::ValidationMatcher
  • Object
show all
Defined in:
lib/rspectacular/matchers/active_record/truthfulness_matcher.rb

Instance Method Summary collapse

Instance Method Details

#allows_falseObject



17
18
19
# File 'lib/rspectacular/matchers/active_record/truthfulness_matcher.rb', line 17

def allows_false
  allows_value_of(false)
end

#allows_trueObject



13
14
15
# File 'lib/rspectacular/matchers/active_record/truthfulness_matcher.rb', line 13

def allows_true
  allows_value_of(true)
end

#descriptionObject



25
26
27
# File 'lib/rspectacular/matchers/active_record/truthfulness_matcher.rb', line 25

def description
  "should accept only boolean true or false values"
end

#disallows_nilObject



21
22
23
# File 'lib/rspectacular/matchers/active_record/truthfulness_matcher.rb', line 21

def disallows_nil
  disallows_value_of(nil)
end

#matches?(truthable) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/rspectacular/matchers/active_record/truthfulness_matcher.rb', line 5

def matches?(truthable)
  super(truthable)

  allows_true &&
  allows_false &&
  disallows_nil
end