Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View run
1 2
Notes:
mongoid: https://github.com/mongoid/mongoid/commit/15ac280c37ca1f5bcdd517a368bb0735d2806321 (master)
View run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
$ bundle exec rspec spec
.FFF
 
Failures:
 
1) Widget assigning a not-very-big integer
Failure/Error: it { should be_valid }
expected valid? to return true, got false
# ./spec/models/widget_spec.rb:25:in `block (3 levels) in <top (required)>'
 
2) Widget assigning a not-very-big integer the errors object should not demand that not_very_big_integer be an integer
Failure/Error: subject.errors[:not_very_big_integer].should_not include "must be an integer"
expected ["must be an integer"] not to include "must be an integer"
Diff:
@@ -1,2 +1,2 @@
-must be an integer
+["must be an integer"]
# ./spec/models/widget_spec.rb:31:in `block (4 levels) in <top (required)>'
 
3) Widget assigning a not-very-big integer the errors object errors
Failure/Error: its(:errors){ should_not include :not_very_big_integer }
expected #<ActiveModel::Errors:0x00000001be1da0 @base=#<Widget _id: 4e77b68fb2bc071301000004, _type: nil, not_very_big_integer: 1048576.0>, @messages={:not_very_big_integer=>["must be an integer"]}> not to include :not_very_big_integer
Diff:
@@ -1,2 +1,5 @@
-:not_very_big_integer
+#<ActiveModel::Errors:0x00000001be1da0
+ @base=
+ #<Widget _id: 4e77b68fb2bc071301000004, _type: nil, not_very_big_integer: 1048576.0>,
+ @messages={:not_very_big_integer=>["must be an integer"]}>
# ./spec/models/widget_spec.rb:29:in `block (4 levels) in <top (required)>'
 
Finished in 0.04039 seconds
4 examples, 3 failures
 
Failed examples:
 
rspec ./spec/models/widget_spec.rb:25 # Widget assigning a not-very-big integer
rspec ./spec/models/widget_spec.rb:30 # Widget assigning a not-very-big integer the errors object should not demand that not_very_big_integer be an integer
rspec ./spec/models/widget_spec.rb:29 # Widget assigning a not-very-big integer the errors object errors
View run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
 
require "spec_helper"
 
class Widget
include Mongoid::Document
 
field :not_very_big_integer,
:type => Integer
 
validates :not_very_big_integer,
:numericality => {
:only_integer => true,
:allow_nil => true
}
end
 
describe Widget do
 
subject { Widget.new }
it { should be_valid } # just to double-check
 
context "assigning a not-very-big integer" do
let(:not_very_big_integer) { 1048576}
 
before { subject.not_very_big_integer = not_very_big_integer }
it { should be_valid } # fails
 
context "the errors object" do
before { subject.valid? }
its(:errors) { should_not include :not_very_big_integer } # fails
it "should not demand that not_very_big_integer be an integer" do
subject.errors[:not_very_big_integer].should_not include "must be an integer" # fails
end
end
end
 
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.