Hi all,
I am experiencing a very strange problem using RSpec. I have a very
basic rails3 app, using devise and mongoid.
Following code:
# postcard.rb
class Postcard
include Mongoid::Document
field :text, :type => String
validates_presence_of :text
end
# postcard_spec.rb
require File.dirname(__FILE__) + '/../spec_helper'
describe Postcard do
it {should validate_presence_of(:text)}
it "should validate presence of text" do
p = Postcard.new
p.save!
p.errors.include?(:text).should be_true
end
end
Now, what happens, is that the tests (the shoulda one and my own one)
fail. The Postcard is saved without any warnings or error messages
(also verified by Postcard.count, which is 0 before save! and 1
afterwards.
BUT when I do the exact same code in any controller_spec it works as
expected. Same when I do it on the console. And the validations also
work in the normal app.
So what the heck is wrong with my postcard_spec.rb???
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.