Sha256: 2d41417278080c69724e7a04dd1cdbf60861f6764883e90305238b2d6745eeee

Contents?: true

Size: 875 Bytes

Versions: 16

Compression:

Stored size: 875 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveModel # :nodoc

      # Usage example: be_boolean(:private)
      def be_boolean(attribute)
        BeBooleanMatcher.new(attribute)
      end

      class BeBooleanMatcher < ValidationMatcher # :nodoc:
        def initialize(attribute)
          @attribute = attribute
        end

        def matches?(subject)
          @subject = subject
          disallows_value_of(nil) &&
            disallows_value_of("") &&
            allows_value_of(true) &&
            allows_value_of(false)
        end

        def description
          description = "#{@attribute} should be a boolean"
        end

        def failure_message
          "Expected #{@attribute} to be a boolean"
        end

        def negative_failure_message
          "Did not expect #{@attribute} to be a boolean"
        end

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bigbluebutton_rails-3.0.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-2.3.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-2.2.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-2.1.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-2.0.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-1.3.0.mweb1 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-1.4.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-1.4.0.beta1 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-1.3.0 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-1.3.0.beta1 spec/support/matchers/shoulda/be_boolean_matcher.rb
bigbluebutton_rails-1.2.0 spec/support/matchers/shoulda/be_boolean.rb
bigbluebutton_rails-1.1.0 spec/support/matchers/shoulda/be_boolean.rb
bigbluebutton_rails-1.0.0 spec/support/matchers/shoulda/be_boolean.rb
bigbluebutton_rails-0.1.1 spec/support/matchers/shoulda/be_boolean.rb
bigbluebutton_rails-0.1.0 spec/support/matchers/shoulda/be_boolean.rb
bigbluebutton_rails-0.0.6 spec/support/matchers/shoulda/be_boolean.rb