Sha256: 4f3be935e28e2832b9887d15503c78c5ed3e1afc3cda1719bf338ff9a4666aab

Contents?: true

Size: 772 Bytes

Versions: 9

Compression:

Stored size: 772 Bytes

Contents

if defined?(ActiveRecord::Base)
  module Spec
    module Rails
      module 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
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-rails-1.3.4/lib/spec/rails/matchers/ar_be_valid.rb
richzhou-rspec-rails-1.3.4 lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-1.3.4 lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-1.3.3 lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-1.3.3.rc lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-w-factory_girl-1.3.2.1 lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-w-factory_girl-1.3.2 lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-1.3.2 lib/spec/rails/matchers/ar_be_valid.rb
rspec-rails-1.3.1 lib/spec/rails/matchers/ar_be_valid.rb