Sha256: 51913c7975e27128c07434c7b42fff636fbd33a4689368acc1eeb7d75a499ab6

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

if defined?(ActiveRecord::Base)
  module Spec::Rails::Matchers
    # :call-seq:
    #   response.should be_valid
    #   response.should_not be_valid
    def be_valid
      ::Spec::Matchers::Matcher.new :be_valid do
        match do |actual|
          actual.valid?
        end

        failure_message_for_should do |actual|
          if actual.respond_to?(:errors) && ActiveRecord::Errors === actual.errors
            "Expected #{actual.inspect} to be valid, but it was not\nErrors: " + actual.errors.full_messages.join(", ")            
          else
            "Expected #{actual.inspect} to be valid"
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-rails-1.3.0 lib/spec/rails/matchers/ar_be_valid.rb