From 3fb9283ca755bba8c87a80da63d540ee8d0d62ce Mon Sep 17 00:00:00 2001 From: Cjay Date: Thu, 2 Jul 2015 18:54:17 +0800 Subject: [PATCH] Add tests for posts --- spec/features/posts/posting_a_post_spec.rb | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/features/posts/posting_a_post_spec.rb diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb new file mode 100644 index 000000000..dabda1586 --- /dev/null +++ b/spec/features/posts/posting_a_post_spec.rb @@ -0,0 +1,34 @@ +require 'rails_helper' + +feature 'Post a post' do + let(:member) { FactoryGirl.create(:member) } + + background do + login_as(member) + visit new_post_path + end + + scenario "creating a post" do + fill_in "post_subject", :with => "Testing" + fill_in "post_body", :with => "This is a sample test" + click_button "Post" + expect(page).to have_content "Post was successfully created" + expect(page).to have_content "Posted by" + end + + context "editing a post" do + let(:existing_post) { FactoryGirl.create(:post, :author => member)} + + background do + visit edit_post_path(existing_post) + end + + scenario "saving edit" do + fill_in "post_subject", :with => "Testing Edit" + click_button "Post" + expect(page).to have_content "Post was successfully updated" + expect(page).to have_content "Edited by" + end + end + +end \ No newline at end of file