Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
- describe Post do
- fixtures :posts
- before(:each) do
- @valid_attributes = {
- :title => 'test post 4',
- :publish_from => Time.now + 2.hours,
- :publish_to => Time.now + 3.hours,
- }
- @invalid_attributes_1 = {
- :title => 'test post 4',
- :publish_from => Time.now + 3.hours
- }
- @invalid_attributes_2 = {
- :title => 'test post 4',
- :publish_from => 2,
- :publish_from => '11'
- }
- end
- it "should create a new instance given valid attributes" do
- Post.create!(@valid_attributes).should be_kind_of(Post)
- end
- it "should return validation of presence error " do
- lambda { Post.create!(@invalid_attributes_1) }.should raise_error
- end
- it "should return data type mismatch error" do
- lambda { Post.create!(@invalid_attributes_2) }.should raise_error
- end
- describe "functional tests of" do
- describe "searching with :find method" do
- it "should return post with id 1" do
- current_time = Time.parse('2008-12-10 01:28:00 CET').utc
- Time.stub!(:now).and_return(current_time)
- posts=Post.find(:all)
- posts.size.should == 1
- posts.first.id.should == 1
- end
- it "should return post with id 2" do
- current_time = Time.parse('2008-12-10 02:28:00 CET').utc
- Time.stub!(:now).and_return(current_time)
- posts=Post.find(:all)
- posts.size.should == 1
- posts.first.id.should == 2
- end
- it "should return no posts" do
- current_time = Time.parse('2008-12-10 03:28:00 CET').utc
- Time.stub!(:now).and_return(current_time)
- posts=Post.find(:all)
- posts.size.should == 0
- end
- end
- describe "searching with :between method" do
- it "should return posts with id 1 and 2" do
- end
- end
- end
- describe "behavioral tests of" do
- describe "standard lists posts in category" do
- it "should find all published posts in current category" do
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment