Sha256: 33a64ca035507ab5c663d62c7bf5e4611138968f306c601f726252a74edc7534

Contents?: true

Size: 578 Bytes

Versions: 4

Compression:

Stored size: 578 Bytes

Contents

RSpec::Matchers.define :have_error_on do |*args|
  @message = nil
  @attributes = [args]

  chain :or do |*args|
    @attributes << args
  end

  match do |model|
    model.valid?
    @has_errors = @attributes.detect {|attribute| model.errors[attribute[0]].present? }
    if @message
      !!@has_errors && model.errors[@has_errors[0]].include?(@has_errors[1])
    else
      !!@has_errors
    end
  end
end

RSpec::Matchers.define :have_index do |index_name|
  match do |model|
    model.collection.index_information.detect { |index| index[0] == index_name }.present?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo_mapper-0.13.1 spec/support/matchers.rb
mongo_mapper-0.13.0 spec/support/matchers.rb
mongo_mapper-0.13.0.beta2 spec/support/matchers.rb
mongo_mapper-0.13.0.beta1 spec/support/matchers.rb