Sha256: cb11e3745d25894113dcdbf4512fd6e9f3fd72dbe8dd0db94251689ca3fd9487

Contents?: true

Size: 736 Bytes

Versions: 7

Compression:

Stored size: 736 Bytes

Contents

module Rspectacular
  module ActiveRecord
    module Matchers
      class TruthfulnessMatcher < Shoulda::ActiveRecord::Matchers::ValidationMatcher
        def matches?(truthable)
          super(truthable)

          allows_true &&
          allows_false &&
          disallows_nil
        end

        def allows_true
          allows_value_of(true)
        end

        def allows_false
          allows_value_of(false)
        end

        def disallows_nil
          disallows_value_of(nil)
        end

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

      def validate_truthfulness_of(truthteller)
        TruthfulnessMatcher.new(truthteller)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rspectacular-0.59.0 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb
rspectacular-0.58.0 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb
rspectacular-0.57.0 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb
rspectacular-0.56.0 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb
rspectacular-0.55.0 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb
rspectacular-0.54.0 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb
rspectacular-0.53.1 lib/rspectacular/matchers/active_record/truthfulness_matcher.rb