Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. # features/post_spec.rb
  2.  
  3. require 'rails_helper'
  4.  
  5. describe 'Navigate' do
  6. before do
  7. @user = FactoryGirl.create(:user)
  8. login_as(@user, :scope => :user)
  9. end
  10.  
  11. describe 'index' do
  12. before do
  13. visit posts_path
  14. end
  15.  
  16. it 'can be reached successfully' do
  17. expect(page.status_code).to eq(200)
  18. end
  19.  
  20. it 'has a title of Posts' do
  21. expect(page).to have_content(/Posts/)
  22. end
  23.  
  24. it 'has a list of Posts' do
  25. post1 = FactoryGirl.build_stubbed(:post)
  26. post2 = FactoryGirl.build_stubbed(:second_post)
  27. visit posts_path
  28. expect(page).to have_content(/Some|super/)
  29. end
  30. end
  31.  
  32. describe 'Creation' do
  33. before do
  34. visit new_post_path
  35. end
  36.  
  37. it 'has a form that can be reached at posts/new' do
  38. expect(page.status_code).to eq(200)
  39. end
  40.  
  41. it 'can be created from new form page' do
  42. fill_in 'post[date]', with: Date.today
  43. fill_in 'post[rationale]', with: 'Some Rationale'
  44. click_on 'Save'
  45.  
  46. expect(page).to have_content('Some Rationale')
  47. end
  48.  
  49. it 'will have a user associated to it' do
  50. fill_in 'post[date]', with: Date.today
  51. fill_in 'post[rationale]', with: 'User_Association'
  52. click_on 'Save'
  53.  
  54. expect(User.last.posts.last.rationale).to eq('User_Association')
  55. end
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement