Skip to content

Commit

Permalink
Add some tests for editing and delete and improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
josiasds committed Oct 13, 2015
1 parent 09095db commit 5d21110
Showing 1 changed file with 53 additions and 18 deletions.
71 changes: 53 additions & 18 deletions spec/features/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,66 @@
it_behaves_like "Comments Form"
end

feature "Add new comment from main page" do
background do
visit root_path
feature "Add new comment" do
context "from the main page" do
background do
visit root_path
end

include_context "Horizontal Form"
include_context "Inline Form"
include_context "Stacked Form"
end

include_context "Horizontal Form"
include_context "Inline Form"
include_context "Stacked Form"
end
context "from the simple page" do
background do
visit simple_path
end

feature "Add new comment from simple page" do
background do
visit simple_path
include_context "Horizontal Form"
include_context "Inline Form"
include_context "Stacked Form"
end

include_context "Horizontal Form"
include_context "Inline Form"
include_context "Stacked Form"
context "from the classic page" do
background do
visit comments_path
click_link "New Comment"
end

it_behaves_like "Comments Form"
end
end

feature "Add new comment from classic page" do
background do
visit comments_path
click_link "New Comment"
feature "Edit a comment" do
context "from the classic page" do
let(:edited_name) { "Edited Name" }

background do
visit comments_path
click_link "Edit", match: :first
end

include_context "Form Submitted", name: :edited_name

scenario "submits form" do
expect(page).to have_css(".comment", text: :edited_name)
end
end
end

it_behaves_like "Comments Form"
feature "Destroy a comment" do
context "from the classic page" do
let(:comment) { Comment.first }

background do
visit comments_path
click_link "Destroy", href: comment_path(comment)
end

scenario "destroys comment" do
expect(page).to_not have_css(".comment", text: comment.author)
expect(page).to_not have_css(".comment", text: comment.text)
end
end
end

0 comments on commit 5d21110

Please sign in to comment.