Sha256: 930cefce5218aa896f6fc288e5f67db862d4d3aa40e707b6d3e965e758af128a

Contents?: true

Size: 803 Bytes

Versions: 3

Compression:

Stored size: 803 Bytes

Contents

require 'active_record'
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"

I18n.enforce_available_locales = false

ActiveRecord::Migrator.up "db/migrate"

module ActiveModel::Validations
  # Extension to enhance `should have` on AR Model instances.  Calls
  # model.valid? in order to prepare the object's errors object.
  #
  # You can also use this to specify the content of the error messages.
  #
  # @example
  #
  #     model.should have(:no).errors_on(:attribute)
  #     model.should have(1).error_on(:attribute)
  #     model.should have(n).errors_on(:attribute)
  #
  #     model.errors_on(:attribute).should include("can't be blank")
  def errors_on(attribute)
    self.valid?
    [self.errors[attribute]].flatten.compact
  end
  alias :error_on :errors_on
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
booklist-0.0.10 spec/support/active_record.rb
booklist-0.0.9 spec/support/active_record.rb
booklist-0.0.7 spec/support/active_record.rb