Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.join( File.dirname(__FILE__), "..", "spec_helper" )
- describe Entry do
- def valid_entry_attributes
- { :title => 'Entry title',
- :alias => 'entry-title',
- :body => 'My entry content' }
- end
- before(:all) do
- @user = User.new( { :username => 'second',
- :password => Digest::SHA1.hexdigest("somepassword"),
- :email => 'second@user.com' } )
- pp @user.email
- pp @user.save
- pp @user.email
- end
- before(:each) do
- @entry = Entry.new
- end
- it "should be invalid without a title" do
- @entry.set valid_entry_attributes.except(:title)
- @entry.user = @user
- @entry.should_not be_valid
- @entry.set valid_entry_attributes.only(:title)
- @entry.should be_valid
- end
- it "should be invalid without an alias" do
- @entry.set valid_entry_attributes.except(:title)
- @entry.user = @user
- @entry.should_not be_valid
- @entry.set valid_entry_attributes.only(:title)
- @entry.should be_valid
- end
- it "should be invalid without a body" do
- @entry.set valid_entry_attributes.except(:body)
- @entry.user = @user
- @entry.should_not be_valid
- @entry.set valid_entry_attributes.only(:body)
- @entry.should be_valid
- end
- it "should should have assigned user" do
- @entry.set valid_entry_attributes
- @entry.should_not be_valid
- @entry.user = @user
- @entry.should be_valid
- end
- it "should set created_at/updated_at after create/save" do
- @entry.set valid_entry_attributes
- @entry.user = @user
- @entry.save
- @entry.created_at.should_not be_nil
- @entry.updated_at.should_not be_nil
- date = @entry.updated_at
- @entry.title = "Second entry title"
- @entry.save
- @entry.updated_at.should_not eql(date)
- end
- end
Add Comment
Please, Sign In to add comment