/ Published in: Rails
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 class Post < ActiveRecord::Base validates_presence_of :title validates_presence_of :publishing_date, :if => :published end class PostTest < ActiveSupport::TestCase context "Post that is NOT going to be published" do should validate_presence_of(:title) should_not validate_presence_of(:publishing_date) end context "Post that is going to be published" do subject do Post.new(:title => 'Valid Title', :published => true) end should validate_presence_of(:publishing_date) end end
Comments
                    Subscribe to comments
                
                