Guest User

Untitled

a guest
Feb 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
  2.  
  3.  
  4.  
  5. describe Post do
  6. fixtures :posts
  7. before(:each) do
  8. @valid_attributes = {
  9. :title => 'test post 4',
  10. :publish_from => Time.now + 2.hours,
  11. :publish_to => Time.now + 3.hours,
  12. }
  13. @invalid_attributes_1 = {
  14. :title => 'test post 4',
  15. :publish_from => Time.now + 3.hours
  16. }
  17. @invalid_attributes_2 = {
  18. :title => 'test post 4',
  19. :publish_from => 2,
  20. :publish_from => '11'
  21. }
  22. end
  23.  
  24. it "should create a new instance given valid attributes" do
  25. Post.create!(@valid_attributes).should be_kind_of(Post)
  26. end
  27.  
  28. it "should return validation of presence error " do
  29. lambda { Post.create!(@invalid_attributes_1) }.should raise_error
  30. end
  31. it "should return data type mismatch error" do
  32. lambda { Post.create!(@invalid_attributes_2) }.should raise_error
  33. end
  34.  
  35. describe "functional tests of" do
  36. describe "searching with :find method" do
  37.  
  38. it "should return post with id 1" do
  39. current_time = Time.parse('2008-12-10 01:28:00 CET').utc
  40. Time.stub!(:now).and_return(current_time)
  41. posts=Post.find(:all)
  42. posts.size.should == 1
  43. posts.first.id.should == 1
  44. end
  45.  
  46. it "should return post with id 2" do
  47. current_time = Time.parse('2008-12-10 02:28:00 CET').utc
  48. Time.stub!(:now).and_return(current_time)
  49. posts=Post.find(:all)
  50. posts.size.should == 1
  51. posts.first.id.should == 2
  52. end
  53.  
  54. it "should return no posts" do
  55. current_time = Time.parse('2008-12-10 03:28:00 CET').utc
  56. Time.stub!(:now).and_return(current_time)
  57. posts=Post.find(:all)
  58. posts.size.should == 0
  59. end
  60.  
  61. end
  62. describe "searching with :between method" do
  63. it "should return posts with id 1 and 2" do
  64.  
  65. end
  66.  
  67. end
  68. end
  69.  
  70. describe "behavioral tests of" do
  71. describe "standard lists posts in category" do
  72. it "should find all published posts in current category" do
  73.  
  74. end
  75. end
  76. end
  77.  
  78. end
Add Comment
Please, Sign In to add comment