Sha256: 38a241b18c52b3620464dc30179df7aa6f9c33089034ebf860e366f861aec5c1

Contents?: true

Size: 594 Bytes

Versions: 3

Compression:

Stored size: 594 Bytes

Contents

require "spec_helper"

describe ActiveModel::Validations::NumericalityValidator do

  describe "#validate_each" do

    before(:all) do
      class TestModel
        include Mongoid::Document
        field :amount, type: BigDecimal
        validates_numericality_of :amount, allow_blank: false
      end
    end

    after(:all) do
      Object.send(:remove_const, :TestModel)
    end

    context "when the value is non numeric" do

      let(:model) do
        TestModel.new(amount: "asdf")
      end

      it "returns false" do
        model.should_not be_valid
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid-3.1.7 spec/mongoid/validations/numericality_spec.rb
mongoid-3.1.6 spec/mongoid/validations/numericality_spec.rb
mongoid-3.1.5 spec/mongoid/validations/numericality_spec.rb