Guest User

Untitled

a guest
Oct 13th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe PostComment do
  4.  
  5. before do
  6. @user = User.create(uname: "mmarignoli", fname:"Marco", email:"test@test.com", password:"foobar", password_confirmation:"foobar")
  7. @post = Post.create(user_id: @user.id, title: "Example Post", content: "Hello this is a test Post")
  8. @firstComment = PostComment.create(content:"Hello There", post_id: @post.id, user_id: @user.id)
  9. @replyComment = PostCommentReply.create(content:"Hello to you", post_comment_id: @firstComment.id, user_id: @user.id)
  10. end
  11.  
  12. it { should respond_to(:content) }
  13. it { should respond_to(:post_id) }
  14. it { should respond_to(:user_id) }
  15.  
  16. describe "user should exist" do
  17. before { @user.uname == "mmarignoli"}
  18. it { should be_valid }
  19. end
  20.  
  21. describe "post should exist" do
  22. before { @post.title == "Example Post"}
  23. it { should be_valid }
  24. end
  25.  
  26. describe "it should have a post" do
  27. before { @firstComment.post.title == "Example Post"}
  28. it { should be_valid}
  29. end
  30.  
  31. describe "it should have a reply" do
  32. before { @firstComment.post_comment_reply[0].content == "Hello to you" }
  33. it {should be_valid}
  34. end
  35.  
  36. describe "it should have 550 char limit" do
  37. before { PostComment.new(content:"a"*551, post_id:1, user_id:1).valid? }
  38. it { should_not be_valid }
  39. end
  40. end
Add Comment
Please, Sign In to add comment